From 22cc529409a7dc62b36be256bc23899156e3c1c2 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Mon, 15 Aug 2011 23:41:24 +0200 Subject: [PATCH] rtspconnection: add OSX specific hack to detect when a connection is refused Unlike linux, OSX wakes up select with POLLOUT (instead of POLLERR) when connect() is done async and the connection is refused. Therefore always check for the socket error state using getsockopt (..., SO_ERROR, ...) after a connection attempt. --- gst-libs/gst/rtsp/gstrtspconnection.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c index 3e29efb280..2de21b9777 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.c +++ b/gst-libs/gst/rtsp/gstrtspconnection.c @@ -592,6 +592,14 @@ do_connect (const gchar * ip, guint16 port, GstPollFD * fdout, getsockopt (fd, SOL_SOCKET, SO_ERROR, (char *) &errno, &len); #endif goto sys_error; + } else { +#ifdef __APPLE__ + /* osx wakes up select with POLLOUT if the connection is refused... */ + socklen_t len = sizeof (errno); + getsockopt (fd, SOL_SOCKET, SO_ERROR, (char *) &errno, &len); + if (errno != 0) + goto sys_error; +#endif } gst_poll_fd_ignored (fdset, fdout);