comparison libpurple/protocols/simple/simple.c @ 23709:7f401e99f9d9

Use non-blocking io for inbound TCP connections for SIMPLE.
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 12 Aug 2008 23:09:05 +0000
parents 6b09c40a15d1
children e22bcca9f2b2 61f825f8b3a2 16734635febf
comparison
equal deleted inserted replaced
23708:0dd3df365017 23709:7f401e99f9d9
1701 /* Callback for new connections on incoming TCP port */ 1701 /* Callback for new connections on incoming TCP port */
1702 static void simple_newconn_cb(gpointer data, gint source, PurpleInputCondition cond) { 1702 static void simple_newconn_cb(gpointer data, gint source, PurpleInputCondition cond) {
1703 PurpleConnection *gc = data; 1703 PurpleConnection *gc = data;
1704 struct simple_account_data *sip = gc->proto_data; 1704 struct simple_account_data *sip = gc->proto_data;
1705 struct sip_connection *conn; 1705 struct sip_connection *conn;
1706 1706 int newfd, flags;
1707 int newfd = accept(source, NULL, NULL); 1707
1708 newfd = accept(source, NULL, NULL);
1709
1710 flags = fcntl(newfd, F_GETFL);
1711 fcntl(newfd, F_SETFL, flags | O_NONBLOCK);
1712 #ifndef _WIN32
1713 fcntl(newfd, F_SETFD, FD_CLOEXEC);
1714 #endif
1708 1715
1709 conn = connection_create(sip, newfd); 1716 conn = connection_create(sip, newfd);
1710 1717
1711 conn->inputhandler = purple_input_add(newfd, PURPLE_INPUT_READ, simple_input_cb, gc); 1718 conn->inputhandler = purple_input_add(newfd, PURPLE_INPUT_READ, simple_input_cb, gc);
1712 } 1719 }