mpd fix take 2
authorBrenden Matthews <brenden1@rty.ca>
Sun, 30 Mar 2008 02:29:12 +0000 (02:29 +0000)
committerBrenden Matthews <brenden1@rty.ca>
Sun, 30 Mar 2008 02:29:12 +0000 (02:29 +0000)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1081 7f574dfc-610e-0410-a909-a81674777703

src/libmpdclient.c

index 02a59f2..f32a0e4 100644 (file)
@@ -117,7 +117,7 @@ static int do_connect_fail(mpd_Connection *connection,
 
        fcntl(connection->sock, F_SETFL, flags | O_NONBLOCK);
        return (connect(connection->sock, serv_addr, addrlen) < 0
-               || errno != EINPROGRESS);
+               && errno != EINPROGRESS);
 }
 #endif /* !WIN32 */
 
@@ -154,6 +154,9 @@ static int mpd_connect(mpd_Connection *connection, const char *host, int port,
 
        for (res = addrinfo; res; res = res->ai_next) {
                /* create socket */
+               if (connection->sock > -1) {
+                       closesocket(connection->sock);
+               }
                connection->sock = socket(res->ai_family, SOCK_STREAM,
                        res->ai_protocol);
                if (connection->sock < 0) {