提交 69f9c326 编写于 作者: C chengtbf

fix bug when ioworker stop


Former-commit-id: a67b4cc52d0b424e142a0a9b958eee56da89b040
上级 7f9b1038
...@@ -108,13 +108,15 @@ void IOWorker::Start() { ...@@ -108,13 +108,15 @@ void IOWorker::Start() {
} }
void IOWorker::Stop() { void IOWorker::Stop() {
IOData* stop_io_data = new IOData; for (size_t i = 0; i < num_of_concurrent_threads_; ++i) {
stop_io_data->IO_type = IOType::kStop; IOData* stop_io_data = new IOData;
memset(&(stop_io_data->overlapped), 0, sizeof(OVERLAPPED)); stop_io_data->IO_type = IOType::kStop;
ResetIODataBuff(stop_io_data); memset(&(stop_io_data->overlapped), 0, sizeof(OVERLAPPED));
PostQueuedCompletionStatus(completion_port_, 0, ResetIODataBuff(stop_io_data);
machine_id2socket_[this_machine_id_], PostQueuedCompletionStatus(completion_port_, 0, i,
reinterpret_cast<LPOVERLAPPED>(stop_io_data)); reinterpret_cast<LPOVERLAPPED>(stop_io_data));
LOG(INFO) << "Post stop request " << i << " to IOCP\n";
}
} }
void IOWorker::InitSockets() { void IOWorker::InitSockets() {
...@@ -124,7 +126,6 @@ void IOWorker::InitSockets() { ...@@ -124,7 +126,6 @@ void IOWorker::InitSockets() {
SOCKET listen_socket = socket(AF_INET, SOCK_STREAM, 0); SOCKET listen_socket = socket(AF_INET, SOCK_STREAM, 0);
PCHECK(listen_socket != INVALID_SOCKET) PCHECK(listen_socket != INVALID_SOCKET)
<< "socket failed with error:" << WSAGetLastError() << "\n"; << "socket failed with error:" << WSAGetLastError() << "\n";
machine_id2socket_[this_machine_id_] = listen_socket;
uint16_t this_listen_port = 1024; uint16_t this_listen_port = 1024;
uint16_t listen_port_max = std::numeric_limits<uint16_t>::max(); uint16_t listen_port_max = std::numeric_limits<uint16_t>::max();
for (; this_listen_port < listen_port_max; ++this_listen_port) { for (; this_listen_port < listen_port_max; ++this_listen_port) {
...@@ -204,6 +205,7 @@ DWORD IOWorker::ThreadProc() { ...@@ -204,6 +205,7 @@ DWORD IOWorker::ThreadProc() {
switch (io_data_ptr->IO_type) { switch (io_data_ptr->IO_type) {
case IOType::kStop: { case IOType::kStop: {
delete io_data_ptr; delete io_data_ptr;
LOG(INFO) << "stop IOworker " << completion_key << " \n";
return 0; return 0;
} }
case IOType::kRecvMsgHead: { case IOType::kRecvMsgHead: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册