logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

nagiosplug/plugins check_tcp.c,1.62,1.63: msg#00002

Subject: nagiosplug/plugins check_tcp.c,1.62,1.63
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;
                }



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20


<Prev in Thread] Current Thread [Next in Thread>