diff packet.c @ 964:67ff2be856ff coverity

merge
author Matt Johnston <matt@ucc.asn.au>
date Fri, 08 Aug 2014 21:26:07 +0800
parents c4f138dae2fd
children e3614649b1f5
line wrap: on
line diff
--- a/packet.c	Mon Jul 28 23:38:54 2014 +0800
+++ b/packet.c	Fri Aug 08 21:26:07 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;
 		}