Threaded recv() Blocks Indefinitely if no Data Available

ID: Q106479


The information in this article applies to:
  • Microsoft LAN Manager, version 2.2


SYMPTOMS

The LAN Manager 2.2 SOCKDRV.OS2 sockets call recv() will block indefinitely if data is not available in the receive window when called from a separate thread.


CAUSE

Socket data structures are allocated on a per-process basis. When the first thread calls recv() and blocks, flags are set to indicate this. When the second thread calls send() the socket's flags are reset, losing the state information on the blocked recv. This is a classic case of one thread stomping on another by means of the shared data segment.


STATUS

This behavior is by design. The problem is avoided if multi-threaded applications send() and recv() on separate sockets.


STEPS TO DUPLICATE CONDITION

If you want to demonstrate this problem, write an application that calls a thread that issues a recv() and then sends data to itself on the same socket.

Additional query words: 2.20

Keywords :
Version : :2.2
Platform :
Issue type :


Last Reviewed: November 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.