View | Details | Raw Unified | Return to bug 1467 | Differences between
and this patch

Collapse All | Expand All

(-)atomicio.c (-8 lines)
Lines 63-73 atomicio(ssize_t (*f) (int, void *, size Link Here
63
		case -1:
63
		case -1:
64
			if (errno == EINTR)
64
			if (errno == EINTR)
65
				continue;
65
				continue;
66
#ifdef EWOULDBLOCK
67
			if (errno == EAGAIN || errno == EWOULDBLOCK) {
66
			if (errno == EAGAIN || errno == EWOULDBLOCK) {
68
#else
69
			if (errno == EAGAIN) {
70
#endif
71
				(void)poll(&pfd, 1, -1);
67
				(void)poll(&pfd, 1, -1);
72
				continue;
68
				continue;
73
			}
69
			}
Lines 109-119 atomiciov(ssize_t (*f) (int, const struc Link Here
109
		case -1:
105
		case -1:
110
			if (errno == EINTR)
106
			if (errno == EINTR)
111
				continue;
107
				continue;
112
#ifdef EWOULDBLOCK
113
			if (errno == EAGAIN || errno == EWOULDBLOCK) {
108
			if (errno == EAGAIN || errno == EWOULDBLOCK) {
114
#else
115
			if (errno == EAGAIN) {
116
#endif
117
				(void)poll(&pfd, 1, -1);
109
				(void)poll(&pfd, 1, -1);
118
				continue;
110
				continue;
119
			}
111
			}
(-)channels.c (-7 / +12 lines)
Lines 1494-1500 channel_handle_rfd(Channel *c, fd_set *r Link Here
1494
	if (c->rfd != -1 && (force || FD_ISSET(c->rfd, readset))) {
1494
	if (c->rfd != -1 && (force || FD_ISSET(c->rfd, readset))) {
1495
		errno = 0;
1495
		errno = 0;
1496
		len = read(c->rfd, buf, sizeof(buf));
1496
		len = read(c->rfd, buf, sizeof(buf));
1497
		if (len < 0 && (errno == EINTR || (errno == EAGAIN && !force)))
1497
		if (len < 0 && (errno == EINTR ||
1498
		    ((errno == EAGAIN || errno == EWOULDBLOCK) && !force)))
1498
			return 1;
1499
			return 1;
1499
#ifndef PTY_ZEROREAD
1500
#ifndef PTY_ZEROREAD
1500
		if (len <= 0) {
1501
		if (len <= 0) {
Lines 1565-1571 channel_handle_wfd(Channel *c, fd_set *r Link Here
1565
			c->local_consumed += dlen + 4;
1566
			c->local_consumed += dlen + 4;
1566
			len = write(c->wfd, buf, dlen);
1567
			len = write(c->wfd, buf, dlen);
1567
			xfree(data);
1568
			xfree(data);
1568
			if (len < 0 && (errno == EINTR || errno == EAGAIN))
1569
			if (len < 0 && (errno == EINTR || errno == EAGAIN ||
1570
			    errno == EWOULDBLOCK))
1569
				return 1;
1571
				return 1;
1570
			if (len <= 0) {
1572
			if (len <= 0) {
1571
				if (c->type != SSH_CHANNEL_OPEN)
1573
				if (c->type != SSH_CHANNEL_OPEN)
Lines 1583-1589 channel_handle_wfd(Channel *c, fd_set *r Link Here
1583
#endif
1585
#endif
1584
1586
1585
		len = write(c->wfd, buf, dlen);
1587
		len = write(c->wfd, buf, dlen);
1586
		if (len < 0 && (errno == EINTR || errno == EAGAIN))
1588
		if (len < 0 &&
1589
		    (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
1587
			return 1;
1590
			return 1;
1588
		if (len <= 0) {
1591
		if (len <= 0) {
1589
			if (c->type != SSH_CHANNEL_OPEN) {
1592
			if (c->type != SSH_CHANNEL_OPEN) {
Lines 1635-1641 channel_handle_efd(Channel *c, fd_set *r Link Here
1635
			    buffer_len(&c->extended));
1638
			    buffer_len(&c->extended));
1636
			debug2("channel %d: written %d to efd %d",
1639
			debug2("channel %d: written %d to efd %d",
1637
			    c->self, len, c->efd);
1640
			    c->self, len, c->efd);
1638
			if (len < 0 && (errno == EINTR || errno == EAGAIN))
1641
			if (len < 0 && (errno == EINTR || errno == EAGAIN ||
1642
			    errno == EWOULDBLOCK))
1639
				return 1;
1643
				return 1;
1640
			if (len <= 0) {
1644
			if (len <= 0) {
1641
				debug2("channel %d: closing write-efd %d",
1645
				debug2("channel %d: closing write-efd %d",
Lines 1650-1657 channel_handle_efd(Channel *c, fd_set *r Link Here
1650
			len = read(c->efd, buf, sizeof(buf));
1654
			len = read(c->efd, buf, sizeof(buf));
1651
			debug2("channel %d: read %d from efd %d",
1655
			debug2("channel %d: read %d from efd %d",
1652
			    c->self, len, c->efd);
1656
			    c->self, len, c->efd);
1653
			if (len < 0 && (errno == EINTR ||
1657
			if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
1654
			    (errno == EAGAIN && !c->detach_close)))
1658
			    errno == EWOULDBLOCK) && !c->detach_close)))
1655
				return 1;
1659
				return 1;
1656
			if (len <= 0) {
1660
			if (len <= 0) {
1657
				debug2("channel %d: closing read-efd %d",
1661
				debug2("channel %d: closing read-efd %d",
Lines 1675-1681 channel_handle_ctl(Channel *c, fd_set *r Link Here
1675
	/* Monitor control fd to detect if the slave client exits */
1679
	/* Monitor control fd to detect if the slave client exits */
1676
	if (c->ctl_fd != -1 && FD_ISSET(c->ctl_fd, readset)) {
1680
	if (c->ctl_fd != -1 && FD_ISSET(c->ctl_fd, readset)) {
1677
		len = read(c->ctl_fd, buf, sizeof(buf));
1681
		len = read(c->ctl_fd, buf, sizeof(buf));
1678
		if (len < 0 && (errno == EINTR || errno == EAGAIN))
1682
		if (len < 0 &&
1683
		    (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
1679
			return 1;
1684
			return 1;
1680
		if (len <= 0) {
1685
		if (len <= 0) {
1681
			debug2("channel %d: ctl read<=0", c->self);
1686
			debug2("channel %d: ctl read<=0", c->self);
(-)clientloop.c (-4 / +8 lines)
Lines 663-669 client_process_net_input(fd_set *readset Link Here
663
		 * There is a kernel bug on Solaris that causes select to
663
		 * There is a kernel bug on Solaris that causes select to
664
		 * sometimes wake up even though there is no data available.
664
		 * sometimes wake up even though there is no data available.
665
		 */
665
		 */
666
		if (len < 0 && (errno == EAGAIN || errno == EINTR))
666
		if (len < 0 &&
667
		    (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
667
			len = 0;
668
			len = 0;
668
669
669
		if (len < 0) {
670
		if (len < 0) {
Lines 1129-1135 client_process_input(fd_set *readset) Link Here
1129
	if (FD_ISSET(fileno(stdin), readset)) {
1130
	if (FD_ISSET(fileno(stdin), readset)) {
1130
		/* Read as much as possible. */
1131
		/* Read as much as possible. */
1131
		len = read(fileno(stdin), buf, sizeof(buf));
1132
		len = read(fileno(stdin), buf, sizeof(buf));
1132
		if (len < 0 && (errno == EAGAIN || errno == EINTR))
1133
		if (len < 0 &&
1134
		    (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
1133
			return;		/* we'll try again later */
1135
			return;		/* we'll try again later */
1134
		if (len <= 0) {
1136
		if (len <= 0) {
1135
			/*
1137
			/*
Lines 1186-1192 client_process_output(fd_set *writeset) Link Here
1186
		len = write(fileno(stdout), buffer_ptr(&stdout_buffer),
1188
		len = write(fileno(stdout), buffer_ptr(&stdout_buffer),
1187
		    buffer_len(&stdout_buffer));
1189
		    buffer_len(&stdout_buffer));
1188
		if (len <= 0) {
1190
		if (len <= 0) {
1189
			if (errno == EINTR || errno == EAGAIN)
1191
			if (errno == EINTR || errno == EAGAIN ||
1192
			    errno == EWOULDBLOCK)
1190
				len = 0;
1193
				len = 0;
1191
			else {
1194
			else {
1192
				/*
1195
				/*
Lines 1210-1216 client_process_output(fd_set *writeset) Link Here
1210
		len = write(fileno(stderr), buffer_ptr(&stderr_buffer),
1213
		len = write(fileno(stderr), buffer_ptr(&stderr_buffer),
1211
		    buffer_len(&stderr_buffer));
1214
		    buffer_len(&stderr_buffer));
1212
		if (len <= 0) {
1215
		if (len <= 0) {
1213
			if (errno == EINTR || errno == EAGAIN)
1216
			if (errno == EINTR || errno == EAGAIN ||
1217
			    errno == EWOULDBLOCK)
1214
				len = 0;
1218
				len = 0;
1215
			else {
1219
			else {
1216
				/*
1220
				/*
(-)defines.h (+4 lines)
Lines 734-737 struct winsize { Link Here
734
# endif
734
# endif
735
#endif
735
#endif
736
736
737
#ifndef EWOULDBLOCK
738
# define EWOULDBLOCK EAGAIN
739
#endif
740
737
#endif /* _DEFINES_H */
741
#endif /* _DEFINES_H */
(-)includes.h (+2 lines)
Lines 149-154 Link Here
149
# include <sys/syslog.h>
149
# include <sys/syslog.h>
150
#endif
150
#endif
151
151
152
#include <errno.h>
153
152
/*
154
/*
153
 * On HP-UX 11.11, shadow.h and prot.h provide conflicting declarations
155
 * On HP-UX 11.11, shadow.h and prot.h provide conflicting declarations
154
 * of getspnam when _INCLUDE__STDC__ is defined, so we unset it here.
156
 * of getspnam when _INCLUDE__STDC__ is defined, so we unset it here.
(-)packet.c (-3 / +5 lines)
Lines 956-962 packet_read_seqnr(u_int32_t *seqnr_p) Link Here
956
			if ((ret = select(connection_in + 1, setp, NULL,
956
			if ((ret = select(connection_in + 1, setp, NULL,
957
			    NULL, timeoutp)) >= 0)
957
			    NULL, timeoutp)) >= 0)
958
				break;
958
				break;
959
		   	if (errno != EAGAIN && errno != EINTR)
959
		   	if (errno != EAGAIN && errno != EINTR &&
960
			    errno != EWOULDBLOCK)
960
				break;
961
				break;
961
			if (packet_timeout_ms == -1)
962
			if (packet_timeout_ms == -1)
962
				continue;
963
				continue;
Lines 1475-1481 packet_write_poll(void) Link Here
1475
	if (len > 0) {
1476
	if (len > 0) {
1476
		len = write(connection_out, buffer_ptr(&output), len);
1477
		len = write(connection_out, buffer_ptr(&output), len);
1477
		if (len <= 0) {
1478
		if (len <= 0) {
1478
			if (errno == EAGAIN)
1479
			if (errno == EAGAIN || errno == EWOULDBLOCK)
1479
				return;
1480
				return;
1480
			else
1481
			else
1481
				fatal("Write failed: %.100s", strerror(errno));
1482
				fatal("Write failed: %.100s", strerror(errno));
Lines 1516-1522 packet_write_wait(void) Link Here
1516
			if ((ret = select(connection_out + 1, NULL, setp,
1517
			if ((ret = select(connection_out + 1, NULL, setp,
1517
			    NULL, timeoutp)) >= 0)
1518
			    NULL, timeoutp)) >= 0)
1518
				break;
1519
				break;
1519
		   	if (errno != EAGAIN && errno != EINTR)
1520
		   	if (errno != EAGAIN && errno != EINTR &&
1521
			    errno != EWOULDBLOCK)
1520
				break;
1522
				break;
1521
			if (packet_timeout_ms == -1)
1523
			if (packet_timeout_ms == -1)
1522
				continue;
1524
				continue;
(-)scp.c (-1 / +1 lines)
Lines 474-480 scpio(ssize_t (*f)(int, void *, size_t), Link Here
474
		if (r < 0) {
474
		if (r < 0) {
475
			if (errno == EINTR)
475
			if (errno == EINTR)
476
				continue;
476
				continue;
477
			if (errno == EAGAIN) {
477
			if (errno == EAGAIN || errno == EWOULDBLOCK) {
478
				(void)poll(&pfd, 1, -1); /* Ignore errors */
478
				(void)poll(&pfd, 1, -1); /* Ignore errors */
479
				continue;
479
				continue;
480
			}
480
			}
(-)serverloop.c (-6 / +8 lines)
Lines 400-406 process_input(fd_set *readset) Link Here
400
				return;
400
				return;
401
			cleanup_exit(255);
401
			cleanup_exit(255);
402
		} else if (len < 0) {
402
		} else if (len < 0) {
403
			if (errno != EINTR && errno != EAGAIN) {
403
			if (errno != EINTR && errno != EAGAIN &&
404
			    errno != EWOULDBLOCK) {
404
				verbose("Read error from remote host "
405
				verbose("Read error from remote host "
405
				    "%.100s: %.100s",
406
				    "%.100s: %.100s",
406
				    get_remote_ipaddr(), strerror(errno));
407
				    get_remote_ipaddr(), strerror(errno));
Lines 418-425 process_input(fd_set *readset) Link Here
418
	if (!fdout_eof && FD_ISSET(fdout, readset)) {
419
	if (!fdout_eof && FD_ISSET(fdout, readset)) {
419
		errno = 0;
420
		errno = 0;
420
		len = read(fdout, buf, sizeof(buf));
421
		len = read(fdout, buf, sizeof(buf));
421
		if (len < 0 && (errno == EINTR ||
422
		if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
422
		    (errno == EAGAIN && !child_terminated))) {
423
		    errno == EWOULDBLOCK) && !child_terminated))) {
423
			/* do nothing */
424
			/* do nothing */
424
#ifndef PTY_ZEROREAD
425
#ifndef PTY_ZEROREAD
425
		} else if (len <= 0) {
426
		} else if (len <= 0) {
Lines 437-444 process_input(fd_set *readset) Link Here
437
	if (!fderr_eof && FD_ISSET(fderr, readset)) {
438
	if (!fderr_eof && FD_ISSET(fderr, readset)) {
438
		errno = 0;
439
		errno = 0;
439
		len = read(fderr, buf, sizeof(buf));
440
		len = read(fderr, buf, sizeof(buf));
440
		if (len < 0 && (errno == EINTR ||
441
		if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
441
		    (errno == EAGAIN && !child_terminated))) {
442
		    errno == EWOULDBLOCK) && !child_terminated))) {
442
			/* do nothing */
443
			/* do nothing */
443
#ifndef PTY_ZEROREAD
444
#ifndef PTY_ZEROREAD
444
		} else if (len <= 0) {
445
		} else if (len <= 0) {
Lines 469-475 process_output(fd_set *writeset) Link Here
469
		data = buffer_ptr(&stdin_buffer);
470
		data = buffer_ptr(&stdin_buffer);
470
		dlen = buffer_len(&stdin_buffer);
471
		dlen = buffer_len(&stdin_buffer);
471
		len = write(fdin, data, dlen);
472
		len = write(fdin, data, dlen);
472
		if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
473
		if (len < 0 &&
474
		    (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) {
473
			/* do nothing */
475
			/* do nothing */
474
		} else if (len <= 0) {
476
		} else if (len <= 0) {
475
			if (fdin != fdout)
477
			if (fdin != fdout)
(-)sftp-client.c (-1 / +2 lines)
Lines 1223-1229 do_upload(struct sftp_conn *conn, char * Link Here
1223
			len = 0;
1223
			len = 0;
1224
		else do
1224
		else do
1225
			len = read(local_fd, data, conn->transfer_buflen);
1225
			len = read(local_fd, data, conn->transfer_buflen);
1226
		while ((len == -1) && (errno == EINTR || errno == EAGAIN));
1226
		while ((len == -1) &&
1227
		    (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
1227
1228
1228
		if (len == -1)
1229
		if (len == -1)
1229
			fatal("Couldn't read from \"%s\": %s", local_path,
1230
			fatal("Couldn't read from \"%s\": %s", local_path,
(-)ssh-agent.c (-2 / +4 lines)
Lines 961-967 after_select(fd_set *readset, fd_set *wr Link Here
961
					    buffer_ptr(&sockets[i].output),
961
					    buffer_ptr(&sockets[i].output),
962
					    buffer_len(&sockets[i].output));
962
					    buffer_len(&sockets[i].output));
963
					if (len == -1 && (errno == EAGAIN ||
963
					if (len == -1 && (errno == EAGAIN ||
964
					    errno == EINTR))
964
					    errno == EINTR ||
965
					    errno == EWOULDBLOCK))
965
						continue;
966
						continue;
966
					break;
967
					break;
967
				} while (1);
968
				} while (1);
Lines 975-981 after_select(fd_set *readset, fd_set *wr Link Here
975
				do {
976
				do {
976
					len = read(sockets[i].fd, buf, sizeof(buf));
977
					len = read(sockets[i].fd, buf, sizeof(buf));
977
					if (len == -1 && (errno == EAGAIN ||
978
					if (len == -1 && (errno == EAGAIN ||
978
					    errno == EINTR))
979
					    errno == EINTR ||
980
					    errno == EWOULDBLOCK))
979
						continue;
981
						continue;
980
					break;
982
					break;
981
				} while (1);
983
				} while (1);
(-)ssh-keyscan.c (-1 / +1 lines)
Lines 656-662 conloop(void) Link Here
656
	memcpy(e, read_wait, read_wait_nfdset * sizeof(fd_mask));
656
	memcpy(e, read_wait, read_wait_nfdset * sizeof(fd_mask));
657
657
658
	while (select(maxfd, r, NULL, e, &seltime) == -1 &&
658
	while (select(maxfd, r, NULL, e, &seltime) == -1 &&
659
	    (errno == EAGAIN || errno == EINTR))
659
	    (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
660
		;
660
		;
661
661
662
	for (i = 0; i < maxfd; i++) {
662
	for (i = 0; i < maxfd; i++) {
(-)sshd.c (-1 / +2 lines)
Lines 1096-1102 server_accept_loop(int *sock_in, int *so Link Here
1096
			*newsock = accept(listen_socks[i],
1096
			*newsock = accept(listen_socks[i],
1097
			    (struct sockaddr *)&from, &fromlen);
1097
			    (struct sockaddr *)&from, &fromlen);
1098
			if (*newsock < 0) {
1098
			if (*newsock < 0) {
1099
				if (errno != EINTR && errno != EWOULDBLOCK)
1099
				if (errno != EINTR && errno != EAGAIN &&
1100
				    errno != EWOULDBLOCK)
1100
					error("accept: %.100s", strerror(errno));
1101
					error("accept: %.100s", strerror(errno));
1101
				continue;
1102
				continue;
1102
			}
1103
			}

Return to bug 1467