X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=input.cpp;h=a54e6fb2d398341302f8bbf13bcaa5f5f8239d4d;hp=47c3c0193472d8cfa56747fd2461cdf5595632cd;hb=684496ba9c7def1421d045435b6b92e80bc54c74;hpb=9b565a9e6e66f076abb7266b2c2f015f585fa9cb diff --git a/input.cpp b/input.cpp index 47c3c01..a54e6fb 100644 --- a/input.cpp +++ b/input.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -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(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) {