httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [users@httpd] httpd forks & handling duplicate file descriptor
Date Mon, 30 May 2005 06:01:47 GMT

Need help in solving the httpd fork and file descriptor issue -

Iam doing a sendmsg(fd,..) followed by recv(fd,...) indirectly in my php file.
i.e, iam calling socket API's which are warppers for sendmsg() and recv() 
by including them in my php file.
There are multile such php files which call sendmsg()and recv() for different functionality.
I don't have much control over 'fd' and they are supposed to be generated in ususal incremental
The sendmsg() and recv() are hence intended to be run 'atomic' to avoid one recv() actually

receiving the reply for sendmsg() of a wrong pair. 

My issue: 
since http does a load sharing and creates forks for httpd (ps -ef |grep httpd) at any given
point of time 
i noticed that the same file desciptors are being used across the different php files (used
strace for this).
This is causing some recv()s to actually receive the reply for sendmsg() of a wrong pair.

better solutions please..?:
1) I could check if the recv() data matches the sendmsg() request by comparing some data.
   Not a good solution since this is not the root cause's solution. 

2) I tried using php semaphores (sem_get/sem_aquire/sem_release) around all the send/recv
   However this still didn't solve my problem.
   [ is httpd fork ignoring a semaphore region and still forking and 
    and handling a different php when a recv() is already waiting ???]

Pls do let me know a better way of handling this issue.

Nb: newbie and first post. i did not find any luck in the httd archives as well. 

Sign-up for Ads Free at

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message