X asynchronicity issues



Hello, dudes,

Yesterday I put in a hack in the Evolution shell view widget so that
its child components are terminated correctly when the shell dies.
The hack consists of doing a gdk_flush() after the EShellView's
unrealize method is called.  What we have is the following:

	(1) EShellView is destroyed, so in the ::shutdown() method of
	    GtkWidget it is unrealized:

		(2) The BonoboSocket that holds the embedded component
		    is unrealized, so a DeleteEvent is sent to the
		    other side's plug.

	(3) We get out of ::shutdown() and enter the EShellView's
	    ::destroy() method, which does the Bonobo CORBA calls to
	    tell the BonoboControl on the other side to destroy
	    itself.

Note that (1) and (3) are executed sequentially.  However, (3) assumes
that (2) will be fully completed, i.e. that the plug will have
destroyed itself already.

However, the DeleteEvent goes through the X pipe, which is
asynchronous, as opposed through the CORBA pipe, which is
synchronous.  The problem we had in Evolution is that the request in
(2) staid in the Xlib queue for a while and (3) executed immediately
afterwards; the components died before their plugs were unrealized
because the CORBA calls in (3) told them to do so.  Since the plugs
were not unrealized, some important termination code was not being
executed and we had processes lying around.

So the basic problem is that we are assuming synchronous operations
for many things, but the X pipe is asynchronous.  We need to be very
careful in situations where termination semantics and similar things
are sent with X requests such as the DeleteEvent for plugs above.

So my hack was just to do a gdk_flush() after the default
::unrealize() handler of the EShellView is run.  This at least makes
sure that the DeleteEvent gets sent to the other side.  The race
condition is not completely fixed, but at least it is much less likely
to happen:  right now my components seem to be getting the chance to
shut down correctly.

I think part of the right solution is to put a gdk_flush() right at
the end of BonoboSocket's unrealize handler.  I am not sure what the
rest of the solution would be so that we ensure synchronization
between the CORBA and X pipes.

  Federico




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