]> git.sesse.net Git - cubemap/blobdiff - udpinput.cpp
Make things line up a bit better.
[cubemap] / udpinput.cpp
index 6537035bb842e4e8cc3fe09ac30d9c187e4c6c7d..3a8beffeabcc8fcfd4aff48e2694f5aaa79603dd 100644 (file)
@@ -1,17 +1,18 @@
+#include <assert.h>
+#include <errno.h>
+#include <poll.h>
 #include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
+#include <stdlib.h>
 #include <sys/socket.h>
-#include <sys/poll.h>
-#include <arpa/inet.h>
-#include <errno.h>
+#include <unistd.h>
 #include <string>
 
 #include "acceptor.h"
-#include "udpinput.h"
+#include "log.h"
 #include "serverpool.h"
-#include "version.h"
 #include "state.pb.h"
+#include "udpinput.h"
+#include "version.h"
 
 using namespace std;
 
@@ -60,7 +61,7 @@ void UDPInput::close_socket()
        } while (ret == -1 && errno == EINTR);
 
        if (ret == -1) {
-               perror("close()");
+               log_perror("close()");
        }
 
        sock = -1;
@@ -84,7 +85,7 @@ void UDPInput::do_work()
                        int port_num = atoi(port.c_str());
                        sock = create_server_socket(port_num, UDP_SOCKET);
                        if (sock == -1) {
-                               fprintf(stderr, "WARNING: UDP socket creation failed. Waiting 0.2 seconds and trying again...\n");
+                               log(WARNING, "UDP socket creation failed. Waiting 0.2 seconds and trying again...");
                                usleep(200000);
                                continue;
                        }
@@ -101,7 +102,7 @@ void UDPInput::do_work()
                        continue;
                }
                if (nfds == -1) {
-                       perror("poll");
+                       log_perror("poll");
                        close_socket();
                        continue;       
                }
@@ -113,7 +114,7 @@ void UDPInput::do_work()
                } while (ret == -1 && errno == EINTR);
 
                if (ret <= 0) {
-                       perror("recv");
+                       log_perror("recv");
                        close_socket();
                        continue;
                }