[Ace-users] Re: Leader/Follower Design Pattern Question

Douglas C. Schmidt schmidt at tango.dre.vanderbilt.edu
Mon Aug 13 05:03:52 CDT 2007


Hi Peter,

   I recommend you post questions about these sorts of patterns to
comp.soft-sys.ace rather than comp.object.corba.

> While implemented for iterative handle (tcp socket) and and using
> iterative handle set (i.e. fdset in poll) must carefully deal with
> handles to avoid race conditions. Please, correct me If I'm wrong.

You are correct.

> Leader thread is blocked on poll() waiting for IO event (CONNECT,
> READ, CLOSE). New request arrives. Leader wakes up, deactivates this
> socket in fdset, then becomes processor. After request is handled
> our thread activates socket in fdset and returns to the thread pool
> (becames one of the followers). 

Right.

> Imagine, we have two connections open to our server, but only one of
> them is active.  

I assume each connection has a separate socket handle in the server,
i.e., there are two socket handles involved here, right?

> I mean sends requests. Second connection is opened but sends no
> requests now. Leader thread is handling first request from active
> connection, deactivates socket from fdset. 

Just to make sure - there is still the second socket handle for the
second connection that's still be waited for by poll(), right?

> New leader is elected, waits for IO event. Second request from
> active connection arrives, but leader still waits on poll(), because
> socket related to active connection is deactivated until first
> request is being processed.

Hum, I don't follow this - why would this occur since there should be
two socket handles?

> My question is, how and when this socket will be added to fdset?
> Does It have to be delayed until data arrives to one of the sockets
> being polled by current leader thread?

Assuming that each connection has a separate socket handle then things
should work fine.  If you are multiplexing requests through a single
socket hande then the second request will will not be processed until
the first request is finished.

Take care,

    Doug
-- 
Dr. Douglas C. Schmidt                       Professor and Associate Chair
Electrical Engineering and Computer Science  TEL: (615) 343-8197
Vanderbilt University                        WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203                          NET: d.schmidt at vanderbilt.edu


More information about the Ace-users mailing list