Microsoft KB Archive/76814

= PRB: Cannot Use dbclose or dbexit in an OS/2 Exit Routine =

Article ID: 76814

Article Last Modified on 2/14/2005

-

APPLIES TO


 * Microsoft SQL Server 4.21a Standard Edition
 * Microsoft SQL Server 6.5 Standard Edition

-



This article was previously published under Q76814



SYMPTOMS
An OS/2 application will appear to hang if dbclose or dbexit is placed in the OS/2 exit routine.



CAUSE
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.



WORKAROUND
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: kbprogramming KB76814

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.