summaryrefslogtreecommitdiffstats
path: root/ldap/servers
diff options
context:
space:
mode:
authorNathan Kinder <nkinder@redhat.com>2008-11-14 02:06:34 +0000
committerNathan Kinder <nkinder@redhat.com>2008-11-14 02:06:34 +0000
commiteb75a8d7d65af98bfb01b1380d53fce2da972db6 (patch)
tree489f33c5fa946b87aafda571eb84dfa986173abc /ldap/servers
parent65e8b7e984129d767f6d766734e5bc1b9cac4ae0 (diff)
downloadds-eb75a8d7d65af98bfb01b1380d53fce2da972db6.tar.gz
ds-eb75a8d7d65af98bfb01b1380d53fce2da972db6.tar.xz
ds-eb75a8d7d65af98bfb01b1380d53fce2da972db6.zip
Resolves: 450046
Summary: Clean-up leftover changelog semaphore at startup.
Diffstat (limited to 'ldap/servers')
-rw-r--r--ldap/servers/plugins/replication/cl5_api.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index fda8f8af..11ad776a 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -6415,17 +6415,35 @@ out:
(*dbFile)->semaName = slapi_ch_smprintf("%s/%s.sema", semadir, replName);
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
"_cl5NewDBFile: semaphore %s\n", (*dbFile)->semaName);
- (*dbFile)->sema = PR_OpenSemaphore((*dbFile)->semaName, PR_SEM_CREATE, 0666, s_cl5Desc.dbConfig.maxConcurrentWrites );
+ (*dbFile)->sema = PR_OpenSemaphore((*dbFile)->semaName,
+ PR_SEM_CREATE | PR_SEM_EXCL, 0666,
+ s_cl5Desc.dbConfig.maxConcurrentWrites );
slapi_log_error (SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5NewDBFile: maxConcurrentWrites=%d\n", s_cl5Desc.dbConfig.maxConcurrentWrites );
}
if ((*dbFile)->sema == NULL )
{
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
- "_cl5NewDBFile: failed to create semaphore %s; NSPR error - %d\n",
- (*dbFile)->semaName ? (*dbFile)->semaName : "(nil)", PR_GetError ());
- rc = CL5_SYSTEM_ERROR;
- goto done;
+ /* If the semaphore was left around due
+ * to an unclean exit last time, remove
+ * and re-create it.
+ */
+ if (PR_GetError() == PR_FILE_EXISTS_ERROR) {
+ PR_DeleteSemaphore((*dbFile)->semaName);
+ (*dbFile)->sema = PR_OpenSemaphore((*dbFile)->semaName,
+ PR_SEM_CREATE | PR_SEM_EXCL, 0666,
+ s_cl5Desc.dbConfig.maxConcurrentWrites );
+ }
+
+ /* If we still failed to create the semaphore,
+ * we should just error out. */
+ if ((*dbFile)->sema == NULL )
+ {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "_cl5NewDBFile: failed to create semaphore %s; NSPR error - %d\n",
+ (*dbFile)->semaName ? (*dbFile)->semaName : "(nil)", PR_GetError());
+ rc = CL5_SYSTEM_ERROR;
+ goto done;
+ }
}
/* compute number of entries in the file */