Mercurial > masqmail
diff src/dotlock.c @ 10:26e34ae9a3e3
changed indention and line wrapping to a more consistent style
author | meillo@marmaro.de |
---|---|
date | Mon, 27 Oct 2008 16:23:10 +0100 |
parents | 08114f7dcc23 |
children | 41958685480d |
line wrap: on
line diff
--- a/src/dotlock.c Mon Oct 27 16:21:27 2008 +0100 +++ b/src/dotlock.c Mon Oct 27 16:23:10 2008 +0100 @@ -29,52 +29,52 @@ #include "masqmail.h" #include "dotlock.h" -gboolean dot_lock(gchar *lock_name, gchar *hitch_name) +gboolean +dot_lock(gchar * lock_name, gchar * hitch_name) { - gboolean ok = FALSE; - int fd; + gboolean ok = FALSE; + int fd; - fd = open(hitch_name, O_WRONLY | O_CREAT | O_EXCL, 0); - if(fd != -1){ - struct stat stat_buf; + fd = open(hitch_name, O_WRONLY | O_CREAT | O_EXCL, 0); + if (fd != -1) { + struct stat stat_buf; - close(fd); - link(hitch_name, lock_name); - if(stat(hitch_name, &stat_buf) == 0){ - if(stat_buf.st_nlink == 2){ - unlink(hitch_name); - ok = TRUE; - } - else{ - if(stat(lock_name, &stat_buf) == 0){ - if((time(NULL) - stat_buf.st_mtime) > MAX_LOCKAGE){ - /* remove lock if uncredibly old */ - unlink(lock_name); + close(fd); + link(hitch_name, lock_name); + if (stat(hitch_name, &stat_buf) == 0) { + if (stat_buf.st_nlink == 2) { + unlink(hitch_name); + ok = TRUE; + } else { + if (stat(lock_name, &stat_buf) == 0) { + if ((time(NULL) - stat_buf.st_mtime) > MAX_LOCKAGE) { + /* remove lock if uncredibly old */ + unlink(lock_name); - link(hitch_name, lock_name); - if(stat(hitch_name, &stat_buf) == 0){ - if(stat_buf.st_nlink == 2){ - unlink(hitch_name); - ok = TRUE; - } - } - } - } - } - } - if(!ok){ - unlink(hitch_name); - } - }else - logwrite(LOG_WARNING, "could not create lock file %s: %s\n", - lock_name, strerror(errno)); + link(hitch_name, lock_name); + if (stat(hitch_name, &stat_buf) == 0) { + if (stat_buf.st_nlink == 2) { + unlink(hitch_name); + ok = TRUE; + } + } + } + } + } + } + if (!ok) { + unlink(hitch_name); + } + } else + logwrite(LOG_WARNING, "could not create lock file %s: %s\n", lock_name, strerror(errno)); - return ok; + return ok; } -gboolean dot_unlock(gchar *lock_name) +gboolean +dot_unlock(gchar * lock_name) { - unlink(lock_name); + unlink(lock_name); - return TRUE; + return TRUE; }