X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=udpinput.cpp;h=ed53edeea073604d93de240ffea6b5c7d04d323d;hp=cd66f16debff02b6edf6426c136b84a46a1bf7d6;hb=e283929bce32fec5c08fc4344a9700f4406d2cc5;hpb=ca9624c43b968a0f29ea44e47851ff686bb64bb6 diff --git a/udpinput.cpp b/udpinput.cpp index cd66f16..ed53ede 100644 --- a/udpinput.cpp +++ b/udpinput.cpp @@ -1,16 +1,18 @@ +#include +#include +#include #include -#include +#include #include -#include -#include -#include +#include #include #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; @@ -45,6 +47,7 @@ UDPInput::UDPInput(const InputProto &serialized) InputProto UDPInput::serialize() const { InputProto serialized; + serialized.set_stream_id(stream_id); serialized.set_url(url); serialized.set_sock(sock); return serialized; @@ -58,7 +61,7 @@ void UDPInput::close_socket() } while (ret == -1 && errno == EINTR); if (ret == -1) { - perror("close()"); + log_perror("close()"); } sock = -1; @@ -82,7 +85,8 @@ 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, "[%s] UDP socket creation failed. Waiting 0.2 seconds and trying again...", + stream_id.c_str()); usleep(200000); continue; } @@ -99,7 +103,7 @@ void UDPInput::do_work() continue; } if (nfds == -1) { - perror("poll"); + log_perror("poll"); close_socket(); continue; } @@ -111,7 +115,7 @@ void UDPInput::do_work() } while (ret == -1 && errno == EINTR); if (ret <= 0) { - perror("recv"); + log_perror("recv"); close_socket(); continue; }