Page 1 of 1

[Nagios-devel] EINTR on accept for Solaris 10's ndo2db

Posted: Wed Feb 27, 2008 6:26 am
by Guest

--Apple-Mail-23-329420167
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit

Hi!

We've found a bug in ndo2db where ndo2db errors due to an accept
problem on Solaris 10. It appears that the accept call in the parent
gets an EINTR error when the child exits.

We've fixed it by placing a loop around the accept call to try again
if EINTR is received. You can see this from the truss output:

24531: open("/var/run/syslog_door", O_RDONLY) = 6
24531: door_info(6, 0x080466E0) = 0
24531: getpid() = 24531 [24522]
24531: door_call(6, 0x08046718) = 0
24531: close(6) = 0
24531: close(5) = 0
24531: mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_ANON, -1, 0) = 0xD2480000
24531: munmap(0xD2480000, 4096) = 0
24531: _exit(0)
24522: Received signal #18, SIGCLD, in accept() [caught]
24522: siginfo: SIGCLD CLD_EXITED pid=24531 status=0x0000
24522: accept(4, 0x08047AC0, 0x08047AAC, SOV_DEFAULT) Err#4 EINTR
24522: lwp_sigmask(SIG_SETMASK, 0x00000000, 0x00000000) = 0xFFBFFEFF
[0x0000FFFF]
24522: write(2, " I n p a r e n t h a n".., 17) = 17
24522: waitid(P_ALL, 0, 0x08047700, WEXITED|WTRAPPED|WNOHANG) = 0
24522: setcontext(0x080475E0)
24522: write(2, " E I N T R r e c e i v".., 14) = 14
24522: write(2, " : ", 2) = 2
24522: write(2, " I n t e r r u p t e d ".., 23) = 23
24522: write(2, "\n", 1) = 1
24522: accept(4, 0x08047AC0, 0x08047AAC, SOV_DEFAULT) (sleeping...)

Note the _exit(0) from pid 24531 followed by the SIGCLD signal, then
the accept call with EINTR before processing in the parent handler
[write(2, "In parenthan...") - a debug line we put in].

Two other things that we've noticed:
* the ndo2db_handle_client_connection() has a check for EINTR too,
but this edge cause could fall into the main processing if result=-1
and errno=EINTR
* the parent signal handler doesn't appear to be reset as
subsequent child exits do not cause the parent to catch the SIGCLD
(which probably explains why the socket is left lying around)

This is for ndoutils 1.4b3.

Ton

http://www.altinity.com
UK: +44 (0)870 787 9243
US: +1 866 879 9184
Fax: +44 (0)845 280 1725
Skype: tonvoon



--Apple-Mail-23-329420167
Content-Disposition: attachment;
filename=ndoutils_solaris_eintr_in_accept.patch.txt
Content-Type: text/plain; x-unix-mode=0644;
name="ndoutils_solaris_eintr_in_accept.patch.txt"
Content-Transfer-Encoding: 7bit

diff -ur ndoutils-1.4b3.original/src/ndo2db.c ndoutils-1.4b3/src/ndo2db.c
--- ndoutils-1.4b3.original/src/ndo2db.c 2008-02-26 16:47:56.039942000 +0000
+++ ndoutils-1.4b3/src/ndo2db.c 2008-02-26 16:54:47.137446552 +0000
@@ -709,11 +709,25 @@
/* accept connections... */
while(1){

- if((new_sd=accept(ndo2db_sd,(ndo2db_socket_type==NDO_SINK_TCPSOCKET)?(struct sockaddr *)&client_address_i:(struct sockaddr *)&client_address_u,(socklen_t *)&client_address_length))=0)
+ /* data available */
+ break;
+ if(errno == EINTR) {
+ /* continue */
+ }
+ else {
+ perror("Accept error");
+ ndo2db_cleanup_socket();
+ return NDO_ERROR;
+ }
+ }
+

#ifndef DEBUG_NDO2DB
/* fork... */

--Apple-Mail-23-329420167
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
Content-Transfer-Encoding: 7bit





--Apple-Mail-23-329420167--





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