[Cialug] Event loop problem
Dave Weis
WeisD at alliancetechnologies.net
Mon Jul 14 14:53:19 CDT 2014
You'll need to use the SO_REUSEADDR on the socket() call to rebind to the same port number. You can't count on the same FD every time so pay attention to the return value from socket() and listen() on it.
-----Original Message-----
From: cialug-bounces at cialug.org [mailto:cialug-bounces at cialug.org] On Behalf Of Brian Wood
Sent: Monday, July 14, 2014 2:49 PM
To: tclug-list; cialug at cialug.org
Subject: [Cialug] Event loop problem
I've been having a problem related to epoll_ctl lately.
You may recall I have a 3-tier system:
1. back tier (tcp server)
2. middle tier (udp server)
3. front tier
If I kill the middle tier with a control-C and then restart it (without making any requests via the front tier), the socket descriptor (associated with the middle tier) in the back tier is 7. But If I first make some requests via the front tier, then kill the middle tier and then restart it, the socket descriptor is 1 instead of 7.
When the socket descriptor is 1, I get an EBADF on an epoll_ctl with an op of EPOLL_CTL_MOD.
It's on the second call to epoll_ctl though (with same input) that it fails. The first one is related to logging in and the second one is due to the request via the front tier. I've tried many things to get the back tier to not give me the socket descriptor of 1, but nothing has worked. I've tried calling daemon(), I've tried freopen'ing stdin, stdout, and stderr, and a few other things. I've tried doing these things only in the parent, only in the child and in both.
Nothing has worked. Any ideas?
This problem makes me think more about BSD. Even if
I figure this out, I'm still left with epoll. If you could have
any operating system for running an on line service, what would you pick? Thanks.
--
Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
_______________________________________________
Cialug mailing list
Cialug at cialug.org
http://cialug.org/mailman/listinfo/cialug
More information about the Cialug
mailing list