Re: Writing on a common socket from multiple threads
Re: Writing on a common socket from multiple threads
- Subject: Re: Writing on a common socket from multiple threads
- From: Josh Graessley <email@hidden>
- Date: Wed, 01 Jun 2011 16:50:03 -0700
On Jun 1, 2011, at 4:42 PM, Nathan Sims wrote:
> On Jun 1, 2011, at 4:29 PM, Quinn The Eskimo! wrote:
>>
>> On 1 Jun 2011, at 15:49, Nathan Sims wrote:
>>
>>> Does this mean that I can only make writev() calls on a common socket from a single thread, or is there some other issue at play?
>>
>> My guess is that something else is at play here. Sockets are thread-safe at this level, even without your spin lock. That said, there are many other ways to die with an architecture like this.
>
> Hmm, well it's 100% repeatable. I was about to funnel everything through a single common thread, but if sockets are already thread-safe, then there's no need. What are some of the 'other ways to die' that result in a broken pipe error?
A broken pipe error in response to a send/write usually means the send side is closed. This can occur if shutdown is called or if the server closes the connection. One common problem with writing on a single socket from multiple threads is interleaved data. If thread 1 writes a header with the length and type of payload, then thread 2 writes a similar header and thread 1 then writes the payload, the data stream is messed up. The server may detect the problem and disconnect. If your spin lock is there to ensure that each thread writes both the header and the payload before releasing the lock, then this probably isn't the problem you're encountering.
-josh
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden