changeset 23773:2a8af2ed4b49

Use non-blocking io for IRC DCC transfers.
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 12 Aug 2008 23:22:47 +0000
parents 239ee71307c6
children 91169093449d 4b920b9ea9ca
files libpurple/protocols/irc/dcc_send.c
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/irc/dcc_send.c	Tue Aug 12 23:16:58 2008 +0000
+++ b/libpurple/protocols/irc/dcc_send.c	Tue Aug 12 23:22:47 2008 +0000
@@ -245,7 +245,7 @@
 static void irc_dccsend_send_connected(gpointer data, int source, PurpleInputCondition cond) {
 	PurpleXfer *xfer = (PurpleXfer *) data;
 	struct irc_xfer_send_data *xd = xfer->data;
-	int conn;
+	int conn, flags;
 
 	conn = accept(xd->fd, NULL, 0);
 	if (conn == -1) {
@@ -262,6 +262,12 @@
 	close(xd->fd);
 	xd->fd = -1;
 
+	flags = fcntl(conn, F_GETFL);
+	fcntl(conn, F_SETFL, flags | O_NONBLOCK);
+#ifndef _WIN32
+	fcntl(conn, F_SETFD, FD_CLOEXEC);
+#endif
+
 	xd->inpa = purple_input_add(conn, PURPLE_INPUT_READ, irc_dccsend_send_read, xfer);
 	/* Start the transfer */
 	purple_xfer_start(xfer, conn, NULL, 0);