Threaded recv() Blocks Indefinitely if no Data Available
Article ID: 106479
Article Last Modified on 9/30/2003
APPLIES TO
- Microsoft LAN Manager 2.2 Standard Edition
This article was previously published under Q106479
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.
MORE INFORMATION
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: KB106479