changeset 13011:5e14039d0415

[gaim-migrate @ 15364] prepare for non-blocking I/O committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 23 Jan 2006 04:25:04 +0000
parents e348ed834acc
children e3b9c6c7bcf6
files src/ft.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ft.c	Mon Jan 23 04:18:34 2006 +0000
+++ b/src/ft.c	Mon Jan 23 04:25:04 2006 +0000
@@ -770,11 +770,13 @@
 		*buffer = g_malloc0(s);
 
 		r = read(xfer->fd, *buffer, s);
-		if ((gaim_xfer_get_size(xfer) > 0) &&
+		if (r < 0 && errno == EAGAIN)
+			r = 0;
+		else if (r < 0)
+			r = -1;
+		else if ((gaim_xfer_get_size(xfer) > 0) &&
 			((gaim_xfer_get_bytes_sent(xfer)+r) >= gaim_xfer_get_size(xfer)))
 			gaim_xfer_set_completed(xfer, TRUE);
-		else if(r <= 0)
-			r = -1;
 	}
 
 	return r;
@@ -795,6 +797,8 @@
 		r = (xfer->ops.write)(buffer, s, xfer);
 	} else {
 		r = write(xfer->fd, buffer, s);
+		if (r < 0 && errno == EAGAIN)
+			r = 0;
 		if ((gaim_xfer_get_bytes_sent(xfer)+r) >= gaim_xfer_get_size(xfer))
 			gaim_xfer_set_completed(xfer, TRUE);
 	}
@@ -817,7 +821,8 @@
 		} else if(r < 0) {
 			gaim_xfer_cancel_remote(xfer);
 			return;
-		}
+		} else if(r == 0)
+			return;
 	}
 
 	if (condition & GAIM_INPUT_WRITE) {