use newest ioevent_loop from libfastcommon

pull/48/head
yuqing 2014-08-10 12:22:43 +08:00
parent c3081550b1
commit be6e9f1141
6 changed files with 23 additions and 13 deletions

View File

@ -1,10 +1,11 @@
Version 5.03 2014-08-11 Version 5.03 2014-08-10
* network send and recv retry when error EINTR happen * network send and recv retry when error EINTR happen
* support mac OS Darwin * support mac OS Darwin
* use newest logger from libfastcommon * use newest logger from libfastcommon
* patches by liangry@ucweb.com * patches by liangry@ucweb.com
* bug fixed: can't sync large files cause by v5.02 * bug fixed: can't sync large files cause by v5.02
* use newest ioevent_loop from libfastcommon
Version 5.02 2014-07-20 Version 5.02 2014-07-20
* corect README spell mistake * corect README spell mistake

View File

@ -3,6 +3,7 @@
#include <errno.h> #include <errno.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <pthread.h> #include <pthread.h>
#include <inttypes.h>
#include "fast_task_queue.h" #include "fast_task_queue.h"
#include "logger.h" #include "logger.h"
#include "shared_func.h" #include "shared_func.h"

View File

@ -19,10 +19,12 @@
#include "ioevent.h" #include "ioevent.h"
#include "fast_timer.h" #include "fast_timer.h"
struct nio_thread_data;
struct fast_task_info; struct fast_task_info;
typedef int (*TaskFinishCallBack) (struct fast_task_info *pTask); typedef int (*ThreadLoopCallback) (struct nio_thread_data *pThreadData);
typedef void (*TaskCleanUpCallBack) (struct fast_task_info *pTask); typedef int (*TaskFinishCallback) (struct fast_task_info *pTask);
typedef void (*TaskCleanUpCallback) (struct fast_task_info *pTask);
typedef void (*IOEventCallback) (int sock, short event, void *arg); typedef void (*IOEventCallback) (int sock, short event, void *arg);
@ -37,8 +39,10 @@ struct nio_thread_data
{ {
struct ioevent_puller ev_puller; struct ioevent_puller ev_puller;
struct fast_timer timer; struct fast_timer timer;
int pipe_fds[2]; int pipe_fds[2];
struct fast_task_info *deleted_list; struct fast_task_info *deleted_list;
ThreadLoopCallback thread_loop_callback;
void *arg; //extra argument pointer
}; };
struct fast_task_info struct fast_task_info
@ -50,8 +54,8 @@ struct fast_task_info
int size; //alloc size int size; //alloc size
int length; //data length int length; //data length
int offset; //current offset int offset; //current offset
int req_count; //request count int64_t req_count; //request count
TaskFinishCallBack finish_callback; TaskFinishCallback finish_callback;
struct nio_thread_data *thread_data; struct nio_thread_data *thread_data;
struct fast_task_info *next; struct fast_task_info *next;
}; };

View File

@ -38,7 +38,7 @@ static void deal_timeouts(FastTimerEntry *head)
} }
int ioevent_loop(struct nio_thread_data *pThreadData, int ioevent_loop(struct nio_thread_data *pThreadData,
IOEventCallback recv_notify_callback, TaskCleanUpCallBack IOEventCallback recv_notify_callback, TaskCleanUpCallback
clean_up_callback, volatile bool *continue_flag) clean_up_callback, volatile bool *continue_flag)
{ {
int result; int result;
@ -109,6 +109,10 @@ int ioevent_loop(struct nio_thread_data *pThreadData,
deal_timeouts(&head); deal_timeouts(&head);
} }
} }
if (pThreadData->thread_loop_callback != NULL) {
pThreadData->thread_loop_callback(pThreadData);
}
} }
return 0; return 0;

View File

@ -8,7 +8,7 @@ extern "C" {
#endif #endif
int ioevent_loop(struct nio_thread_data *pThreadData, int ioevent_loop(struct nio_thread_data *pThreadData,
IOEventCallback recv_notify_callback, TaskCleanUpCallBack IOEventCallback recv_notify_callback, TaskCleanUpCallback
clean_up_callback, volatile bool *continue_flag); clean_up_callback, volatile bool *continue_flag);
int ioevent_set(struct fast_task_info *pTask, struct nio_thread_data *pThread, int ioevent_set(struct fast_task_info *pTask, struct nio_thread_data *pThread,

View File

@ -54,6 +54,7 @@ static void tracker_find_max_free_space_group();
int tracker_service_init() int tracker_service_init()
{ {
int result; int result;
int bytes;
struct nio_thread_data *pThreadData; struct nio_thread_data *pThreadData;
struct nio_thread_data *pDataEnd; struct nio_thread_data *pDataEnd;
pthread_t tid; pthread_t tid;
@ -81,17 +82,16 @@ int tracker_service_init()
{ {
return result; return result;
} }
bytes = sizeof(struct nio_thread_data) * g_work_threads;
g_thread_data = (struct nio_thread_data *)malloc(sizeof( \ g_thread_data = (struct nio_thread_data *)malloc(bytes );
struct nio_thread_data) * g_work_threads);
if (g_thread_data == NULL) if (g_thread_data == NULL)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, " \
"malloc %d bytes fail, errno: %d, error info: %s", \ "malloc %d bytes fail, errno: %d, error info: %s", \
__LINE__, (int)sizeof(struct nio_thread_data) * \ __LINE__, bytes, errno, STRERROR(errno));
g_work_threads, errno, STRERROR(errno));
return errno != 0 ? errno : ENOMEM; return errno != 0 ? errno : ENOMEM;
} }
memset(g_thread_data, 0, bytes);
g_tracker_thread_count = 0; g_tracker_thread_count = 0;
pDataEnd = g_thread_data + g_work_threads; pDataEnd = g_thread_data + g_work_threads;