use newest ioevent_loop from libfastcommon
parent
c3081550b1
commit
be6e9f1141
3
HISTORY
3
HISTORY
|
|
@ -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
|
||||
* support mac OS Darwin
|
||||
* use newest logger from libfastcommon
|
||||
* patches by liangry@ucweb.com
|
||||
* bug fixed: can't sync large files cause by v5.02
|
||||
* use newest ioevent_loop from libfastcommon
|
||||
|
||||
Version 5.02 2014-07-20
|
||||
* corect README spell mistake
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <errno.h>
|
||||
#include <sys/resource.h>
|
||||
#include <pthread.h>
|
||||
#include <inttypes.h>
|
||||
#include "fast_task_queue.h"
|
||||
#include "logger.h"
|
||||
#include "shared_func.h"
|
||||
|
|
|
|||
|
|
@ -19,10 +19,12 @@
|
|||
#include "ioevent.h"
|
||||
#include "fast_timer.h"
|
||||
|
||||
struct nio_thread_data;
|
||||
struct fast_task_info;
|
||||
|
||||
typedef int (*TaskFinishCallBack) (struct fast_task_info *pTask);
|
||||
typedef void (*TaskCleanUpCallBack) (struct fast_task_info *pTask);
|
||||
typedef int (*ThreadLoopCallback) (struct nio_thread_data *pThreadData);
|
||||
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);
|
||||
|
||||
|
|
@ -39,6 +41,8 @@ struct nio_thread_data
|
|||
struct fast_timer timer;
|
||||
int pipe_fds[2];
|
||||
struct fast_task_info *deleted_list;
|
||||
ThreadLoopCallback thread_loop_callback;
|
||||
void *arg; //extra argument pointer
|
||||
};
|
||||
|
||||
struct fast_task_info
|
||||
|
|
@ -50,8 +54,8 @@ struct fast_task_info
|
|||
int size; //alloc size
|
||||
int length; //data length
|
||||
int offset; //current offset
|
||||
int req_count; //request count
|
||||
TaskFinishCallBack finish_callback;
|
||||
int64_t req_count; //request count
|
||||
TaskFinishCallback finish_callback;
|
||||
struct nio_thread_data *thread_data;
|
||||
struct fast_task_info *next;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ static void deal_timeouts(FastTimerEntry *head)
|
|||
}
|
||||
|
||||
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)
|
||||
{
|
||||
int result;
|
||||
|
|
@ -109,6 +109,10 @@ int ioevent_loop(struct nio_thread_data *pThreadData,
|
|||
deal_timeouts(&head);
|
||||
}
|
||||
}
|
||||
|
||||
if (pThreadData->thread_loop_callback != NULL) {
|
||||
pThreadData->thread_loop_callback(pThreadData);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
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);
|
||||
|
||||
int ioevent_set(struct fast_task_info *pTask, struct nio_thread_data *pThread,
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ static void tracker_find_max_free_space_group();
|
|||
int tracker_service_init()
|
||||
{
|
||||
int result;
|
||||
int bytes;
|
||||
struct nio_thread_data *pThreadData;
|
||||
struct nio_thread_data *pDataEnd;
|
||||
pthread_t tid;
|
||||
|
|
@ -81,17 +82,16 @@ int tracker_service_init()
|
|||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
g_thread_data = (struct nio_thread_data *)malloc(sizeof( \
|
||||
struct nio_thread_data) * g_work_threads);
|
||||
bytes = sizeof(struct nio_thread_data) * g_work_threads;
|
||||
g_thread_data = (struct nio_thread_data *)malloc(bytes );
|
||||
if (g_thread_data == NULL)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"malloc %d bytes fail, errno: %d, error info: %s", \
|
||||
__LINE__, (int)sizeof(struct nio_thread_data) * \
|
||||
g_work_threads, errno, STRERROR(errno));
|
||||
__LINE__, bytes, errno, STRERROR(errno));
|
||||
return errno != 0 ? errno : ENOMEM;
|
||||
}
|
||||
memset(g_thread_data, 0, bytes);
|
||||
|
||||
g_tracker_thread_count = 0;
|
||||
pDataEnd = g_thread_data + g_work_threads;
|
||||
|
|
|
|||
Loading…
Reference in New Issue