comparison common-channel.c @ 815:35183e8a7851

Improve EOF handling for half-close. Patch from Catalin Patulea Fixes the situation $ ./dbclient [email protected] 'cat; echo foo' ^D <no output>
author Matt Johnston <matt@ucc.asn.au>
date Sat, 21 Sep 2013 00:17:22 +0800
parents 7577a3afc42d
children a1a97e98b0c1
comparison
equal deleted inserted replaced
814:bcfa7f779531 815:35183e8a7851
305 } 305 }
306 remove_channel(channel); 306 remove_channel(channel);
307 return; 307 return;
308 } 308 }
309 309
310 if (channel->recv_eof && !write_pending(channel)) { 310 if ((channel->recv_eof && !write_pending(channel))
311 /* have a server "session" and child has exited */
312 || (channel->type->check_close && close_allowed)) {
311 close_chan_fd(channel, channel->writefd, SHUT_WR); 313 close_chan_fd(channel, channel->writefd, SHUT_WR);
312 } 314 }
313 315
314 /* Special handling for flushing read data after an exit. We 316 /* Special handling for flushing read data after an exit. We
315 read regardless of whether the select FD was set, 317 read regardless of whether the select FD was set,
334 send_msg_channel_eof(channel); 336 send_msg_channel_eof(channel);
335 } 337 }
336 338
337 /* And if we can't receive any more data from them either, close up */ 339 /* And if we can't receive any more data from them either, close up */
338 if (channel->readfd == FD_CLOSED 340 if (channel->readfd == FD_CLOSED
341 && channel->writefd == FD_CLOSED
339 && (ERRFD_IS_WRITE(channel) || channel->errfd == FD_CLOSED) 342 && (ERRFD_IS_WRITE(channel) || channel->errfd == FD_CLOSED)
340 && !channel->sent_close 343 && !channel->sent_close
341 && close_allowed 344 && close_allowed
342 && !write_pending(channel)) { 345 && !write_pending(channel)) {
343 TRACE(("sending close, readfd is closed")) 346 TRACE(("sending close, readfd is closed"))