Browse Source

Merge pull request #871 from paullouisageneau/fix-wsapoll-socket-close

Fix WebSocket TCP stuck in CLOSE_WAIT state on Windows
Paul-Louis Ageneau 2 years ago
parent
commit
e13fa98875
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/impl/pollservice.cpp

+ 3 - 2
src/impl/pollservice.cpp

@@ -124,13 +124,14 @@ void PollService::process(std::vector<struct pollfd> &pfds) {
 					mSocks->erase(sock);
 					callback(Event::Error);
 
-				} else if (it->revents & POLLIN || it->revents & POLLOUT) {
+				} else if (it->revents & POLLIN || it->revents & POLLOUT || it->revents & POLLHUP) {
 					entry.until = params.timeout
 					                  ? std::make_optional(clock::now() + *params.timeout)
 					                  : nullopt;
 
 					auto callback = params.callback;
-					if (it->revents & POLLIN) {
+					if (it->revents & POLLIN ||
+					    it->revents & POLLHUP) { // Windows does not set POLLIN on close
 						PLOG_VERBOSE << "Poll in event";
 						callback(Event::In);
 					}