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 »

Thomas Guyot-Sionnest wrote:
> 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 condition will always succeed (just like when testing the pointer) and
> there is no need to walk further the r list.
>
ah yes, I see that now.

> 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.
>
>
I'm not trying to solve any immediate problem, I was just having a look
and came across that, so I'm not inclined to change its current
behavior. thanks for the reply.






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