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

Collapse All | Expand All

(-)atomicio.c (-8 lines)
Lines 63-73 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 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 1497-1503 Link Here
1497
	if (c->rfd != -1 && (force || FD_ISSET(c->rfd, readset))) {
1497
	if (c->rfd != -1 && (force || FD_ISSET(c->rfd, readset))) {
1498
		errno = 0;
1498
		errno = 0;
1499
		len = read(c->rfd, buf, sizeof(buf));
1499
		len = read(c->rfd, buf, sizeof(buf));
1500
		if (len < 0 && (errno == EINTR || (errno == EAGAIN && !force)))
1500
		if (len < 0 && (errno == EINTR ||
1501
		    ((errno == EAGAIN || errno == EWOULDBLOCK) && !force)))
1501
			return 1;
1502
			return 1;
1502
#ifndef PTY_ZEROREAD
1503
#ifndef PTY_ZEROREAD
1503
		if (len <= 0) {
1504
		if (len <= 0) {
Lines 1568-1574 Link Here
1568
			c->local_consumed += dlen + 4;
1569
			c->local_consumed += dlen + 4;
1569
			len = write(c->wfd, buf, dlen);
1570
			len = write(c->wfd, buf, dlen);
1570
			xfree(data);
1571
			xfree(data);
1571
			if (len < 0 && (errno == EINTR || errno == EAGAIN))
1572
			if (len < 0 && (errno == EINTR || errno == EAGAIN ||
1573
			    errno == EWOULDBLOCK))
1572
				return 1;
1574
				return 1;
1573
			if (len <= 0) {
1575
			if (len <= 0) {
1574
				if (c->type != SSH_CHANNEL_OPEN)
1576
				if (c->type != SSH_CHANNEL_OPEN)
Lines 1586-1592 Link Here
1586
#endif
1588
#endif
1587
1589
1588
		len = write(c->wfd, buf, dlen);
1590
		len = write(c->wfd, buf, dlen);
1589
		if (len < 0 && (errno == EINTR || errno == EAGAIN))
1591
		if (len < 0 &&
1592
		    (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
1590
			return 1;
1593
			return 1;
1591
		if (len <= 0) {
1594
		if (len <= 0) {
1592
			if (c->type != SSH_CHANNEL_OPEN) {
1595
			if (c->type != SSH_CHANNEL_OPEN) {
Lines 1638-1644 Link Here
1638
			    buffer_len(&c->extended));
1641
			    buffer_len(&c->extended));
1639
			debug2("channel %d: written %d to efd %d",
1642
			debug2("channel %d: written %d to efd %d",
1640
			    c->self, len, c->efd);
1643
			    c->self, len, c->efd);
1641
			if (len < 0 && (errno == EINTR || errno == EAGAIN))
1644
			if (len < 0 && (errno == EINTR || errno == EAGAIN ||
1645
			    errno == EWOULDBLOCK))
1642
				return 1;
1646
				return 1;
1643
			if (len <= 0) {
1647
			if (len <= 0) {
1644
				debug2("channel %d: closing write-efd %d",
1648
				debug2("channel %d: closing write-efd %d",
Lines 1653-1660 Link Here
1653
			len = read(c->efd, buf, sizeof(buf));
1657
			len = read(c->efd, buf, sizeof(buf));
1654
			debug2("channel %d: read %d from efd %d",
1658
			debug2("channel %d: read %d from efd %d",
1655
			    c->self, len, c->efd);
1659
			    c->self, len, c->efd);
1656
			if (len < 0 && (errno == EINTR ||
1660
			if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
1657
			    (errno == EAGAIN && !c->detach_close)))
1661
			    errno == EWOULDBLOCK) && !c->detach_close)))
1658
				return 1;
1662
				return 1;
1659
			if (len <= 0) {
1663
			if (len <= 0) {
1660
				debug2("channel %d: closing read-efd %d",
1664
				debug2("channel %d: closing read-efd %d",
Lines 1678-1684 Link Here
1678
	/* Monitor control fd to detect if the slave client exits */
1682
	/* Monitor control fd to detect if the slave client exits */
1679
	if (c->ctl_fd != -1 && FD_ISSET(c->ctl_fd, readset)) {
1683
	if (c->ctl_fd != -1 && FD_ISSET(c->ctl_fd, readset)) {
1680
		len = read(c->ctl_fd, buf, sizeof(buf));
1684
		len = read(c->ctl_fd, buf, sizeof(buf));
1681
		if (len < 0 && (errno == EINTR || errno == EAGAIN))
1685
		if (len < 0 &&
1686
		    (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
1682
			return 1;
1687
			return 1;
1683
		if (len <= 0) {
1688
		if (len <= 0) {
1684
			debug2("channel %d: ctl read<=0", c->self);
1689
			debug2("channel %d: ctl read<=0", c->self);
(-)clientloop.c (-4 / +8 lines)
Lines 623-629 Link Here
623
		 * There is a kernel bug on Solaris that causes select to
623
		 * There is a kernel bug on Solaris that causes select to
624
		 * sometimes wake up even though there is no data available.
624
		 * sometimes wake up even though there is no data available.
625
		 */
625
		 */
626
		if (len < 0 && (errno == EAGAIN || errno == EINTR))
626
		if (len < 0 &&
627
		    (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
627
			len = 0;
628
			len = 0;
628
629
629
		if (len < 0) {
630
		if (len < 0) {
Lines 1001-1007 Link Here
1001
	if (FD_ISSET(fileno(stdin), readset)) {
1002
	if (FD_ISSET(fileno(stdin), readset)) {
1002
		/* Read as much as possible. */
1003
		/* Read as much as possible. */
1003
		len = read(fileno(stdin), buf, sizeof(buf));
1004
		len = read(fileno(stdin), buf, sizeof(buf));
1004
		if (len < 0 && (errno == EAGAIN || errno == EINTR))
1005
		if (len < 0 &&
1006
		    (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
1005
			return;		/* we'll try again later */
1007
			return;		/* we'll try again later */
1006
		if (len <= 0) {
1008
		if (len <= 0) {
1007
			/*
1009
			/*
Lines 1056-1062 Link Here
1056
		len = write(fileno(stdout), buffer_ptr(&stdout_buffer),
1058
		len = write(fileno(stdout), buffer_ptr(&stdout_buffer),
1057
		    buffer_len(&stdout_buffer));
1059
		    buffer_len(&stdout_buffer));
1058
		if (len <= 0) {
1060
		if (len <= 0) {
1059
			if (errno == EINTR || errno == EAGAIN)
1061
			if (errno == EINTR || errno == EAGAIN ||
1062
			    errno == EWOULDBLOCK)
1060
				len = 0;
1063
				len = 0;
1061
			else {
1064
			else {
1062
				/*
1065
				/*
Lines 1079-1085 Link Here
1079
		len = write(fileno(stderr), buffer_ptr(&stderr_buffer),
1082
		len = write(fileno(stderr), buffer_ptr(&stderr_buffer),
1080
		    buffer_len(&stderr_buffer));
1083
		    buffer_len(&stderr_buffer));
1081
		if (len <= 0) {
1084
		if (len <= 0) {
1082
			if (errno == EINTR || errno == EAGAIN)
1085
			if (errno == EINTR || errno == EAGAIN ||
1086
			    errno == EWOULDBLOCK)
1083
				len = 0;
1087
				len = 0;
1084
			else {
1088
			else {
1085
				/* EOF or error, but can't even print error message. */
1089
				/* EOF or error, but can't even print error message. */
(-)defines.h (+4 lines)
Lines 729-732 Link Here
729
# endif
729
# endif
730
#endif
730
#endif
731
731
732
#ifndef EWOULDBLOCK
733
# define EWOULDBLOCK EAGAIN
734
#endif
735
732
#endif /* _DEFINES_H */
736
#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 / +3 lines)
Lines 927-933 Link Here
927
927
928
		/* Wait for some data to arrive. */
928
		/* Wait for some data to arrive. */
929
		while (select(connection_in + 1, setp, NULL, NULL, NULL) == -1 &&
929
		while (select(connection_in + 1, setp, NULL, NULL, NULL) == -1 &&
930
		    (errno == EAGAIN || errno == EINTR))
930
		    (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
931
			;
931
			;
932
932
933
		/* Read data from the socket. */
933
		/* Read data from the socket. */
Lines 1433-1439 Link Here
1433
	if (len > 0) {
1433
	if (len > 0) {
1434
		len = write(connection_out, buffer_ptr(&output), len);
1434
		len = write(connection_out, buffer_ptr(&output), len);
1435
		if (len <= 0) {
1435
		if (len <= 0) {
1436
			if (errno == EAGAIN)
1436
			if (errno == EAGAIN || errno == EWOULDBLOCK)
1437
				return;
1437
				return;
1438
			else
1438
			else
1439
				fatal("Write failed: %.100s", strerror(errno));
1439
				fatal("Write failed: %.100s", strerror(errno));
Lines 1460-1466 Link Here
1460
		    sizeof(fd_mask));
1460
		    sizeof(fd_mask));
1461
		FD_SET(connection_out, setp);
1461
		FD_SET(connection_out, setp);
1462
		while (select(connection_out + 1, NULL, setp, NULL, NULL) == -1 &&
1462
		while (select(connection_out + 1, NULL, setp, NULL, NULL) == -1 &&
1463
		    (errno == EAGAIN || errno == EINTR))
1463
		    (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
1464
			;
1464
			;
1465
		packet_write_poll();
1465
		packet_write_poll();
1466
	}
1466
	}
(-)scp.c (-1 / +1 lines)
Lines 474-480 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 399-405 Link Here
399
				return;
399
				return;
400
			cleanup_exit(255);
400
			cleanup_exit(255);
401
		} else if (len < 0) {
401
		} else if (len < 0) {
402
			if (errno != EINTR && errno != EAGAIN) {
402
			if (errno != EINTR && errno != EAGAIN &&
403
			    errno != EWOULDBLOCK) {
403
				verbose("Read error from remote host "
404
				verbose("Read error from remote host "
404
				    "%.100s: %.100s",
405
				    "%.100s: %.100s",
405
				    get_remote_ipaddr(), strerror(errno));
406
				    get_remote_ipaddr(), strerror(errno));
Lines 417-424 Link Here
417
	if (!fdout_eof && FD_ISSET(fdout, readset)) {
418
	if (!fdout_eof && FD_ISSET(fdout, readset)) {
418
		errno = 0;
419
		errno = 0;
419
		len = read(fdout, buf, sizeof(buf));
420
		len = read(fdout, buf, sizeof(buf));
420
		if (len < 0 && (errno == EINTR ||
421
		if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
421
		    (errno == EAGAIN && !child_terminated))) {
422
		    errno == EWOULDBLOCK) && !child_terminated))) {
422
			/* do nothing */
423
			/* do nothing */
423
#ifndef PTY_ZEROREAD
424
#ifndef PTY_ZEROREAD
424
		} else if (len <= 0) {
425
		} else if (len <= 0) {
Lines 436-443 Link Here
436
	if (!fderr_eof && FD_ISSET(fderr, readset)) {
437
	if (!fderr_eof && FD_ISSET(fderr, readset)) {
437
		errno = 0;
438
		errno = 0;
438
		len = read(fderr, buf, sizeof(buf));
439
		len = read(fderr, buf, sizeof(buf));
439
		if (len < 0 && (errno == EINTR ||
440
		if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
440
		    (errno == EAGAIN && !child_terminated))) {
441
		    errno == EWOULDBLOCK) && !child_terminated))) {
441
			/* do nothing */
442
			/* do nothing */
442
#ifndef PTY_ZEROREAD
443
#ifndef PTY_ZEROREAD
443
		} else if (len <= 0) {
444
		} else if (len <= 0) {
Lines 468-474 Link Here
468
		data = buffer_ptr(&stdin_buffer);
469
		data = buffer_ptr(&stdin_buffer);
469
		dlen = buffer_len(&stdin_buffer);
470
		dlen = buffer_len(&stdin_buffer);
470
		len = write(fdin, data, dlen);
471
		len = write(fdin, data, dlen);
471
		if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
472
		if (len < 0 &&
473
		    (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) {
472
			/* do nothing */
474
			/* do nothing */
473
		} else if (len <= 0) {
475
		} else if (len <= 0) {
474
			if (fdin != fdout)
476
			if (fdin != fdout)
(-)sftp-client.c (-1 / +2 lines)
Lines 1210-1216 Link Here
1210
			len = 0;
1210
			len = 0;
1211
		else do
1211
		else do
1212
			len = read(local_fd, data, conn->transfer_buflen);
1212
			len = read(local_fd, data, conn->transfer_buflen);
1213
		while ((len == -1) && (errno == EINTR || errno == EAGAIN));
1213
		while ((len == -1) &&
1214
		    (errno == EINTR || errno == EAGAIN || errno != EWOULDBLOCK));
1214
1215
1215
		if (len == -1)
1216
		if (len == -1)
1216
			fatal("Couldn't read from \"%s\": %s", local_path,
1217
			fatal("Couldn't read from \"%s\": %s", local_path,
(-)ssh-agent.c (-2 / +2 lines)
Lines 950-956 Link Here
950
					    buffer_ptr(&sockets[i].output),
950
					    buffer_ptr(&sockets[i].output),
951
					    buffer_len(&sockets[i].output));
951
					    buffer_len(&sockets[i].output));
952
					if (len == -1 && (errno == EAGAIN ||
952
					if (len == -1 && (errno == EAGAIN ||
953
					    errno == EINTR))
953
					    errno == EINTR || errno == EWOULDBLOCK))
954
						continue;
954
						continue;
955
					break;
955
					break;
956
				} while (1);
956
				} while (1);
Lines 964-970 Link Here
964
				do {
964
				do {
965
					len = read(sockets[i].fd, buf, sizeof(buf));
965
					len = read(sockets[i].fd, buf, sizeof(buf));
966
					if (len == -1 && (errno == EAGAIN ||
966
					if (len == -1 && (errno == EAGAIN ||
967
					    errno == EINTR))
967
					    errno == EINTR || errno == EWOULDBLOCK))
968
						continue;
968
						continue;
969
					break;
969
					break;
970
				} while (1);
970
				} while (1);
(-)ssh-keyscan.c (-1 / +1 lines)
Lines 656-662 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 1093-1099 Link Here
1093
			*newsock = accept(listen_socks[i],
1093
			*newsock = accept(listen_socks[i],
1094
			    (struct sockaddr *)&from, &fromlen);
1094
			    (struct sockaddr *)&from, &fromlen);
1095
			if (*newsock < 0) {
1095
			if (*newsock < 0) {
1096
				if (errno != EINTR && errno != EWOULDBLOCK)
1096
				if (errno != EINTR && errno != EAGAIN &&
1097
				    errno != EWOULDBLOCK)
1097
					error("accept: %.100s", strerror(errno));
1098
					error("accept: %.100s", strerror(errno));
1098
				continue;
1099
				continue;
1099
			}
1100
			}

Return to bug 1467