From 5fa5f1430b883a9c9944ca332c127cc1ee7970da Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Wed, 13 Feb 2013 11:32:30 +0000 Subject: [PATCH] small change to something never used/tested much ... cserve2 - FAIL if an existing cserve 2 client is there. SVN revision: 83866 --- src/bin/evas/evas_cserve2_main_loop_linux.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/bin/evas/evas_cserve2_main_loop_linux.c b/src/bin/evas/evas_cserve2_main_loop_linux.c index afd678e..0fd40ea 100644 --- a/src/bin/evas/evas_cserve2_main_loop_linux.c +++ b/src/bin/evas/evas_cserve2_main_loop_linux.c @@ -253,13 +253,22 @@ _socketfd_setup(void) socket_local.sun_family = AF_UNIX; _socket_path_set(socket_local.sun_path); DBG("Using '%s' as server socket.", socket_local.sun_path); - unlink(socket_local.sun_path); len = strlen(socket_local.sun_path) + sizeof(socket_local.sun_family); if (bind(s, (struct sockaddr *)&socket_local, len) == -1) { - ERR("Could not bind socketfd: \"%s\"", strerror(errno)); - close(s); - return -1; + if (connect(s, (struct sockaddr *)&socket_local, len) != -1) + { + ERR("cserve2 service already there: \"%s\"", strerror(errno)); + close(s); + return -1; + } + unlink(socket_local.sun_path); + if (bind(s, (struct sockaddr *)&socket_local, len) == -1) + { + ERR("Could not bind socketfd: \"%s\"", strerror(errno)); + close(s); + return -1; + } } if (listen(s, MAX_INCOMING_CONN) == -1) -- 2.7.4