[Ace-users] Re: Leader/Follower Design Pattern Question
Douglas C. Schmidt
schmidt at tango.dre.vanderbilt.edu
Mon Aug 13 09:13:20 CDT 2007
>Yes, these two socket handles are in fdset. Leader thread wakes up,
>poll() indicates that appropriate socket in fdset is "Read Ready".
BTW, please note that poll() doesn't use fdsets - I assume you're
using this term loosely, right?
>Then leader thread deactivates this socket in fdset. As I understand
>until this socket is not activated, poll() will not return any new data
>notification on this socket handle.
Yes, that is correct.
>>> 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?
>Now, there is one deactivated socket handle (for active connection) and
>active socket handle (for the second connection) in fdset.
>Even if new
>request on active connection arrives It will not wake up new leader
>thread waiting on poll(), because this socket handle is now deactivated
Yes, that's correct. As long as the active connection is being
processed then the handle will be deactivated.
>Going back to our example.
>Now processing thread ends Its activities (handling first request) and
>should activate his socket handle in fdset in order to enable handling
>of incoming subsequent request.
Yes, that's correct.
>But It is not able to activate his
>socket handle in fdset, because It's now acquired by leader polling
Ah, now I understand your question. Basically, there needs to be yet
another "internal" I/O handle - let's call it the "notify handle" -
that poll() always waits on in addition to the socket handles that
correspond to clients. This notify handle is used to wakeup poll()
after updating the fdset that keeps track of what events need to be
listened to. There's more discussion of how this works in Chapter 3
and 4 of the C++NPv2 book <www.cs.wustl.edu/~schmidt/ACE/book2/>. The
code for doing this is available in ACE in the ACE_Select_Reactor.
Please take a look at these resources and let me know if you have any
>I assume that thread handles only one request per activation. I am not
>sure If It is a valid assumption.
Yes, that's (usually) correct.
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