Browse Source

Fixed unexpected POLLHUP event on connection failure on MacOS

Paul-Louis Ageneau 1 year ago
parent
commit
e842ee202e
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/impl/pollservice.cpp

+ 3 - 1
src/impl/pollservice.cpp

@@ -118,7 +118,9 @@ void PollService::process(std::vector<struct pollfd> &pfds) {
 				auto &entry = jt->second;
 				const auto &params = entry.params;
 
-				if (it->revents & POLLNVAL || it->revents & POLLERR) {
+				if (it->revents & POLLNVAL || it->revents & POLLERR ||
+				    (it->revents & POLLHUP &&
+				     !(it->events & POLLIN))) { // MacOS sets POLLHUP on connection failure
 					PLOG_VERBOSE << "Poll error event";
 					auto callback = std::move(params.callback);
 					mSocks->erase(sock);