Re: [Nagios-devel] netutils use of socket descriptor

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

Re: [Nagios-devel] netutils use of socket descriptor

Post by Guest »

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 13/06/09 08:17 AM, Hiren Patel wrote:
> wondering if this is a valid change.
> attached. thanks.

Good catch, though it looks like it will have no effect whatsoever.

According to socket(2):
On success, a file descriptor for the new socket is returned. On
error, -1 is returned, and errno is set appropriately.

In other words if sd is not <0 (which returns an error immediately) the
condition will always succeed (just like when testing the pointer) and
there is no need to walk further the r list.

If you want to connect with a given per-address or global timeout, then
you'll have to include most of the rest of the function in the while(r)
loop... unfortunately that will give you a per-ip timeout which is
likely not desired.


A better way of doing this is to send a connect for the next ip in list
every n miliseconds (where n is a small fraction of the timeout, you
could for example take half of the timeout and divide it by the number
of IP), use the first connected socket and clean up the rest.


- --
Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKNpKb6dZ+Kt5BchYRAr5kAKDRKewdaQdhHO/zIO3it0rQShcEcgCg/Dbj
4gpQ/7cEuRf17boUA6glazo=
=knMY
-----END PGP SIGNATURE-----





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