diff --git a/HISTORY b/HISTORY index e8a0df18ddd8f26ec11dc445a70fcef6384ff872..585348b8434a349f774cd08a40feef5fe620942f 100644 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,5 @@ -Version 1.44 2020-10-21 +Version 1.44 2020-10-28 * add test file src/tests/test_pthread_lock.c * add uniq_skiplist.[hc] * add function split_string_ex diff --git a/src/fast_task_queue.h b/src/fast_task_queue.h index 37a02f1651c711de2125961cf16429cb09f794b0..5e2d4c34ba76ff03b54cf8fd9dd14e87b55bf88c 100644 --- a/src/fast_task_queue.h +++ b/src/fast_task_queue.h @@ -87,7 +87,9 @@ struct fast_task_info uint8_t current; volatile uint8_t notify; } nio_stages; //stages for network IO - bool canceled; //if task canceled + int (*continue_callback)(struct fast_task_info *task); //for continue stage + volatile int8_t reffer_count; + volatile int8_t canceled; //if task canceled int connect_timeout; //for client side int network_timeout; int64_t req_count; //request count diff --git a/src/ioevent_loop.h b/src/ioevent_loop.h index 40a5946523e4815f675d234b65dc20a0414047c3..8a419706fa5c9de11c50815d1d426928b038485e 100644 --- a/src/ioevent_loop.h +++ b/src/ioevent_loop.h @@ -32,20 +32,16 @@ int ioevent_remove(IOEventPoller *ioevent, void *data); int ioevent_set(struct fast_task_info *pTask, struct nio_thread_data *pThread, int sock, short event, IOEventCallback callback, const int timeout); +//only called by the nio thread static inline void ioevent_add_to_deleted_list(struct fast_task_info *task) { - if (task->thread_data == NULL) + if (!__sync_bool_compare_and_swap(&task->canceled, 0, 1)) { - return; - } - - if (task->canceled) { - logError("file: "__FILE__", line: %d, " + logWarning("file: "__FILE__", line: %d, " "task %p already canceled", __LINE__, task); return; } - task->canceled = true; task->next = task->thread_data->deleted_list; task->thread_data->deleted_list = task; }