Microsoft KB Archive/192127

From BetaArchive Wiki

FIX: RpcTestCancel() Always Returns Error Code 5

Q192127



The information in this article applies to:


  • Microsoft Windows NT Server version 4.0
  • Microsoft Windows NT Workstation version 4.0
  • Microsoft Windows NT Server version 4.0, Terminal Server Edition





SYMPTOMS

Your RPC server manager routine makes a RpcTestCancel() call to test if the current RPC call has been cancelled by the remote RPC client. However, this call always returns error code 5.



RESOLUTION

To resolve this problem, obtain the latest service pack for Windows NT 4.0 or Windows NT Server 4.0, Terminal Server Edition. For additional information, please see the following article in the Microsoft Knowledge Base:

Q152734 How to Obtain the Latest Windows NT 4.0 Service Pack





STATUS

Microsoft has confirmed this to be a problem in Windows NT 4.0 and Windows NT Server 4.0, Terminal Server Edition. This problem was first corrected in Windows NT 4.0 Service Pack 4.0 and Windows NT Server 4.0, Terminal Server Edition Service Pack 4.



MORE INFORMATION

Under Windows NT version 4.0 Service Pack 3 and previous Service Packs, when an RPC client issues a cancel then the client is unblocked. However, the server never notices the cancel. If the client is using an infinite timeout, the client does not unblock unless the server finishes or fails the call.

On Windows NT version 4.0, you need to do the following to cancel an RPC remote call:


  1. Use connection-oriented protocols, such as ncacn_ip_tcp, for communication between your RPC client and server.
  2. In the client-side main thread start another call thread to make the actual RPC call. For example: CallThread = (void *) _beginthreadex(...);
  3. The call thread issues RpcMgmtSetCancelTimeout(0), where 0 indicates that you do not want to wait for the RPC server to acknowledge the cancel (the call is immediately abandoned upon a cancel). Next, your call thread makes the actual RPC call.
  4. In the main thread, you can either call Sleep() to sleep for sometime or wait until the timeout expired and issue RpcCancelThread() to cancel the call if it timeouts. For example: rc = WaitForSingleObject(CallThread, 5000); if (WAIT_TIMEOUT == rc) { status = RpcCancelThread(CallThread); . . .
  5. In your RPC server-side manager routine, you need to test if the current RPC call has been cancelled by calling RpcTestCancel(). However, RpcTestCancel() always returns error code 5, even if the cancel packet has been received by the RPC server runtime.

Additional query words: RpcTestCancel RpcMgmtSetCancelTimeout Timeout

Keywords : kbnetwork kbWinNT400sp4fix kbRPC kbSDKPlatform kbGrpDSNet
Issue type : kbbug
Technology : kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT400xsearch kbWinNTSsearch kbWinNTS400xsearch kbWinNTS400 kbNTTermServ400 kbNTTermServSearch


Last Reviewed: February 10, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.