From 75e3ac281bf1b9291944659adf990a8b6b5ea325 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Milo=C5=A1=20Mula=C4=8D?= Date: Fri, 9 Jun 2006 09:32:27 +0000 Subject: [PATCH] add microseconds to filename to avoid two registrations in one second (now two registrations in one usec, from one slave are very unlikely) --- org.glite.lb.common/src/lb_maildir.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/org.glite.lb.common/src/lb_maildir.c b/org.glite.lb.common/src/lb_maildir.c index 14bda68..ede0b3d 100644 --- a/org.glite.lb.common/src/lb_maildir.c +++ b/org.glite.lb.common/src/lb_maildir.c @@ -78,6 +78,7 @@ int edg_wll_MaildirStoreMsg( written, msgsz, ct, i; + struct timeval tv; if ( !root ) root = DEFAULT_ROOT; @@ -90,9 +91,11 @@ int edg_wll_MaildirStoreMsg( snprintf(lbm_errdesc, MAX_ERR_LEN, "Maximum tries limit reached with unsuccessful file creation"); return -1; } - snprintf(fname, PATH_MAX, "%s/%s/%ld.%d.%s", root, dirs[LBMD_DIR_TMP], (long) time(NULL), getpid(), srvname); + gettimeofday(&tv,NULL); + snprintf(fname, PATH_MAX, "%s/%s/%ld.%ld_%d.%s", root, dirs[LBMD_DIR_TMP], + (long) tv.tv_sec, (long) tv.tv_usec, getpid(), srvname); if ( (fhnd = open(fname, O_CREAT|O_EXCL|O_WRONLY, 00600)) < 0 ) { - if ( errno == EEXIST ) { sleep(2); continue; } + if ( errno == EEXIST ) { /* hypothetic error */ continue; } snprintf(lbm_errdesc, MAX_ERR_LEN, "Can't create file %s", fname); return -1; } -- 1.8.2.3