PRB: Cannot Use dbclose() or dbexit() in an OS/2 Exit RoutineLast reviewed: April 25, 1997Article ID: Q76814 |
The information in this article applies to:
SYMPTOMSAn OS/2 application will appear to hang if dbclose() or dbexit() is placed in the OS/2 exit routine.
CAUSEWhen 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.
WORKAROUNDBecause 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |