add SF_NIO_STAGE_HANDSHAKE after connect
parent
aaeb421e6d
commit
9bee7ad62b
|
|
@ -11,11 +11,12 @@
|
|||
#define SF_DEF_MAX_BUFF_SIZE (64 * 1024)
|
||||
|
||||
#define SF_NIO_STAGE_INIT 0 //set ioevent
|
||||
#define SF_NIO_STAGE_CONNECT 1 //do connect
|
||||
#define SF_NIO_STAGE_RECV 2 //do recv
|
||||
#define SF_NIO_STAGE_SEND 3 //do send
|
||||
#define SF_NIO_STAGE_FORWARDED 4 //deal the forwarded request
|
||||
#define SF_NIO_STAGE_CONTINUE 5 //notify the thread continue deal
|
||||
#define SF_NIO_STAGE_CONNECT 1 //do connect (client only)
|
||||
#define SF_NIO_STAGE_HANDSHAKE 2 //notify the thread to handshake (client only)
|
||||
#define SF_NIO_STAGE_RECV 3 //do recv
|
||||
#define SF_NIO_STAGE_SEND 4 //do send
|
||||
#define SF_NIO_STAGE_FORWARDED 5 //deal the forwarded request
|
||||
#define SF_NIO_STAGE_CONTINUE 6 //notify the thread continue deal
|
||||
#define SF_NIO_STAGE_CLOSE 9 //cleanup the task
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
16
src/sf_nio.c
16
src/sf_nio.c
|
|
@ -184,9 +184,8 @@ static int sf_client_sock_connect(int sock, short event, void *arg)
|
|||
return -1;
|
||||
}
|
||||
|
||||
task->nio_stage = SF_NIO_STAGE_RECV;
|
||||
task->event.callback = (IOEventCallback)sf_client_sock_read;
|
||||
return 0;
|
||||
task->nio_stage = SF_NIO_STAGE_HANDSHAKE;
|
||||
return SF_CTX->deal_task(task);
|
||||
}
|
||||
|
||||
static int sf_connect_server(struct fast_task_info *task)
|
||||
|
|
@ -202,9 +201,14 @@ static int sf_connect_server(struct fast_task_info *task)
|
|||
result = asyncconnectserverbyip(task->event.fd,
|
||||
task->server_ip, task->port);
|
||||
if (result == 0) {
|
||||
task->nio_stage = SF_NIO_STAGE_RECV;
|
||||
return sf_ioevent_add(task, (IOEventCallback)
|
||||
sf_client_sock_read, task->network_timeout);
|
||||
if ((result=sf_ioevent_add(task, (IOEventCallback)
|
||||
sf_client_sock_read, task->network_timeout)) != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
task->nio_stage = SF_NIO_STAGE_HANDSHAKE;
|
||||
return SF_CTX->deal_task(task);
|
||||
} else if (result == EINPROGRESS) {
|
||||
return sf_ioevent_add(task, (IOEventCallback)
|
||||
sf_client_sock_connect, task->connect_timeout);
|
||||
|
|
|
|||
Loading…
Reference in New Issue