PRB: Cannot Use dbclose() or dbexit() in an OS/2 Exit RoutineID: Q76814
|
An OS/2 application will appear to hang if dbclose() or dbexit() is placed in the OS/2 exit routine.
When exiting an OS/2 program, all threads belonging to that application are
first closed. Then the exit routine is run in the context of the main
thread, the only remaining running thread.
When an OS/2 DB-Library (DB-Lib) program opens a connection to SQL Server
using the dbopen() function, DB-Library creates a new thread for that
application to manage the DBPROCESS connection. Thus, all DB-Library
applications are multithreaded applications, and DB-Library handles all the
multithreading automatically.
In addition, DB-Library uses semaphores to control access to the DBPROCESS
connections. Many OS/2 DB-Library functions first wait on the DBPROCESS
semaphore before proceeding, dbclose() and dbexit() among them. When this
semaphore is cleared, the DBPROCESS is available and the function can
proceed.
When exiting an OS/2 DB-Library application, all the DBPROCESS connection
threads created by DB-Library are first closed by OS/2. Then the exit
routine is run in the context of the main thread. If dbclose() or dbexit()
is run in the exit routine, it first waits on the DBPROCESS semaphore.
However, the DBPROCESS thread has already been closed by OS/2, thus the
semaphore can never be cleared. As a result, dbclose() or dbexit() will
wait forever on a semaphore that will never be cleared.
Because of the architecture of DB-Library, dbclose() or dbexit() cannot be called in an OS/2 exit routine registered with DosExitList().
Additional query words: dblib
Keywords : kbprg SSrvDB_Lib
Version : 4.2
Platform : OS/2
Issue type :
Last Reviewed: March 11, 1999