[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Nbd] NBD server terminates on SIGPIPE during negotiation



Wouter,

On 5 Feb 2013, at 21:37, Wouter Verhelst wrote:

>> #1 Set the default action of SIGPIPE to Ign.
>> 
>> This is simplest to do, but not the right thing in my opinion.
> 
> It feels utterly wrong to me. If the client isn't talking to us anymore,
> we need to stop, not try to continue. Doing otherwise could cause
> different issues down the road; I don't want to go there.

Why do you think ignoring SIGPIPE is wrong? Provided you catch the
condition in your select loop, you can tell when the client is not
talking to you any more.

I haven't got my copy of Stephens in front of me, but I am pretty
sure it's the way he recommends doing things where there is more than
one non-blocking fd open, or you have anything else that might cause
a SIGPIPE.

And if we are not catching this sort of thing in our select loop,
that seems to me exactly the sort of thing that causes other
problems. What I mean by this is that SIGPIPE is always generated
on a write to a pipe (or socket) with no readers. In general
nbd is waiting to read, rather than to write. So we need to
reliably catch the case of a client disconnecting when we are trying
to read anyway. Writes to an fd which has already generated
an ignored SIGPIPE will always error, and we need to cope with
write errors anyway (SIGPIPE or no SIGPIPE).

-- 
Alex Bligh







Reply to: