[SSSD] Design question

Stephen Gallagher sgallagh at redhat.com
Fri Oct 16 13:05:25 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/15/2009 05:26 PM, Dmitri Pal wrote:
> Hi,
> 
> Couple questions about async processing.
> The communication usually consists of several parts. Imagine that you
> have an object that is responsible for some sort of communication
> (socket, pipe, file, bus - whatever).
> Here are the basic things that can happen with such object:
> * Object is created
> * Communication channel is opened
> * Message is sent (and may be you get response back)
> * Communication channel is closed
> * Object is destructed
> 
> Object creation and destruction are the same regardless of whether the
> communication is synchronous or asynchronous.
> They are pretty straightforward. So let us talk about the other three.
> Definitely communication on the channel can (and should) be asynchronous
> - this is the whole purpose.
> But what about opening the channel. Should a file or socket be always
> opened as "O_NONBLOCK" or
> the event library would set the flag on the FD itself?
> I guess the question who is responsible for making socket/fd nonblocking
> the creator of it or the async library that provided the event loop?
> 

Whoever makes the call to open the channel must set O_NONBLOCK. The
event library will not do it for you.

> Now imagine the situation: the opening of the channel includes actually
> two steps, establishing the channel itself (TCP for example) and sending
> some sort of the HELLO message.
> Can this hello message be done synchronously or the  connection should
> be established in async way and the hello message should be treated as
> any other message?
> I understand that the preferred way is to do it asynchronously but the
> question is: is it acceptable not to at least in the first implementation?

I suppose it depends on whether the HELLO message needs a reply/ack or
not. If it does, then the appropriate way to handle this is to do it
asynchronously and allow the consumer to provide a callback to be
notified when the connection is available for use.

If you are sending a message with no expectation of a response, it's
acceptable to fire-and-forget in the init routine.

> Same question about closing the channel when this operation involves
> sending some sort of good bye message first. Is it acceptable to send
> and close in one step synchronously or not?
> 

Same answer.

Remember that the consumer of your asynchronous API can always use a
private loop context in order to have it behave in a synchronous manner.


- -- 
Stephen Gallagher
RHCE 804006346421761

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkrYb5EACgkQeiVVYja6o6OP5gCggXJQDVg1U8QWCYoq9b7EQNR5
TJQAmgL16llgVH5SpJVubJN3CNNpAdk5
=D7kw
-----END PGP SIGNATURE-----



More information about the sssd-devel mailing list