- int server_sock = int(intptr_t(arg));
- while (!hupped) {
- // Since we are non-blocking, we need to wait for the right state first.
- // Wait up to 50 ms, then check hupped.
- pollfd pfd;
- pfd.fd = server_sock;
- pfd.events = POLLIN;
-
- int nfds = poll(&pfd, 1, 50);
- if (nfds == 0 || (nfds == -1 && errno == EINTR)) {
- continue;
- }
- if (nfds == -1) {
- perror("poll");
- usleep(100000);
+}
+
+AcceptorProto Acceptor::serialize() const
+{
+ AcceptorProto serialized;
+ serialized.set_server_sock(server_sock);
+ serialized.set_port(port);
+ return serialized;
+}
+
+void Acceptor::close_socket()
+{
+ safe_close(server_sock);
+}
+
+void Acceptor::do_work()
+{
+ while (!should_stop()) {
+ if (!wait_for_activity(server_sock, POLLIN, NULL)) {