bug fixed: log header correctly when rotate

pull/4/head
yuqing 2015-05-15 14:02:39 +08:00
parent 8b9bdfd333
commit 0fd3425fb6
2 changed files with 7 additions and 6 deletions

View File

@ -5,6 +5,7 @@ Version 1.14 2015-05-15
* bugfixed: sockopt.c correct fsbytes to sbytes in FreeBSD
* macro FDFS_WRITE_BUFF_SIZE change to FAST_WRITE_BUFF_SIZE
* logger.c call log_check_rotate in lock
* bug fixed: log header correctly when rotate
Version 1.13 2015-02-27
* support php extension

View File

@ -567,9 +567,9 @@ static int log_fsync(LogContext *pContext, const bool bNeedLock)
int result;
int lock_res;
int write_bytes;
int written;
write_bytes = pContext->pcurrent_buff - pContext->log_buff;
if (write_bytes == 0)
if (pContext->pcurrent_buff - pContext->log_buff == 0)
{
if (!pContext->rotate_immediately)
{
@ -599,6 +599,7 @@ static int log_fsync(LogContext *pContext, const bool bNeedLock)
__LINE__, lock_res, STRERROR(lock_res));
}
write_bytes = pContext->pcurrent_buff - pContext->log_buff;
pContext->current_size += write_bytes;
if (pContext->rotate_size > 0)
{
@ -612,9 +613,9 @@ static int log_fsync(LogContext *pContext, const bool bNeedLock)
result = 0;
do
{
write_bytes = pContext->pcurrent_buff - pContext->log_buff;
if (write(pContext->log_fd, pContext->log_buff, write_bytes) != \
write_bytes)
written = write(pContext->log_fd, pContext->log_buff, write_bytes);
pContext->pcurrent_buff = pContext->log_buff;
if (written != write_bytes)
{
result = errno != 0 ? errno : EIO;
fprintf(stderr, "file: "__FILE__", line: %d, " \
@ -629,7 +630,6 @@ static int log_fsync(LogContext *pContext, const bool bNeedLock)
}
} while (0);
pContext->pcurrent_buff = pContext->log_buff;
if (bNeedLock && ((lock_res=pthread_mutex_unlock( \
&(pContext->log_thread_lock))) != 0))
{