gsocket: use _add_unix_fd() instead of _add_poll()

Use g_source_add_unix_fd() on UNIX instead of using a GPollFD.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
This commit is contained in:
Ryan Lortie 2014-02-13 16:37:49 -05:00
parent 04aee2d920
commit e8f26efe0d

View File

@ -3204,7 +3204,11 @@ update_condition (GSocket *socket)
typedef struct { typedef struct {
GSource source; GSource source;
#ifdef G_OS_WIN32
GPollFD pollfd; GPollFD pollfd;
#else
gpointer fd_tag;
#endif
GSocket *socket; GSocket *socket;
GIOCondition condition; GIOCondition condition;
} GSocketSource; } GSocketSource;
@ -3219,10 +3223,10 @@ socket_source_prepare (GSource *source,
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
socket_source->pollfd.revents = update_condition (socket_source->socket); socket_source->pollfd.revents = update_condition (socket_source->socket);
#endif
if ((socket_source->condition & socket_source->pollfd.revents) != 0) if ((socket_source->condition & socket_source->pollfd.revents) != 0)
return TRUE; return TRUE;
#endif
return FALSE; return FALSE;
} }
@ -3250,7 +3254,7 @@ socket_source_dispatch (GSource *source,
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
events = update_condition (socket_source->socket); events = update_condition (socket_source->socket);
#else #else
events = socket_source->pollfd.revents; events = g_source_query_unix_fd (source, socket_source->fd_tag);
#endif #endif
timeout = g_source_get_ready_time (source); timeout = g_source_get_ready_time (source);
@ -3362,13 +3366,12 @@ socket_source_new (GSocket *socket,
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
add_condition_watch (socket, &socket_source->condition); add_condition_watch (socket, &socket_source->condition);
socket_source->pollfd.fd = (gintptr) socket->priv->event; socket_source->pollfd.fd = (gintptr) socket->priv->event;
#else
socket_source->pollfd.fd = socket->priv->fd;
#endif
socket_source->pollfd.events = condition; socket_source->pollfd.events = condition;
socket_source->pollfd.revents = 0; socket_source->pollfd.revents = 0;
g_source_add_poll (source, &socket_source->pollfd); g_source_add_poll (source, &socket_source->pollfd);
#else
socket_source->fd_tag = g_source_add_unix_fd (source, socket->priv->fd, condition);
#endif
if (socket->priv->timeout) if (socket->priv->timeout)
g_source_set_ready_time (source, g_get_monotonic_time () + socket->priv->timeout * 1000000); g_source_set_ready_time (source, g_get_monotonic_time () + socket->priv->timeout * 1000000);