netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: send(), sendmsg(), sendto() not thread-safe
@ 2006-05-17 17:25 Benjamin Reed
  2006-05-17 18:00 ` Christopher Friesen
  0 siblings, 1 reply; 12+ messages in thread
From: Benjamin Reed @ 2006-05-17 17:25 UTC (permalink / raw)
  To: netdev

David et al, I think you may be missing the point. 

David S. Miller wrote:
> I don't understand why the desire is so high to
> ensure that individual threads get "atomic" writes,
> you can't even ensure that in the general case.

I think Mark's point isn't about "atomic" writes;
instead, he was pointing out that when a programmer
reads that a call is thread-safe he usually
understands that to mean that it does not need to be
protected by a lock when used by multiple threads.

With the current implementation of sendmsg it takes
some imagination to come up with scenario where it is
okay for concurrent sendmsg calls to mix their data.

> Only sloppy programs that don't do their own
internal
> locking hit into issues in this area.

You are looking at it backwards. If sendmsg were
indeed
thread-safe (two concurrent calls to sendmsg would not
mix their data), then it would be stupid for a
programmer to put a lock around the sendmsg call. It
would also be stupid for a programmer to protect a
call to socket() with a lock.

This thread-safe issue is an even bigger deal when you
are sharing the socket amoung many independent
processes since locking in that context is a bit
harder and more inefficient than in a pthread context.

So, if it isn't going to be "fixed". It would be nice
to at least document the issue. A cursory examination
of the sendmsg kernel code leads you to believe that
it is thread-safe in the sense that Mark is talking
about.

ben

^ permalink raw reply	[flat|nested] 12+ messages in thread
[parent not found: <OFE8460E54.0C8D85D8-ON8525716F.0074F22F-8825716F.0076D537@us.ibm.com>]

end of thread, other threads:[~2006-05-17 19:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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
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
     [not found] <OFE8460E54.0C8D85D8-ON8525716F.0074F22F-8825716F.0076D537@us.ibm.com>
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).