diff --git a/src/zm_buffer.cpp b/src/zm_buffer.cpp index b4b970eb3..4cb580aa4 100644 --- a/src/zm_buffer.cpp +++ b/src/zm_buffer.cpp @@ -74,11 +74,13 @@ int Buffer::read_into(int sd, unsigned int bytes) { return bytes_read; } -int Buffer::read_into(int sd, unsigned int bytes, struct timeval timeout) { +int Buffer::read_into(int sd, unsigned int bytes, Microseconds timeout) { fd_set set; FD_ZERO(&set); /* clear the set */ FD_SET(sd, &set); /* add our file descriptor to the set */ - int rv = select(sd + 1, &set, NULL, NULL, &timeout); + timeval timeout_tv = zm::chrono::duration_cast(timeout); + + int rv = select(sd + 1, &set, nullptr, nullptr, &timeout_tv); if (rv == -1) { Error("Error %d %s from select", errno, strerror(errno)); return rv; @@ -86,5 +88,6 @@ int Buffer::read_into(int sd, unsigned int bytes, struct timeval timeout) { Debug(1, "timeout"); /* a timeout occured */ return 0; } + return read_into(sd, bytes); } diff --git a/src/zm_buffer.h b/src/zm_buffer.h index c2b509e13..fddd2f3cc 100644 --- a/src/zm_buffer.h +++ b/src/zm_buffer.h @@ -21,6 +21,7 @@ #define ZM_BUFFER_H #include "zm_logger.h" +#include "zm_time.h" #include class Buffer { @@ -187,7 +188,7 @@ class Buffer { return static_cast(mSize); } int read_into(int sd, unsigned int bytes); - int read_into(int sd, unsigned int bytes, struct timeval timeout); + int read_into(int sd, unsigned int bytes, Microseconds timeout); }; #endif // ZM_BUFFER_H