[Nagiosplug-checkins] nagiosplug/plugins check_tcp.c,1.62,1.63

M. Sean Finney seanius at users.sourceforge.net
Mon May 2 18:54:12 CEST 2005


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13568

Modified Files:
	check_tcp.c 
Log Message:
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.


Index: check_tcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_tcp.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- check_tcp.c	11 Apr 2005 03:07:59 -0000	1.62
+++ check_tcp.c	3 May 2005 01:52:19 -0000	1.63
@@ -322,8 +322,10 @@
 		while ((i = my_recv ()) > 0) {
 			buffer[i] = '\0';
 			asprintf (&status, "%s%s", status, buffer);
-			if (buffer[i-2] == '\r' && buffer[i-1] == '\n')
-				break;
+			if (buffer[i-1] == '\n') {
+				if (buffer[i-2] == '\r' || i < MAXBUF-1)
+					break;
+			}
 			if (maxbytes>0 && strlen(status) >= (unsigned)maxbytes)
 				break;
 		}





More information about the Commits mailing list