From b64cd7e45873e033be4761ebffac99967bcb9984 Mon Sep 17 00:00:00 2001 From: Alexey Dvoryanchikov Date: Thu, 9 Jan 2014 14:07:53 +0400 Subject: [PATCH] Use timeout in connect function, avoiding sigpipe in case one of remote monitor systems is unreachable that causing loss all other communications, maybe later should make it optional config parameter --- clients/upsclient.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clients/upsclient.c b/clients/upsclient.c index 797786b0b1..c9b6c99470 100644 --- a/clients/upsclient.c +++ b/clients/upsclient.c @@ -1034,7 +1034,10 @@ int upscli_tryconnect(UPSCONN_t *ups, const char *host, int port, int flags,stru int upscli_connect(UPSCONN_t *ups, const char *host, int port, int flags) { - return upscli_tryconnect(ups,host,port,flags,NULL); + struct timeval timeout; + timeout.tv_sec = 10; + timeout.tv_usec = 0; + return upscli_tryconnect(ups,host,port,flags,&timeout); } /* map upsd error strings back to upsclient internal numbers */