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
|
* bugfixed: sockopt.c correct fsbytes to sbytes in FreeBSD
|
||||||
* macro FDFS_WRITE_BUFF_SIZE change to FAST_WRITE_BUFF_SIZE
|
* macro FDFS_WRITE_BUFF_SIZE change to FAST_WRITE_BUFF_SIZE
|
||||||
* logger.c call log_check_rotate in lock
|
* logger.c call log_check_rotate in lock
|
||||||
|
* bug fixed: log header correctly when rotate
|
||||||
|
|
||||||
Version 1.13 2015-02-27
|
Version 1.13 2015-02-27
|
||||||
* support php extension
|
* 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 result;
|
||||||
int lock_res;
|
int lock_res;
|
||||||
int write_bytes;
|
int write_bytes;
|
||||||
|
int written;
|
||||||
|
|
||||||
write_bytes = pContext->pcurrent_buff - pContext->log_buff;
|
if (pContext->pcurrent_buff - pContext->log_buff == 0)
|
||||||
if (write_bytes == 0)
|
|
||||||
{
|
{
|
||||||
if (!pContext->rotate_immediately)
|
if (!pContext->rotate_immediately)
|
||||||
{
|
{
|
||||||
|
|
@ -599,6 +599,7 @@ static int log_fsync(LogContext *pContext, const bool bNeedLock)
|
||||||
__LINE__, lock_res, STRERROR(lock_res));
|
__LINE__, lock_res, STRERROR(lock_res));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_bytes = pContext->pcurrent_buff - pContext->log_buff;
|
||||||
pContext->current_size += write_bytes;
|
pContext->current_size += write_bytes;
|
||||||
if (pContext->rotate_size > 0)
|
if (pContext->rotate_size > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -612,9 +613,9 @@ static int log_fsync(LogContext *pContext, const bool bNeedLock)
|
||||||
result = 0;
|
result = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
write_bytes = pContext->pcurrent_buff - pContext->log_buff;
|
written = write(pContext->log_fd, pContext->log_buff, write_bytes);
|
||||||
if (write(pContext->log_fd, pContext->log_buff, write_bytes) != \
|
pContext->pcurrent_buff = pContext->log_buff;
|
||||||
write_bytes)
|
if (written != write_bytes)
|
||||||
{
|
{
|
||||||
result = errno != 0 ? errno : EIO;
|
result = errno != 0 ? errno : EIO;
|
||||||
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
||||||
|
|
@ -629,7 +630,6 @@ static int log_fsync(LogContext *pContext, const bool bNeedLock)
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
pContext->pcurrent_buff = pContext->log_buff;
|
|
||||||
if (bNeedLock && ((lock_res=pthread_mutex_unlock( \
|
if (bNeedLock && ((lock_res=pthread_mutex_unlock( \
|
||||||
&(pContext->log_thread_lock))) != 0))
|
&(pContext->log_thread_lock))) != 0))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue