bug fixed: log header correctly when rotate
parent
8b9bdfd333
commit
0fd3425fb6
1
HISTORY
1
HISTORY
|
|
@ -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
|
||||
|
|
|
|||
12
src/logger.c
12
src/logger.c
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue