서버 버그 픽스스

This commit is contained in:
2025-05-09 17:19:53 +09:00
parent 87cc1c7119
commit 914cfcba32
3 changed files with 29 additions and 6 deletions

View File

@@ -80,8 +80,28 @@ public:
IOCPPASSINDATA* rootIocpData = (IOCPPASSINDATA*)event.data.ptr;
std::lock_guard<std::mutex> lock(rootIocpData->socket->readMutex);
char peekBuffer[1];
while (rootIocpData->socket->recv(peekBuffer, 1, MSG_PEEK)) {
while (true) {
char peekBuffer[1];
int rc = rootIocpData->socket->recv(peekBuffer, 1, MSG_PEEK);
if (rc > 0);
else if (rc == 0) {
spdlog::debug("Client disconnected. [{}]", (std::string)(rootIocpData->socket->remoteAddr));
::epoll_ctl(epollfd, EPOLL_CTL_DEL, rootIocpData->socket->sock, NULL);
delete rootIocpData;
return;
}
else {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
spdlog::trace("No data to read on {}", tid);
return;
}
else {
spdlog::error("recv() [{}]", strerror(errno));
::epoll_ctl(epollfd, EPOLL_CTL_DEL, rootIocpData->socket->sock, NULL);
delete rootIocpData;
return;
}
}
Chattr::IOCPPASSINDATA* ptr = new Chattr::IOCPPASSINDATA;
::memcpy(ptr, rootIocpData, sizeof(IOCPPASSINDATA));
::memset(&ptr->overlapped, 0, sizeof(OVERLAPPED));
@@ -180,7 +200,7 @@ public:
pthread_t tid = pthread_self();
spdlog::trace("epoll waiting on {}", tid);
int nready = ::epoll_wait(epollfd, events, FD_SETSIZE, -1);
int nready = ::epoll_wait(epollfd, events, FD_SETSIZE, 1000);
for (int i=0; i<nready; i++) {
struct epoll_event current_event = events[i];