Microsoft KB Archive/308270

= PRB: Server Level Post Handlers Cannot Remove Themselves with srv_post_handle =

Article ID: 308270

Article Last Modified on 10/5/2001

-

APPLIES TO


 * Microsoft SQL Server 7.0 Standard Edition

-



This article was previously published under Q308270



SYMPTOMS
The SQL Server Open Data Services (ODS) toolkit for SQL Server 7.0 allows the development of pre-event and post-event handlers.

The SRV_PROC level handlers can remove themselves whereas SERVER level handlers will result in a hang condition if they attempt to remove themselves.

For additional details, refer to the SQL Server Books Online topics &quot;srv_pre_handle&quot; and &quot;srv_post_handle&quot;.



MORE INFORMATION
A SERVER level handler is designed to be used by any SRV_PROC/SPID where a SRV_PROC level handler is limited to the current SPID.

The SRV_PROC can install an event handler that removes itself from the list of available handlers for the given SRV_PROC. For instance, this is used by SQL Server to handle sp_OA... based activities. A SRV_PROC post event handler is installed to ensure that proper cleanup of the COM objects takes place. The post handler makes sure that proper cleanup is completed and then removes itself from the list of available Post handlers for the specified SRV_PROC.

The SERVER level handler is broad in scope. When a SERVER level handler is installed, any SRV_PROC can invoke the specified handler function. This means that the function can be invoked by multiple SRV_PROCs at the same time. As with any XPROC function, it must be thread-safe; however, it must also take into account the local DLL data.

The design of SERVER-based handlers is such that it will guarantee that no thread is executing a handler when the removal of the handler occurs. Therefore, to correctly design a SERVER-level post handler you must first remove the handlers and then cleanup DLL specific data. Not doing so can lead to numerous unwanted behaviors; the most prevalent of these behaviors is error 17801 states 5 and 9.

Keywords: kbprb KB308270

-

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

© Microsoft Corporation. All rights reserved.