fix for SB#37213
authorMichal Voců <michal@ruk.cuni.cz>
Tue, 8 Feb 2011 08:49:31 +0000 (08:49 +0000)
committerMichal Voců <michal@ruk.cuni.cz>
Tue, 8 Feb 2011 08:49:31 +0000 (08:49 +0000)
org.glite.lb.logger/src/logd_proto.c

index 9ef2793..cc9cb79 100644 (file)
@@ -366,18 +366,17 @@ int edg_wll_log_proto_server(edg_wll_GssConnection *con, struct timeval *timeout
        /* look for the unique unused long local-logger id (LLLID) */
        lllid = 1000*getpid();
        for (i=0; (i<1000)&&(!unique); i++) {
+               struct stat statbuf;
                lllid += i;
                snprintf(confirm_sock_name, sizeof(confirm_sock_name), "/tmp/dglogd_sock_%ld", lllid);
-               if ((filedesc = open(confirm_sock_name,O_CREAT)) == -1) {
-                       if (errno == EEXIST) {
-                               glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_WARN,"Warning: LLLID %ld already in use.\n",lllid);
+               if ((filedesc = stat(confirm_sock_name,&statbuf)) == 0) {
+                       glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_WARN,"Warning: LLLID %ld already in use.\n",lllid);
+               } else {
+                       if (errno == ENOENT) {
+                               unique = 1;
                        } else {
-                               glite_common_log_SYS_ERROR("open");
+                               glite_common_log_SYS_ERROR("stat");
                        }
-               } else {
-                       unique = 1;
-                       close(filedesc); filedesc = 0;
-                       unlink(confirm_sock_name);
                }
        }
        if (!unique) {