[farsight2/master] Correctly find the port we used.. in case port is 0, we can't use the port variable since it will be randomly allocated

Youness Alaoui youness.alaoui at collabora.co.uk
Tue Jul 14 09:50:47 PDT 2009


---
 gst/fsmsnconference/fs-msn-connection.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/gst/fsmsnconference/fs-msn-connection.c b/gst/fsmsnconference/fs-msn-connection.c
index 8a05eec..959cd54 100644
--- a/gst/fsmsnconference/fs-msn-connection.c
+++ b/gst/fsmsnconference/fs-msn-connection.c
@@ -326,6 +326,7 @@ fs_msn_open_listening_port (FsMsnConnection *self, guint16 port)
 {
   gint fd = -1;
   struct sockaddr_in myaddr;
+  guint myaddr_len = sizeof (struct sockaddr_in);
   FsCandidate * candidate = NULL;
   GList *addresses = nice_interfaces_get_local_ips (FALSE);
   GList *item = NULL;
@@ -379,6 +380,12 @@ fs_msn_open_listening_port (FsMsnConnection *self, guint16 port)
     }
   } while (errno == EADDRINUSE);
 
+
+  if (getsockname (fd, (struct sockaddr *) &myaddr, &myaddr_len) < 0) {
+    close (fd);
+    return FALSE;
+  }
+  port = ntohs (myaddr.sin_port);
   add_pollfd (self, fd, accept_connection_cb, TRUE, TRUE);
 
   g_debug ("Listening on port %d", port);
-- 
1.5.6.5




More information about the farsight-commits mailing list