set IOEVENT_READ | IOEVENT_WRITE events for connect status check
parent
17d3af8fd5
commit
02b345deb9
|
|
@ -42,6 +42,9 @@
|
|||
((code >= SF_RETRIABLE_ERROR_MIN && code <= SF_RETRIABLE_ERROR_MAX) || \
|
||||
(code == EAGAIN) || is_network_error(code))
|
||||
|
||||
#define SF_UNIX_ERRNO(code, errno_for_overflow) \
|
||||
(code < 256 ? code : errno_for_overflow)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -216,8 +216,10 @@ static int sf_connect_server(struct fast_task_info *task)
|
|||
sf_nio_set_stage(task, SF_NIO_STAGE_HANDSHAKE);
|
||||
return SF_CTX->deal_task(task);
|
||||
} else if (result == EINPROGRESS) {
|
||||
return sf_ioevent_add(task, (IOEventCallback)
|
||||
result = ioevent_set(task, task->thread_data, task->event.fd,
|
||||
IOEVENT_READ | IOEVENT_WRITE, (IOEventCallback)
|
||||
sf_client_sock_connect, task->connect_timeout);
|
||||
return result > 0 ? -1 * result : result;
|
||||
} else {
|
||||
close(task->event.fd);
|
||||
task->event.fd = -1;
|
||||
|
|
|
|||
|
|
@ -252,9 +252,17 @@ int sf_service_destroy_ex(SFContext *sf_context)
|
|||
static void *worker_thread_entrance(void *arg)
|
||||
{
|
||||
struct worker_thread_context *thread_ctx;
|
||||
int thread_count;
|
||||
|
||||
thread_ctx = (struct worker_thread_context *)arg;
|
||||
__sync_fetch_and_add(&thread_ctx->sf_context->thread_count, 1);
|
||||
thread_count = __sync_add_and_fetch(&thread_ctx->
|
||||
sf_context->thread_count, 1);
|
||||
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"worker thread enter, current thread index: %d, "
|
||||
"current thread count: %d", __LINE__,
|
||||
(int)(thread_ctx->thread_data - thread_ctx->
|
||||
sf_context->thread_data), thread_count);
|
||||
|
||||
ioevent_loop(thread_ctx->thread_data,
|
||||
sf_recv_notify_read,
|
||||
|
|
@ -262,7 +270,14 @@ static void *worker_thread_entrance(void *arg)
|
|||
&g_sf_global_vars.continue_flag);
|
||||
ioevent_destroy(&thread_ctx->thread_data->ev_puller);
|
||||
|
||||
__sync_fetch_and_sub(&thread_ctx->sf_context->thread_count, 1);
|
||||
thread_count = __sync_sub_and_fetch(&thread_ctx->
|
||||
sf_context->thread_count, 1);
|
||||
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"worker thread exit, current thread index: %d, "
|
||||
"current thread count: %d", __LINE__,
|
||||
(int)(thread_ctx->thread_data - thread_ctx->
|
||||
sf_context->thread_data), thread_count);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue