comparison common-channel.c @ 394:17d097fc111c

disapproval of revision '332f709a4cb39cde4cedab7c3be89e05f3023067'
author Matt Johnston <matt@ucc.asn.au>
date Sat, 03 Feb 2007 08:08:47 +0000
parents 8ed0dce45126
children dc37bd8563e8 a707e6148060
comparison
equal deleted inserted replaced
329:8ed0dce45126 394:17d097fc111c
201 if (channel->extrabuf == NULL && 201 if (channel->extrabuf == NULL &&
202 channel->errfd >= 0 && FD_ISSET(channel->errfd, readfds)) { 202 channel->errfd >= 0 && FD_ISSET(channel->errfd, readfds)) {
203 send_msg_channel_data(channel, 1, SSH_EXTENDED_DATA_STDERR); 203 send_msg_channel_data(channel, 1, SSH_EXTENDED_DATA_STDERR);
204 } 204 }
205 205
206 /* if we can read from the writefd, it might be closed, so we try to
207 * see if it has errors */
208 if (channel->writefd >= 0 && channel->writefd != channel->readfd
209 && FD_ISSET(channel->writefd, readfds)) {
210 if (channel->initconn) {
211 /* Handling for "in progress" connection - this is needed
212 * to avoid spinning 100% CPU when we connect to a server
213 * which doesn't send anything (tcpfwding) */
214 checkinitdone(channel);
215 continue; /* Important not to use the channel after
216 checkinitdone(), as it may be NULL */
217 }
218 ret = write(channel->writefd, NULL, 0); /* Fake write */
219 if (ret < 0 && errno != EINTR && errno != EAGAIN) {
220 closewritefd(channel);
221 }
222 }
223
224 /* write to program/pipe stdin */ 206 /* write to program/pipe stdin */
225 if (channel->writefd >= 0 && FD_ISSET(channel->writefd, writefds)) { 207 if (channel->writefd >= 0 && FD_ISSET(channel->writefd, writefds)) {
226 if (channel->initconn) { 208 if (channel->initconn) {
227 checkinitdone(channel); 209 checkinitdone(channel);
228 continue; /* Important not to use the channel after 210 continue; /* Important not to use the channel after
443 if (channel->extrabuf == NULL && channel->errfd >= 0) { 425 if (channel->extrabuf == NULL && channel->errfd >= 0) {
444 FD_SET(channel->errfd, readfds); 426 FD_SET(channel->errfd, readfds);
445 } 427 }
446 } 428 }
447 429
448 /* For checking FD status (ie closure etc) - we don't actually 430 /* Stuff from the wire */
449 * read data from writefd */
450 TRACE(("writefd = %d, readfd %d, errfd %d, bufused %d",
451 channel->writefd, channel->readfd,
452 channel->errfd,
453 cbuf_getused(channel->writebuf) ))
454 if (channel->writefd >= 0 && channel->writefd != channel->readfd) {
455 FD_SET(channel->writefd, readfds);
456 }
457
458 /* Stuff from the wire, to local program/shell/user etc */
459 if ((channel->writefd >= 0 && cbuf_getused(channel->writebuf) > 0 ) 431 if ((channel->writefd >= 0 && cbuf_getused(channel->writebuf) > 0 )
460 || channel->initconn) { 432 || channel->initconn) {
461 433
462 FD_SET(channel->writefd, writefds); 434 FD_SET(channel->writefd, writefds);
463 } 435 }