]> git.sesse.net Git - cubemap/blobdiff - input.cpp
Support multiple listening sockets. Actually mostly because it makes the code somewha...
[cubemap] / input.cpp
index 47c3c0193472d8cfa56747fd2461cdf5595632cd..a54e6fb2d398341302f8bbf13bcaa5f5f8239d4d 100644 (file)
--- a/input.cpp
+++ b/input.cpp
@@ -11,6 +11,7 @@
 #include <sys/socket.h>
 #include <netdb.h>
 #include <poll.h>
+#include <signal.h>
 #include <errno.h>
 #include <vector>
 #include <string>
@@ -113,34 +114,6 @@ InputProto Input::serialize() const
        return serialized;
 }
 
-void Input::run()
-{
-       should_stop = false;
-       
-       // Joinable is already the default, but it's good to be certain.
-       pthread_attr_t attr;
-       pthread_attr_init(&attr);
-       pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-       pthread_create(&worker_thread, &attr, Input::do_work_thunk, this);
-}
-
-void Input::stop()
-{
-       should_stop = true;
-
-       if (pthread_join(worker_thread, NULL) == -1) {
-               perror("pthread_join");
-               exit(1);
-       }
-}
-
-void *Input::do_work_thunk(void *arg)
-{
-       Input *input = static_cast<Input *>(arg);
-       input->do_work();
-       return NULL;
-}
-
 int Input::lookup_and_connect(const string &host, const string &port)
 {
        addrinfo *ai;
@@ -269,7 +242,7 @@ void Input::do_work()
                        pfd.events |= POLLRDHUP;
 
                        int nfds = poll(&pfd, 1, 50);
-                       if (nfds == 0 || (nfds == -1 && errno == EAGAIN)) {
+                       if (nfds == 0 || (nfds == -1 && errno == EINTR)) {
                                continue;
                        }
                        if (nfds == -1) {