Package: ndoutils Version: 1.4b9-1 Severity: normal Tags: patch Hi there,
At work, we use ndoutils and a custom bit of perl on the remote side to
send updates from satellites back to an aggregator nagios. We've found
that when the network flaps, all the satellites get stuck in a write()
and never return. The admittedly simple patch below should help:
--- ndoutils-1.4b9/src/io.c 2009-10-21 08:53:30.000000000 +0100
+++ ndoutils-1.4b9+nonblock/src/io.c 2010-05-01 15:31:43.000000000 +0100
@@ -224,6 +224,9 @@
if(!(newfd=socket(PF_INET,SOCK_STREAM,0)))
return NDO_ERROR;
+ int x;
+ x=fcntl(newfd,F_GETFL,0); // Get socket flags
+ fcntl(newfd,F_SETFL,x | O_NONBLOCK); // Add non-blocking flag
/* copy the host/ip address and port */
server_address_i.sin_family=AF_INET;
server_address_i.sin_port=htons(port);
@@ -274,7 +277,8 @@
if(buflen<=0)
return 0;
- while(tbytes<buflen){
+ int a = 0;
+ while(tbytes<buflen && a < 1024){ // try, but let's not loop forever
/* try to write everything we have left */
#ifdef HAVE_SSL
@@ -289,12 +293,13 @@
if(result==-1){
/* unless we encountered a recoverable error, bail out
*/
- if(errno!=EAGAIN && errno!=EINTR)
+ if(errno!=EAGAIN && errno!=EINTR && errno!=EINPROGRESS)
return NDO_ERROR;
}
/* update the number of bytes we've written */
tbytes+=result;
+ a++;
}
return tbytes;
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8) (ignored: LC_ALL
set to en_US.utf8)
Shell: /bin/sh linked to /bin/dash
--
-----------------------------------------------------------------
| ,''`. Stephen Gran |
| : :' : [email protected] |
| `. `' Debian user, admin, and developer |
| `- http://www.debian.org |
-----------------------------------------------------------------
signature.asc
Description: Digital signature

