From 28d899285c65ad2b7266e57e1974603b7b040bfe Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 21 Oct 2010 13:27:35 -0700 Subject: [PATCH] messenger: a 0 timeout on ::poll really means don't wait (as opposed to -1, which waits until an event occurs). So, set the default timeout to -1, and convert ms_tcp_read_timeout to -1 if it's set at 0. --- src/msg/SimpleMessenger.h | 2 ++ src/msg/tcp.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/msg/SimpleMessenger.h b/src/msg/SimpleMessenger.h index 37825948d3c8d..d450352465cd2 100644 --- a/src/msg/SimpleMessenger.h +++ b/src/msg/SimpleMessenger.h @@ -216,6 +216,8 @@ private: reader_thread(this), writer_thread(this) { connection_state->pipe = get(); messenger->timeout = g_conf.ms_tcp_read_timeout * 1000; //convert to ms + if (messenger->timeout == 0) + messenger->timeout = -1; } ~Pipe() { for (map::item* >::iterator i = queue_items.begin(); diff --git a/src/msg/tcp.h b/src/msg/tcp.h index 97ef3a90a86dc..89548aa10e9e4 100644 --- a/src/msg/tcp.h +++ b/src/msg/tcp.h @@ -25,7 +25,7 @@ inline ostream& operator<<(ostream& out, const sockaddr_storage &ss) << buf << ':' << serv; } -extern int tcp_read(int sd, char *buf, int len, int timeout=0); +extern int tcp_read(int sd, char *buf, int len, int timeout=-1); extern int tcp_write(int sd, const char *buf, int len); inline bool operator==(const sockaddr_in& a, const sockaddr_in& b) { -- 2.39.5