Re: socket read() vs. recv() serialization

David S. Miller (davem@dm.cobaltmicro.com)
Wed, 23 Sep 1998 22:44:14 -0700


Date: Wed, 23 Sep 1998 19:11:53 +0200
From: Henner Eisen <eis@baty.hanse.de>

I realized that concurrent attempts to read() from a socket are
serialized by means of the socket's inode semaphore. But concurrent
calls of recv(), recvfrom(), or recvmsg() are not serialized. The
same holds for write() vs. send(), sendto(), or sendmsg().

Is this intentional or is it a bug (which might in theory cause
some trouble, i.e. when concurrent threads try to send() large
chunks to the same socket)?

Well, write() itself serializes using the main inode semaphore, check
fs/read_write.c:sys_write()

The other socket operations actually do have a serialization
mechanism, although at this time I cannot determine if it provides the
full thread synchronization you mention, and this happens via
lock_sock() in the mid-protocol layers.

Later,
David S. Miller
davem@dm.cobaltmicro.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/