diff options
author | M. Sean Finney <seanius@users.sourceforge.net> | 2005-05-03 01:52:19 +0000 |
---|---|---|
committer | M. Sean Finney <seanius@users.sourceforge.net> | 2005-05-03 01:52:19 +0000 |
commit | 3e5b9b3d3256792f02c53b3bce0cb5ae6c147428 (patch) | |
tree | f39a3a16c7ae6957d81c686b711f0a2090d8984e /plugins | |
parent | 1cd64d081d1745436dd7c41826dfb05672dd26aa (diff) | |
download | monitoring-plugins-3e5b9b3d3256792f02c53b3bce0cb5ae6c147428.tar.gz |
if check_tcp was called with -e but not -s, it would hang in a call to my_recv. the
fix committed here adds on more piece of logic to the check to see if more data needs
to be read, avoiding the deadlock call. a better fix would be to not use these "voodoo"
heuristics and instead use poll() or select(), but that's quite a bit more complicated.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1170 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_tcp.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index 979dfad8..fd2fe66b 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c | |||
@@ -322,8 +322,10 @@ main (int argc, char **argv) | |||
322 | while ((i = my_recv ()) > 0) { | 322 | while ((i = my_recv ()) > 0) { |
323 | buffer[i] = '\0'; | 323 | buffer[i] = '\0'; |
324 | asprintf (&status, "%s%s", status, buffer); | 324 | asprintf (&status, "%s%s", status, buffer); |
325 | if (buffer[i-2] == '\r' && buffer[i-1] == '\n') | 325 | if (buffer[i-1] == '\n') { |
326 | break; | 326 | if (buffer[i-2] == '\r' || i < MAXBUF-1) |
327 | break; | ||
328 | } | ||
327 | if (maxbytes>0 && strlen(status) >= (unsigned)maxbytes) | 329 | if (maxbytes>0 && strlen(status) >= (unsigned)maxbytes) |
328 | break; | 330 | break; |
329 | } | 331 | } |