diff --git a/src/lib/utils/log.cpp b/src/lib/utils/log.cpp index 0829f210..2190c1b6 100644 --- a/src/lib/utils/log.cpp +++ b/src/lib/utils/log.cpp @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +#define _GNU_SOURCE + #include "lib/utils/log.h" #include #include diff --git a/src/lib/utils/tcpsocket.h b/src/lib/utils/tcpsocket.h index 6b8f3263..1855aaf8 100644 --- a/src/lib/utils/tcpsocket.h +++ b/src/lib/utils/tcpsocket.h @@ -95,6 +95,17 @@ class TCPSocket { */ bool isValid(); + /** + * Set the timeout for @a send and @a recv. + * @param timeout the timeout in seconds. + */ + void setTimeout(int timeout) { + struct timeval t; + t.tv_usec = 0; + t.tv_sec = timeout; + setsockopt(m_sfd, SO_RCVTIMEO, SO_REUSEADDR, &t, sizeof(t)); + setsockopt(m_sfd, SO_SNDTIMEO, SO_REUSEADDR, &t, sizeof(t)); + } private: /** file descriptor from tcp socket */ diff --git a/src/lib/utils/thread.cpp b/src/lib/utils/thread.cpp index bc428d8c..8df01504 100644 --- a/src/lib/utils/thread.cpp +++ b/src/lib/utils/thread.cpp @@ -20,6 +20,10 @@ # include #endif +#ifdef HAVE_PTHREAD_SETNAME_NP +# define _GNU_SOURCE +#endif + #include "lib/utils/thread.h" #include "lib/utils/clock.h"