[Nagios-devel] Make sockets non-blocking

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Make sockets non-blocking

Post by Guest »


--QTprm0S8XgL7H0Dt
Content-Type: multipart/mixed; boundary="azLHFNyN32YCQGCU"
Content-Disposition: inline


--azLHFNyN32YCQGCU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi there,

We use NDO for network communication with a custom bit of perl to pass
status updates around. Recently, we've seen that a network flap can
make ndo hang the entire nagios process, which is possibly imperfect :)

I think I've tracked it down to the write() call in io.c when sending
the actual update to the remote server. The attached patch is a
relatively naive attempt at making this write nonblocking for network
sockets.

This is a patch against the CVS - if you prefer a git-am style patch,
that's fine. I tried to clone the git off of sourceforge this morning,
and got an empty repo. If there's a better place to clone from, let me
know and I'll fix it up for that.

Cheers,
--=20
--------------------------------------------------------------------------
| Stephen Gran | You have a will that can be influenced |
| [email protected] | by all with whom you come in contact. |
| http://www.lobefin.net/~steve | |
--------------------------------------------------------------------------

--azLHFNyN32YCQGCU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="ndoutils-nonblock-socket.patch"

Index: src/io.c
===================================================================
RCS file: /cvsroot/nagios/ndoutils/src/io.c,v
retrieving revision 1.6
diff -r1.6 io.c
226a227,229
> int x;
> x=fcntl(newfd,F_GETFL,0); // Get socket flags
> fcntl(newfd,F_SETFL,x | O_NONBLOCK); // Add non-blocking flag
277c280,281
int a = 0;
> while(tbytes if(errno!=EAGAIN && errno!=EINTR && errno!=EWOULDBLOCK)
297a302
> a++;

--azLHFNyN32YCQGCU--

--QTprm0S8XgL7H0Dt
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkvcUO8ACgkQSYIMHOpZA46TQwCgmV+TOlXnrWZ/Cu9on7l9D9PC
QuQAmQHQqXJxMxIbJ76NkPVHBTtMu3Pd
=fQMk
-----END PGP SIGNATURE-----

--QTprm0S8XgL7H0Dt--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked