提交 0fd3425f 编写于 作者: Y yuqing

bug fixed: log header correctly when rotate

上级 8b9bdfd3
......@@ -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
......
......@@ -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))
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册