From: Mike Stroyan <mike.stroyan@hp.com>
To: Mark A Smith <mark1smi@us.ibm.com>
Cc: Rick Jones <rick.jones2@hp.com>,
Linux Network Development list <netdev@vger.kernel.org>,
shemminger@osdl.org
Subject: Re: send(), sendmsg(), sendto() not thread-safe
Date: Tue, 16 May 2006 10:24:46 -0600 [thread overview]
Message-ID: <20060516162446.GA26068@ldl.lart> (raw)
In-Reply-To: <OF4D94549F.7BBB070C-ON85257170.0009219D-88257170.000A05E8@us.ibm.com>
On Mon, May 15, 2006 at 06:50:36PM -0700, Mark A Smith wrote:
>
> I cannot think of another possible definition for thread-safe in the
> context of these functions. Certainly they should not cause a "crash" when
> called from multiple threads, but that's a requirement independent of
> thread-safety.
...
> I think the question really boils down to: "What does thread-safe mean with
> respect to send()?" It might be more easily answered by asking, "How would
> a non-thread-safe send() behave?" I think it would behave the way we're
> seeing it behave.
A non-thread-safe send() could use a global buffer to hold copied
data or results. When called from multiple threads it could lose data
or mix data from send()s to different sockets. Or it could return a
result in one thread that reflects the result of an overlapping send()
in another thread. Or it could sometimes core dump. The behavior of
a non-thread-safe function called from multiple threads is undefined.
There is really no requirement "independent of thread-safety" on the
behavior of a function called from multiple unsyncronized threads.
As Rick noted, this is not really a threading test but a multiprocess
test. A requirement to be thread-safe shouldn't imply anything about
the behavior of functions in single-threaded processes. The posix
standard has a limit of PIPE_BUF bytes for atomic writes to a pipe.
That might extend to expecting sends of under PIPE_BUF bytes to be atomic
on a socket. But I don't actually find any guarantee of atomic writes
for sockets, even for sizes below PIPE_BUF.
--
Mike Stroyan, mike.stroyan@hp.com
next prev parent reply other threads:[~2006-05-16 16:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <OFA7F8723C.2DDF9383-ON85257170.00014BE5-88257170.00019BEA@us.ibm.com>
2006-05-16 0:43 ` send(), sendmsg(), sendto() not thread-safe Rick Jones
2006-05-16 1:50 ` Mark A Smith
2006-05-16 16:24 ` Mike Stroyan [this message]
2006-05-17 17:25 Benjamin Reed
2006-05-17 18:00 ` Christopher Friesen
2006-05-17 18:21 ` Benjamin Reed
2006-05-17 18:52 ` Rick Jones
2006-05-17 19:06 ` Benjamin Reed
-- strict thread matches above, loose matches on Subject: below --
2006-05-15 21:39 Mark A Smith
2006-05-15 22:24 ` H. Peter Anvin
2006-05-15 22:49 ` David S. Miller
2006-05-15 23:17 ` Rick Jones
2006-05-15 23:35 ` Stephen Hemminger
2006-05-16 0:02 ` Rick Jones
2006-05-16 2:47 ` David Schwartz
2006-05-16 20:09 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060516162446.GA26068@ldl.lart \
--to=mike.stroyan@hp.com \
--cc=mark1smi@us.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=rick.jones2@hp.com \
--cc=shemminger@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.