Theoretically, getsockopt could fail and leave 'error' unset. While I
authorWill Thompson <will.thompson@collabora.co.uk>
Sat, 10 Oct 2009 18:25:37 +0200
changeset 601 7972c1499f6d
parent 600 7f0be2600f6d
child 602 3bcd644fe1ba
Theoretically, getsockopt could fail and leave 'error' unset. While I don't think this will happen in practice, the failure can be handled by returning the value of errno. committer: Frank Zschockelt <lm@freakysoft.de>
loudmouth/lm-sock.c
--- a/loudmouth/lm-sock.c	Sat Oct 10 18:24:58 2009 +0200
+++ b/loudmouth/lm-sock.c	Sat Oct 10 18:25:37 2009 +0200
@@ -208,7 +208,8 @@
                     void      *error,
                     socklen_t *len)
 {
-    getsockopt (sock, SOL_SOCKET, SO_ERROR, (void*) error, len);
+    if (getsockopt (sock, SOL_SOCKET, SO_ERROR, (void*) error, len) != 0)
+	*((int *) error) = errno;
 }
 
 const gchar *