<!-- MHonArc v2.4.4 --> <!--X-Subject: [MUD-Dev] Passing file descriptors to other processes --> <!--X-From-R13: "Oqnz X. Fubeagba" <nqnzNcubravk.Bevaprgba.SRG> --> <!--X-Date: Thu, 13 Aug 1998 20:18:42 -0700 --> <!--X-Message-Id: 19980813231806.A15838#yuma,Princeton.EDU --> <!--X-Content-Type: text/plain --> <!--X-Head-End--> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>MUD-Dev message, [MUD-Dev] Passing file descriptors to other processes</title> <!-- meta name="robots" content="noindex,nofollow" --> <link rev="made" href="mailto:adam#phoenix,Princeton.EDU"> </head> <body background="/backgrounds/paperback.gif" bgcolor="#ffffff" text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000"> <font size="+4" color="#804040"> <strong><em>MUD-Dev<br>mailing list archive</em></strong> </font> <br> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] <br clear=all><hr> <!--X-Body-Begin--> <!--X-User-Header--> <!--X-User-Header-End--> <!--X-TopPNI--> Date: [ <a href="msg00714.html">Previous</a> | <a href="msg00716.html">Next</a> ] Thread: [ <a href="msg00719.html">Previous</a> | <a href="msg00711.html">Next</a> ] Index: [ <A HREF="author.html#00715">Author</A> | <A HREF="#00715">Date</A> | <A HREF="thread.html#00715">Thread</A> ] <!--X-TopPNI-End--> <!--X-MsgBody--> <!--X-Subject-Header-Begin--> <H1>[MUD-Dev] Passing file descriptors to other processes</H1> <HR> <!--X-Subject-Header-End--> <!--X-Head-of-Message--> <UL> <LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI> <LI><em>Subject</em>: [MUD-Dev] Passing file descriptors to other processes</LI> <LI><em>From</em>: "Adam J. Thornton" <<A HREF="mailto:adam#phoenix,Princeton.EDU">adam#phoenix,Princeton.EDU</A>></LI> <LI><em>Date</em>: Thu, 13 Aug 1998 23:18:06 -0400</LI> <LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI> </UL> <!--X-Head-of-Message-End--> <!--X-Head-Body-Sep-Begin--> <HR> <!--X-Head-Body-Sep-End--> <!--X-Body-of-Message--> <PRE> Hmmm. I've hit another roadblock. In my design, you may remember, if a player connects to the server daemon and wants to be in a room where there are already connected players, then that room has a process associated with it. So I can pass the file descriptor of the open socket to that process with sendmsg, and receive it with recvmsg... But, with sendmsg and recvmsg, I can't target a specific process, so any process that's listening might grab the connection--this is wrong, I want it to go to a specific room process. So here's my solution; it seems ugly to me and I was wondering if anyone sees an obviously better way to do it. Server Process Room Process -------------- ------------ mutex_lock signal to room process signal received signal handler block all new signals sendmsg (blocking)=fd recvmsg (blocking) **************Processes Synchronized Here******************** get fd out of message spawn player thread connected to new fd. recvmsg (blocking) sendmsg(blocking) = "done" **************Processes Synchronized Here******************** unblock signals mutex_unlock exit signal handler The reason for the mutex is so that there's only ever one attempt to pass a file descriptor at a time. The signal() will alert the room process that there's data for it; it'll set up a receiving socket and the server process will attempt to send. Both will block until the message gets sent. The receiving end will parse that message to get the appropriate end. The sending end, meanwhile, will block waiting to receive a message. The receiving end will send a message telling the server process that it's done, whereupon the server can unlock the mutex and get on with delivering the *next* such signal, while the room process deals with its player threads and gets ready to catch the next signal passed its way. This way, we know that, because the sendmsg/recvmsg calls are blocking, we are synchronized between the two processes. Because of the mutex only one room process will be ready to recvmsg() at any given time, since catching that message happens only in the signal handler. So I have two questions: A) will this work, or is there some blindingly obvious race condition I overlooked, and B) is there a better way to do this? Adam -- adam#princeton,edu "There's a border to somewhere waiting, and a tank full of time." - J. Steinman </PRE> <!--X-Body-of-Message-End--> <!--X-MsgBody-End--> <!--X-Follow-Ups--> <HR> <!--X-Follow-Ups-End--> <!--X-References--> <!--X-References-End--> <!--X-BotPNI--> <UL> <LI>Prev by Date: <STRONG><A HREF="msg00714.html">[MUD-Dev] Re: clients anyone?...</A></STRONG> </LI> <LI>Next by Date: <STRONG><A HREF="msg00716.html">[MUD-Dev] Re: clients anyone?...</A></STRONG> </LI> <LI>Prev by thread: <STRONG><A HREF="msg00719.html">[MUD-Dev] Re: Yet another update on threads and signals</A></STRONG> </LI> <LI>Next by thread: <STRONG><A HREF="msg00711.html">[MUD-Dev] Re: Methods to Reduce Ecological Wipeout (fwd)</A></STRONG> </LI> <LI>Index(es): <UL> <LI><A HREF="index.html#00715"><STRONG>Date</STRONG></A></LI> <LI><A HREF="thread.html#00715"><STRONG>Thread</STRONG></A></LI> </UL> </LI> </UL> <!--X-BotPNI-End--> <!--X-User-Footer--> <!--X-User-Footer-End--> <ul><li>Thread context: <BLOCKQUOTE><UL> <LI><strong><A NAME="00722" HREF="msg00722.html">[MUD-Dev] Re: Affordances and social method</A></strong>, cat <a href="mailto:cat#bga,com">cat#bga,com</a>, Fri 14 Aug 1998, 21:34 GMT <LI><strong><A NAME="00720" HREF="msg00720.html">[MUD-Dev] OT: access</A></strong>, s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Fri 14 Aug 1998, 18:48 GMT <LI><strong><A NAME="00718" HREF="msg00718.html">[MUD-Dev] Yet another update on threads and signals</A></strong>, Adam J. Thornton <a href="mailto:adam#phoenix,Princeton.EDU">adam#phoenix,Princeton.EDU</a>, Fri 14 Aug 1998, 14:24 GMT <UL> <LI><strong><A NAME="00719" HREF="msg00719.html">[MUD-Dev] Re: Yet another update on threads and signals</A></strong>, s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Fri 14 Aug 1998, 18:32 GMT </LI> </UL> </LI> <LI><strong><A NAME="00715" HREF="msg00715.html">[MUD-Dev] Passing file descriptors to other processes</A></strong>, Adam J. Thornton <a href="mailto:adam#phoenix,Princeton.EDU">adam#phoenix,Princeton.EDU</a>, Fri 14 Aug 1998, 03:18 GMT <LI><strong><A NAME="00711" HREF="msg00711.html">[MUD-Dev] Re: Methods to Reduce Ecological Wipeout (fwd)</A></strong>, Marc Hernandez <a href="mailto:marc#jb,com">marc#jb,com</a>, Thu 13 Aug 1998, 20:44 GMT <LI><strong><A NAME="00708" HREF="msg00708.html">[MUD-Dev] Re: avoiding ecological wipeout</A></strong>, Laurel Fan <a href="mailto:lf25+@andrew.cmu.edu">lf25+@andrew.cmu.edu</a>, Thu 13 Aug 1998, 20:13 GMT <LI><strong><A NAME="00707" HREF="msg00707.html">[MUD-Dev] OGR: Ion Storm's Witchboy talks about the functionality of enemy AI.</A></strong>, J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Thu 13 Aug 1998, 20:06 GMT <UL> <LI><strong><A NAME="00709" HREF="msg00709.html">[MUD-Dev] Re: OGR: Ion Storm's Witchboy talks about the functionalityof enemy AI.</A></strong>, s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Thu 13 Aug 1998, 20:36 GMT </LI> </UL> </LI> </UL></BLOCKQUOTE> </ul> <hr> <center> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] </center> <hr> </body> </html>