Only check selected pair for writability in gio outputstream
authorYouness Alaoui <youness.alaoui@collabora.co.uk>
Tue, 8 Apr 2014 03:14:42 +0000 (23:14 -0400)
committerOlivier Crête <olivier.crete@ocrete.ca>
Thu, 15 May 2014 13:43:15 +0000 (09:43 -0400)
agent/outputstream.c

index c92b64d..8390ce9 100644 (file)
@@ -470,7 +470,6 @@ nice_output_stream_is_writable (GPollableOutputStream *stream)
   Component *component = NULL;
   Stream *_stream = NULL;
   gboolean retval = FALSE;
-  GSList *i;
   NiceAgent *agent;  /* owned */
 
   /* Closed streams are not writeable. */
@@ -491,23 +490,15 @@ nice_output_stream_is_writable (GPollableOutputStream *stream)
     goto done;
   }
   if (component->selected_pair.local != NULL) {
+    NiceSocket *sockptr = component->selected_pair.local->sockptr;
+
     /* If it’s a reliable agent, see if there’s any space in the pseudo-TCP
      * output buffer. */
-    if (!nice_socket_is_reliable (component->selected_pair.local->sockptr) &&
-        component->tcp != NULL) {
-      retval = pseudo_tcp_socket_can_send (component->tcp);
-      goto done;
-    }
-
-    /* Check whether any of the component’s FDs are pollable. */
-    for (i = component->socket_sources; i != NULL; i = i->next) {
-      SocketSource *socket_source = i->data;
-      NiceSocket *nicesock = socket_source->socket;
-
-      if (g_socket_condition_check (nicesock->fileno, G_IO_OUT) != 0) {
-        retval = TRUE;
-        break;
-      }
+    if (!nice_socket_is_reliable (sockptr)) {
+      if (component->tcp != NULL)
+        retval = pseudo_tcp_socket_can_send (component->tcp);
+    } else {
+      retval = (g_socket_condition_check (sockptr->fileno, G_IO_OUT) != 0);
     }
   }