diff --git a/HISTORY b/HISTORY index a748a21..4eacd2e 100644 --- a/HISTORY +++ b/HISTORY @@ -1,7 +1,8 @@ -Version 5.08 2015-12-08 +Version 5.08 2016-01-26 * install library to $(TARGET_PREFIX)/lib anyway * php extension compiled in PHP 7 + * dio thread use blocked_queue Version 5.07 2015-09-13 * schedule task add the "second" field diff --git a/fastdfs.spec b/fastdfs.spec index f0c6e1c..d27c747 100644 --- a/fastdfs.spec +++ b/fastdfs.spec @@ -2,7 +2,7 @@ %define FDFSServer fastdfs-server %define FDFSClient libfdfsclient %define FDFSTool fastdfs-tool -%define FDFSVersion 5.0.7 +%define FDFSVersion 5.0.8 Name: %{FastDFS} Version: %{FDFSVersion} @@ -16,13 +16,13 @@ Source: http://perso.orange.fr/sebastien.godard/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires: %__cp %__mv %__chmod %__grep %__mkdir %__install %__id -BuildRequires: libfastcommon-devel >= 1.0.21 +BuildRequires: libfastcommon-devel >= 1.0.24 %description This package provides tracker & storage of fastdfs %package -n %{FDFSServer} -Requires: libfastcommon >= 1.0.21 +Requires: libfastcommon >= 1.0.24 Summary: fastdfs tracker & storage %package -n %{FDFSTool} diff --git a/storage/storage_dio.c b/storage/storage_dio.c index 0d5c42e..2623720 100644 --- a/storage/storage_dio.c +++ b/storage/storage_dio.c @@ -100,26 +100,11 @@ int storage_dio_init() for (pContext=pThreadData->contexts; pContextqueue))) != 0) + if ((result=blocked_queue_init(&(pContext->queue))) != 0) { return result; } - if ((result=init_pthread_lock(&(pContext->lock))) != 0) - { - return result; - } - - result = pthread_cond_init(&(pContext->cond), NULL); - if (result != 0) - { - logError("file: "__FILE__", line: %d, " \ - "pthread_cond_init fail, " \ - "errno: %d, error info: %s", \ - __LINE__, result, STRERROR(result)); - return result; - } - if ((result=pthread_create(&tid, &thread_attr, \ dio_thread_entrance, pContext)) != 0) { @@ -153,7 +138,7 @@ void storage_dio_terminate() pContextEnd = g_dio_contexts + g_dio_thread_count; for (pContext=g_dio_contexts; pContextcond)); + blocked_queue_terminate(&(pContext->queue)); } } @@ -169,23 +154,12 @@ int storage_dio_queue_push(struct fast_task_info *pTask) pContext = g_dio_contexts + pFileContext->dio_thread_index; pClientInfo->stage |= FDFS_STORAGE_STAGE_DIO_THREAD; - if ((result=task_queue_push(&(pContext->queue), pTask)) != 0) + if ((result=blocked_queue_push(&(pContext->queue), pTask)) != 0) { add_to_deleted_list(pTask); return result; } - if ((result=pthread_cond_signal(&(pContext->cond))) != 0) - { - logError("file: "__FILE__", line: %d, " \ - "pthread_cond_signal fail, " \ - "errno: %d, error info: %s", \ - __LINE__, result, STRERROR(result)); - - add_to_deleted_list(pTask); - return result; - } - return 0; } @@ -757,25 +731,13 @@ static void *dio_thread_entrance(void* arg) struct fast_task_info *pTask; pContext = (struct storage_dio_context *)arg; - - pthread_mutex_lock(&(pContext->lock)); while (g_continue_flag) { - if ((result=pthread_cond_wait(&(pContext->cond), \ - &(pContext->lock))) != 0) - { - logError("file: "__FILE__", line: %d, " \ - "call pthread_cond_wait fail, " \ - "errno: %d, error info: %s", \ - __LINE__, result, STRERROR(result)); - } - - while ((pTask=task_queue_pop(&(pContext->queue))) != NULL) + while ((pTask=blocked_queue_pop(&(pContext->queue))) != NULL) { ((StorageClientInfo *)pTask->arg)->deal_func(pTask); } } - pthread_mutex_unlock(&(pContext->lock)); if ((result=pthread_mutex_lock(&g_dio_thread_lock)) != 0) { diff --git a/storage/storage_dio.h b/storage/storage_dio.h index 74135c7..f9eee05 100644 --- a/storage/storage_dio.h +++ b/storage/storage_dio.h @@ -17,12 +17,11 @@ #include #include "tracker_types.h" #include "fast_task_queue.h" +#include "fast_blocked_queue.h" struct storage_dio_context { - struct fast_task_queue queue; - pthread_mutex_t lock; - pthread_cond_t cond; + struct fast_blocked_queue queue; }; struct storage_dio_thread_data diff --git a/test/test_delete.sh b/test/test_delete.sh old mode 100644 new mode 100755 diff --git a/test/test_download.sh b/test/test_download.sh old mode 100644 new mode 100755 diff --git a/test/test_upload.sh b/test/test_upload.sh old mode 100644 new mode 100755