diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-02-09 01:51:36 -0800 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-02-12 20:21:34 -0800 |
commit | 80e36aa669274637bcd5956fbf4020dba1d4739c (patch) | |
tree | 2f5d3a63a5f7230ab73cd588e3493c0664a5a73b /src/common/socket.cpp | |
parent | 83b2e0b3ceda907b7186acfcc56c214fc04d9c13 (diff) | |
download | tmwa-80e36aa669274637bcd5956fbf4020dba1d4739c.tar.gz tmwa-80e36aa669274637bcd5956fbf4020dba1d4739c.tar.bz2 tmwa-80e36aa669274637bcd5956fbf4020dba1d4739c.tar.xz tmwa-80e36aa669274637bcd5956fbf4020dba1d4739c.zip |
Strictify timers
Diffstat (limited to 'src/common/socket.cpp')
-rw-r--r-- | src/common/socket.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 50c08a0..ac5a17d 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -332,7 +332,7 @@ void WFIFOSET(int fd, size_t len) FPRINTF(stderr, "socket: %d wdata lost !!\n", fd), abort(); } -void do_sendrecv(uint32_t next) +void do_sendrecv(interval_t next_ms) { fd_set rfd = readfds, wfd; FD_ZERO(&wfd); @@ -342,8 +342,12 @@ void do_sendrecv(uint32_t next) FD_SET(i, &wfd); } struct timeval timeout; - timeout.tv_sec = next / 1000; - timeout.tv_usec = next % 1000 * 1000; + { + std::chrono::seconds next_s = std::chrono::duration_cast<std::chrono::seconds>(next_ms); + std::chrono::microseconds next_us = next_ms - next_s; + timeout.tv_sec = next_s.count(); + timeout.tv_usec = next_us.count(); + } if (select(fd_max, &rfd, &wfd, NULL, &timeout) <= 0) return; for (int i = 0; i < fd_max; i++) |