diff --git a/HISTORY b/HISTORY index 0564155..fac8eba 100644 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,5 @@ -Version 1.06 2014-06-27 +Version 1.06 2014-07-02 * update source code from FastDFS V5.02 * add function short2buff and buff2short * add object memory pool (fast_mblock.h and fast_mblock.c) @@ -14,6 +14,7 @@ Version 1.06 2014-06-27 * add libfastcommon.spec for building RPM * logger can delete old rotated files * bug fixed: connection pool should NOT increase counter when connect fail + * logger.c do NOT call fsync after write Version 1.05 2012-07-08 * update source code from FastDFS V3.09 diff --git a/src/fast_mblock.c b/src/fast_mblock.c index b1e33dc..c38035a 100644 --- a/src/fast_mblock.c +++ b/src/fast_mblock.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "fast_mblock.h" #include "logger.h" #include "shared_func.h" @@ -21,7 +22,7 @@ int fast_mblock_init(struct fast_mblock_man *mblock, const int element_size, \ return EINVAL; } - mblock->element_size = element_size; + mblock->element_size = MEM_ALIGN(element_size); if (alloc_elements_once > 0) { mblock->alloc_elements_once = alloc_elements_once; @@ -30,7 +31,7 @@ int fast_mblock_init(struct fast_mblock_man *mblock, const int element_size, \ { int block_size; block_size = MEM_ALIGN(sizeof(struct fast_mblock_node) \ - + element_size); + + mblock->element_size); mblock->alloc_elements_once = (1024 * 1024) / block_size; } @@ -85,7 +86,6 @@ static int fast_mblock_prealloc(struct fast_mblock_man *mblock) pNode = (struct fast_mblock_node *)p; pNode->next = (struct fast_mblock_node *)(p + block_size); } - ((struct fast_mblock_node *)pLast)->next = NULL; mblock->free_chain_head = (struct fast_mblock_node *)pTrunkStart; @@ -116,6 +116,7 @@ void fast_mblock_destroy(struct fast_mblock_man *mblock) } mblock->malloc_chain_head = NULL; mblock->free_chain_head = NULL; + mblock->total_count = 0; pthread_mutex_destroy(&(mblock->lock)); } diff --git a/src/logger.c b/src/logger.c index 33f708d..9b4a963 100644 --- a/src/logger.c +++ b/src/logger.c @@ -391,6 +391,7 @@ static int log_fsync(LogContext *pContext, const bool bNeedLock) break; } + /* if (pContext->log_fd != STDERR_FILENO) { if (fsync(pContext->log_fd) != 0) @@ -402,6 +403,7 @@ static int log_fsync(LogContext *pContext, const bool bNeedLock) break; } } + */ if (pContext->rotate_immediately) {