Remove WIN32 preprocessor directive from csync.c.

This commit is contained in:
Klaas Freitag 2013-04-20 11:38:25 +03:00
parent 2b971a09f3
commit 84f425a326
2 changed files with 7 additions and 4 deletions

View file

@ -188,13 +188,11 @@ int csync_init(CSYNC *ctx) {
goto out;
}
#ifndef _WIN32
if (csync_lock(ctx, lock) < 0) {
ctx->error_code = CSYNC_ERR_LOCK;
rc = -1;
goto out;
}
#endif
/* load config file */
if (asprintf(&config, "%s/%s", ctx->options.config_dir, CSYNC_CONF_FILE) < 0) {
@ -736,12 +734,10 @@ int csync_destroy(CSYNC *ctx) {
/* clear exclude list */
csync_exclude_destroy(ctx);
#ifndef _WIN32
/* remove the lock file */
if (asprintf(&lock, "%s/%s", ctx->options.config_dir, CSYNC_LOCK_FILE) > 0) {
csync_lock_remove(ctx, lock);
}
#endif
while (ctx->progress) {
csync_progressinfo_t *next = ctx->progress->next;

View file

@ -181,6 +181,7 @@ static pid_t _csync_lock_read(CSYNC *ctx, const char *lockfile) {
}
int csync_lock(CSYNC *ctx, const char *lockfile) {
#ifndef _WIN32
/* Check if lock already exists. */
if (_csync_lock_read(ctx, lockfile) > 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Aborting, another synchronization process is running.");
@ -190,9 +191,14 @@ int csync_lock(CSYNC *ctx, const char *lockfile) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_INFO, "Creating lock file: %s", lockfile);
return _csync_lock_create(ctx, lockfile);
#else
return 0;
#endif
}
void csync_lock_remove(CSYNC *ctx, const char *lockfile) {
#ifndef _WIN32
char errbuf[256] = {0};
/* You can't remove the lock if it is from another process */
if (_csync_lock_read(ctx, lockfile) == getpid()) {
@ -205,5 +211,6 @@ void csync_lock_remove(CSYNC *ctx, const char *lockfile) {
errbuf);
}
}
#endif
}