On Thu, 2009-10-15 at 17:26 -0400, 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?
Usually whoever opens the channel is responsible for setting O_NONBLOCK, but this seem more convention than a hard rule. You can decide to check if O_NONBLOCK is set or not and refuse to operate asynchronusly returning errors if it is not I guess. > 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? This is your call :-) But Sumit seem to have described a good way to do it otherwise. > 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? As above. Simo. -- Simo Sorce * Red Hat, Inc * New York _______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/sssd-devel