diff packet.c @ 957:c4f138dae2fd

Test for EAGAIN too
author Matt Johnston <matt@ucc.asn.au>
date Wed, 06 Aug 2014 21:55:43 +0800
parents a0819ecfee0b
children e3614649b1f5
line wrap: on
line diff
--- a/packet.c	Mon Jul 28 23:23:49 2014 +0800
+++ b/packet.c	Wed Aug 06 21:55:43 2014 +0800
@@ -93,9 +93,12 @@
 		iov[i].iov_base = buf_getptr(writebuf, len);
 		iov[i].iov_len = len;
 	}
+	/* This may return EAGAIN. The main loop sometimes
+	calls write_packet() without bothering to test with select() since
+	it's likely to be necessary */
 	written = writev(ses.sock_out, iov, iov_max_count);
 	if (written < 0) {
-		if (errno == EINTR) {
+		if (errno == EINTR || errno == EAGAIN) {
 			m_free(iov);
 			TRACE2(("leave write_packet: EINTR"))
 			return;
@@ -136,7 +139,7 @@
 	written = write(ses.sock_out, buf_getptr(writebuf, len), len);
 
 	if (written < 0) {
-		if (errno == EINTR) {
+		if (errno == EINTR || errno == EAGAIN) {
 			TRACE2(("leave writepacket: EINTR"))
 			return;
 		} else {
@@ -255,7 +258,7 @@
 		ses.remoteclosed();
 	}
 	if (slen < 0) {
-		if (errno == EINTR) {
+		if (errno == EINTR || errno == EAGAIN) {
 			TRACE2(("leave read_packet_init: EINTR"))
 			return DROPBEAR_FAILURE;
 		}