[PATCH] lib/iobroker: Only close fds we're managing

robin.sonefors at op5.com robin.sonefors at op5.com
Wed Nov 21 10:21:23 CET 2012


From: Robin Sonefors <robin.sonefors at op5.com>

In all places except one, iobroker makes sure it only touches the file
descriptors that's been registered with it. The last place is in the
destructor, which is called quite early in the nagios shutdown process,
making it impossible to log anything else after this.

This patch excludes any valid fds we're not supposed to do anything
with, meaning that, say, stdout won't get mercilessly closed.

In practice, without this patch, a restart would log any broker modules
being unloaded, while a shutdown wouldn't. With this patch, shutdowns do
log broker modules being unloaded.

Reported-by: Anton Löfgren <alofgren at op5.com>
Signed-off-by: Robin Sonefors <robin.sonefors at op5.com>
---
 lib/iobroker.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/iobroker.c b/lib/iobroker.c
index af60bd6..5f55127 100644
--- a/lib/iobroker.c
+++ b/lib/iobroker.c
@@ -320,6 +320,8 @@ void iobroker_destroy(iobroker_set *iobs, int flags)
 		return;
 
 	for (i = 0; i < iobs->max_fds; i++) {
+		if (iobs->iobroker_fds[i] == NULL)
+			continue;
 		dereg(iobs, i);
 	}
 	free(iobs->iobroker_fds);
-- 
1.7.11.7


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list