Page 1 of 1

[Nagios-devel] patch: poll(2) error checking in service_result_worker_thread.

Posted: Fri Apr 29, 2005 2:16 am
by Guest
This is a multi-part message in MIME format.
--------------080700080001030403020007
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Ahoy.

Attached is a patch to make the poll(2) call in
service_result_worker_thread check for errors. It doesn't really do
anything about errors it finds except logging them, so this shouldn't
affect neither performance nor functionality.

Apply with
patch -p1 < nagios-poll-errcheck.diff

This needs to be applied before the nonroot-no_drop_priv patch I sent in
2 minutes ago for them to apply without fuzzy offsets.

--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Lead Developer

--------------080700080001030403020007
Content-Type: text/plain;
name="nagios-poll-errcheck.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="nagios-poll-errcheck.diff"

diff -urN ../nagios.orig/base/utils.c ./base/utils.c
--- ../nagios.orig/base/utils.c Wed Apr 27 17:45:29 2005
+++ ./base/utils.c Fri Apr 29 13:05:29 2005
@@ -4675,8 +4675,24 @@
pollval=poll(&pfd,1,500);

/* loop if no data */
- if(pollval<=0)
+ if(pollval==0)
continue;
+
+ /* check for errors */
+ if(pollval==-1) {
+ if(errno==EBADF)
+ write_to_log("service_result_worker_thread(): poll(): EBADF", logging_options, NULL);
+ else if(errno==ENOMEM)
+ write_to_log("service_result_worker_thread(): poll(): ENOMEM", logging_options, NULL);
+ else if(errno==EFAULT)
+ write_to_log("service_result_worker_thread(): poll(): EFAULT", logging_options, NULL);
+ else if(errno==EINTR) /* this should NEVER happen */
+ write_to_log("service_result_worker_thread(): poll(): EINTR (impossible)", logging_options, NULL);
+ else
+ write_to_log("service_result_worker_thread(): poll(): Unknown errno value.", logging_options, NULL);
+
+ continue;
+ }

/* should we shutdown? */
pthread_testcancel();

--------------080700080001030403020007--





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