Skip to content

Commit 1601c8b

Browse files
committed
Just flip some codes.
1 parent e32170e commit 1601c8b

1 file changed

Lines changed: 66 additions & 66 deletions

File tree

src/kernel/Communicator.cc

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -924,69 +924,6 @@ struct CommConnEntry *Communicator::accept_conn(CommServiceTarget *target,
924924
return NULL;
925925
}
926926

927-
void Communicator::handle_listen_result(struct poller_result *res)
928-
{
929-
CommService *service = (CommService *)res->data.context;
930-
struct CommConnEntry *entry;
931-
CommServiceTarget *target;
932-
int timeout;
933-
934-
switch (res->state)
935-
{
936-
case PR_ST_SUCCESS:
937-
target = (CommServiceTarget *)res->data.result;
938-
entry = this->accept_conn(target, service);
939-
if (entry)
940-
{
941-
if (service->ssl_ctx)
942-
{
943-
if (__create_ssl(service->ssl_ctx, entry) >= 0 &&
944-
service->init_ssl(entry->ssl) >= 0)
945-
{
946-
res->data.operation = PD_OP_SSL_ACCEPT;
947-
timeout = service->ssl_accept_timeout;
948-
}
949-
}
950-
else
951-
{
952-
res->data.operation = PD_OP_READ;
953-
res->data.create_message = Communicator::create_request;
954-
res->data.message = NULL;
955-
timeout = target->response_timeout;
956-
}
957-
958-
if (res->data.operation != PD_OP_LISTEN)
959-
{
960-
res->data.fd = entry->sockfd;
961-
res->data.ssl = entry->ssl;
962-
res->data.context = entry;
963-
if (mpoller_add(&res->data, timeout, this->mpoller) >= 0)
964-
{
965-
if (this->stop_flag)
966-
mpoller_del(res->data.fd, this->mpoller);
967-
break;
968-
}
969-
}
970-
971-
this->release_conn(entry);
972-
}
973-
else
974-
close(target->sockfd);
975-
976-
target->decref();
977-
break;
978-
979-
case PR_ST_DELETED:
980-
this->shutdown_service(service);
981-
break;
982-
983-
case PR_ST_ERROR:
984-
case PR_ST_STOPPED:
985-
service->handle_stop(res->error);
986-
break;
987-
}
988-
}
989-
990927
void Communicator::handle_connect_result(struct poller_result *res)
991928
{
992929
struct CommConnEntry *entry = (struct CommConnEntry *)res->data.context;
@@ -1061,6 +998,69 @@ void Communicator::handle_connect_result(struct poller_result *res)
1061998
}
1062999
}
10631000

1001+
void Communicator::handle_listen_result(struct poller_result *res)
1002+
{
1003+
CommService *service = (CommService *)res->data.context;
1004+
struct CommConnEntry *entry;
1005+
CommServiceTarget *target;
1006+
int timeout;
1007+
1008+
switch (res->state)
1009+
{
1010+
case PR_ST_SUCCESS:
1011+
target = (CommServiceTarget *)res->data.result;
1012+
entry = this->accept_conn(target, service);
1013+
if (entry)
1014+
{
1015+
if (service->ssl_ctx)
1016+
{
1017+
if (__create_ssl(service->ssl_ctx, entry) >= 0 &&
1018+
service->init_ssl(entry->ssl) >= 0)
1019+
{
1020+
res->data.operation = PD_OP_SSL_ACCEPT;
1021+
timeout = service->ssl_accept_timeout;
1022+
}
1023+
}
1024+
else
1025+
{
1026+
res->data.operation = PD_OP_READ;
1027+
res->data.create_message = Communicator::create_request;
1028+
res->data.message = NULL;
1029+
timeout = target->response_timeout;
1030+
}
1031+
1032+
if (res->data.operation != PD_OP_LISTEN)
1033+
{
1034+
res->data.fd = entry->sockfd;
1035+
res->data.ssl = entry->ssl;
1036+
res->data.context = entry;
1037+
if (mpoller_add(&res->data, timeout, this->mpoller) >= 0)
1038+
{
1039+
if (this->stop_flag)
1040+
mpoller_del(res->data.fd, this->mpoller);
1041+
break;
1042+
}
1043+
}
1044+
1045+
this->release_conn(entry);
1046+
}
1047+
else
1048+
close(target->sockfd);
1049+
1050+
target->decref();
1051+
break;
1052+
1053+
case PR_ST_DELETED:
1054+
this->shutdown_service(service);
1055+
break;
1056+
1057+
case PR_ST_ERROR:
1058+
case PR_ST_STOPPED:
1059+
service->handle_stop(res->error);
1060+
break;
1061+
}
1062+
}
1063+
10641064
void Communicator::handle_ssl_accept_result(struct poller_result *res)
10651065
{
10661066
struct CommConnEntry *entry = (struct CommConnEntry *)res->data.context;
@@ -1155,6 +1155,9 @@ void Communicator::handler_thread_routine(void *context)
11551155

11561156
switch (res->data.operation)
11571157
{
1158+
case PD_OP_TIMER:
1159+
comm->handle_sleep_result(res);
1160+
break;
11581161
case PD_OP_READ:
11591162
comm->handle_read_result(res);
11601163
break;
@@ -1175,9 +1178,6 @@ void Communicator::handler_thread_routine(void *context)
11751178
case PD_OP_NOTIFY:
11761179
comm->handle_aio_result(res);
11771180
break;
1178-
case PD_OP_TIMER:
1179-
comm->handle_sleep_result(res);
1180-
break;
11811181
}
11821182

11831183
free(res);

0 commit comments

Comments
 (0)