gdk_input_add behavior



The quick question: when gdk_input_add is called to monitor a socket for
read activity, will it send an event immediately if there is data in the
queue?

The slightly longer question:

I'm working on a cross-platform socket wrapper.  In an attempt to reduce
spurious events on all platforms, callbacks are disabled while an event
is being handled, then reenabled once the event has been handled.  The
current code looks like this:

OnReadEvent {
   gdk_input_remove();
   DoSomeProcessing();
   gdk_input_add();
   recv();
}

Is this a race condition with gdk_input_add() being called prior to the
recv() call?  Will there be any behavior change with those calls
reversed like so?

OnReadEvent {
   gdk_input_remove();
   DoSomeProcessing();
   recv();
   gdk_input_add();
}

Or does this have the potential to miss an event if data comes in
between recv() and gdk_input_add()?

Thanks in advance!

-- 
Brian



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]