| 124 | |
| 125 | |
| 126 | void TCPServer::run() |
| 127 | { |
| 128 | while (!_stopped) |
| 129 | { |
| 130 | Poco::Timespan timeout(250000); |
| 131 | try |
| 132 | { |
| 133 | if (_socket.poll(timeout, Socket::SELECT_READ)) |
| 134 | { |
| 135 | try |
| 136 | { |
| 137 | StreamSocket ss = _socket.acceptConnection(); |
| 138 | |
| 139 | if (!_pConnectionFilter || _pConnectionFilter->accept(ss)) |
| 140 | { |
| 141 | // enable nodelay per default: OSX really needs that |
| 142 | #if defined(POCO_OS_FAMILY_UNIX) |
| 143 | if (ss.address().family() != AddressFamily::UNIX_LOCAL) |
| 144 | #endif |
| 145 | { |
| 146 | ss.setNoDelay(_pDispatcher->params().getNoDelay()); |
| 147 | } |
| 148 | _pDispatcher->enqueue(ss); |
| 149 | } |
| 150 | else |
| 151 | { |
| 152 | ErrorHandler::logMessage(Message::PRIO_WARNING, "Filtered out connection from " + ss.peerAddress().toString()); |
| 153 | } |
| 154 | } |
| 155 | // Termination request |
| 156 | catch (Poco::InvalidArgumentException& exc) |
| 157 | { |
| 158 | ErrorHandler::logMessage(Message::PRIO_INFORMATION, "Shutting down TCPServer: " + exc.displayText()); |
| 159 | } |
| 160 | catch (Poco::Exception& exc) |
| 161 | { |
| 162 | ErrorHandler::handle(exc); |
| 163 | } |
| 164 | catch (std::exception& exc) |
| 165 | { |
| 166 | ErrorHandler::handle(exc); |
| 167 | } |
| 168 | catch (...) |
| 169 | { |
| 170 | ErrorHandler::handle(); |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | catch (Poco::Exception& exc) |
| 175 | { |
| 176 | ErrorHandler::handle(exc); |
| 177 | // possibly a resource issue since poll() failed; |
| 178 | // give some time to recover before trying again |
| 179 | Poco::Thread::sleep(50); |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 |
nothing calls this directly
no test coverage detected