diff src/protocols/irc/dcc_send.c @ 13200:33bef17125c2

[gaim-migrate @ 15563] This is the soon-to-be-infamous nonblocking network activity patch that I've been working on. Feel free to yell at me if this makes you unhappy. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 09 Feb 2006 04:17:56 +0000
parents 8e3b85fe4a55
children 5ddde4ad1ca2
line wrap: on
line diff
--- a/src/protocols/irc/dcc_send.c	Thu Feb 09 04:14:54 2006 +0000
+++ b/src/protocols/irc/dcc_send.c	Thu Feb 09 04:17:56 2006 +0000
@@ -174,7 +174,12 @@
 	char *buffer[16];
 	int len;
 
-	if ((len = read(source, buffer, sizeof(buffer))) <= 0) {
+	len = read(source, buffer, sizeof(buffer));
+
+	if (len < 0 && errno == EAGAIN)
+		return;
+	else if (len < 0) {
+		/* XXX: Shouldn't this be canceling the transfer? */
 		gaim_input_remove(xd->inpa);
 		xd->inpa = 0;
 		return;
@@ -209,20 +214,24 @@
 			gaim_xfer_end(xfer);
 			return;
 		}
-
-
 	}
 }
 
 static gssize irc_dccsend_send_write(const guchar *buffer, size_t size, GaimXfer *xfer)
 {
 	gssize s;
+	int ret;
 
 	s = MIN(gaim_xfer_get_bytes_remaining(xfer), size);
 	if (!s)
 		return 0;
 
-	return write(xfer->fd, buffer, s);
+	ret = write(xfer->fd, buffer, s);
+
+	if (ret < 0 && errno == EAGAIN)
+		ret = 0;
+
+	return ret;
 }
 
 static void irc_dccsend_send_connected(gpointer data, int source, GaimInputCondition cond) {