RSC/MP 7.2 Programming Manual
Application Design
HP NonStop Remote Server Call (RSC/MP) Programming Manual—522360-004
5-2
Resource Sharing Between Threads
not provide this mutual exclusion scheme might appear to function correctly, but will be
prone to unexpected results that are difficult to diagnose.
Resource Sharing Between Threads
Connection, session, and I/O handles can be shared between registered threads. In
general, the application program must ensure that the use of shared resources is
coordinated properly. Be aware that sharing handles, especially I/O, can lead to these
application design problems which cannot be caught by the RSC/MP library:
•
Multiple threads share one RscConnect handle. One thread issues an RscConnect
call, and other threads attempt to use the connect handle before the call has
completed in the thread making the RscConnect call. This situation returns the
error RSC_INVALID_CONNECTION_HANDLE. To correct this situation, issue the
RscConnect in the main thread before beginning the other threads, or make each
thread issue its own RscConnect call.
•
Two or more threads simultaneously attempt an IoCheck on the same I/O. One will
succeed, the rest will return an error RSC_NO_IO_PENDING.
•
Two threads sharing a session handle attempt to start a transaction (explicit or
implicit). One will fail. A session can have only one transaction outstanding at a
time.
When RscDisconnect is called on a connection, the connection is immediately
terminated, even if it is in use by other threads. Other threads awaiting completion of
an RSC/MP operation on that connection will return errors. Subsequent attempts to
use that connection return the error INVALID_CONNECTION_HANDLE.
Essentially, an RscDisconnect is performed internally on each connection the thread
called RscConnect for. This disconnect occurs even if the connection is being used by
other threads. Connections that were used but not created by the thread are left
untouched. However, applications should not rely on RscUnregisterThread to perform
disconnects on outstanding connections; RscDisconnect should be called on each
RSC/MP connection the thread created prior to RscUnregisterThread calls or upon
exiting the application.
Note. Any active connections by a registered thread will be implicitly disconnected when the
thread unregisters.