Problem:
In a distributed system, an improper implementation of callback might cause deadlock (i.e. distributed deadlock). For instance, a single-threaded client with a callback object makes an invocation on a CORBA object in a server (server is single-threaded as well). Due to single thread of client, there will be an event loop at client. When the invocation made on server’s CORBA object, the server calls back on the client CORBA’s object while processing this invocation. In normal circumstance, synchronous mode is on and the server blocked until a reply from client comes back. However it will never happen as the client is blocked, waiting for reply from server. The deadlock occurs.
Resolution:
To avoid the deadlock happening in CORBA applications due to callbacks, there are 2 common ways to implement:
1. Client is single-threaded: IDL defines a “oneway” operation to an invocation with expectation of no reply. By applying this operation on the callback object in IDL, the callback invocation will returns immediately without waiting for reply from client, so the deadlock is avoided.
2. Client is multi-threaded: An implementation of separate thread for processing invocations in the clients will surely avoid the deadlock.
In addition, the use of ORB_CTRL_MODEL multi-threading policy also helps to protect the client from deadlock where the ORB is responsible for assigning requests for an ORB-controlled POA to threads.
Note: There are also limitations when using “oneway” operation:
-
“oneway” operation must have void return type and 1 in-parameter
-
Neither user exception nor system exception handled.
#VisiBroker
#Security
#deadlock
#callback
#oneway