masqmail-0.2
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 |
line diff
1.1 --- a/src/dotlock.c Mon Oct 27 16:21:27 2008 +0100 1.2 +++ b/src/dotlock.c Mon Oct 27 16:23:10 2008 +0100 1.3 @@ -29,52 +29,52 @@ 1.4 #include "masqmail.h" 1.5 #include "dotlock.h" 1.6 1.7 -gboolean dot_lock(gchar *lock_name, gchar *hitch_name) 1.8 +gboolean 1.9 +dot_lock(gchar * lock_name, gchar * hitch_name) 1.10 { 1.11 - gboolean ok = FALSE; 1.12 - int fd; 1.13 + gboolean ok = FALSE; 1.14 + int fd; 1.15 1.16 - fd = open(hitch_name, O_WRONLY | O_CREAT | O_EXCL, 0); 1.17 - if(fd != -1){ 1.18 - struct stat stat_buf; 1.19 + fd = open(hitch_name, O_WRONLY | O_CREAT | O_EXCL, 0); 1.20 + if (fd != -1) { 1.21 + struct stat stat_buf; 1.22 1.23 - close(fd); 1.24 - link(hitch_name, lock_name); 1.25 - if(stat(hitch_name, &stat_buf) == 0){ 1.26 - if(stat_buf.st_nlink == 2){ 1.27 - unlink(hitch_name); 1.28 - ok = TRUE; 1.29 - } 1.30 - else{ 1.31 - if(stat(lock_name, &stat_buf) == 0){ 1.32 - if((time(NULL) - stat_buf.st_mtime) > MAX_LOCKAGE){ 1.33 - /* remove lock if uncredibly old */ 1.34 - unlink(lock_name); 1.35 + close(fd); 1.36 + link(hitch_name, lock_name); 1.37 + if (stat(hitch_name, &stat_buf) == 0) { 1.38 + if (stat_buf.st_nlink == 2) { 1.39 + unlink(hitch_name); 1.40 + ok = TRUE; 1.41 + } else { 1.42 + if (stat(lock_name, &stat_buf) == 0) { 1.43 + if ((time(NULL) - stat_buf.st_mtime) > MAX_LOCKAGE) { 1.44 + /* remove lock if uncredibly old */ 1.45 + unlink(lock_name); 1.46 1.47 - link(hitch_name, lock_name); 1.48 - if(stat(hitch_name, &stat_buf) == 0){ 1.49 - if(stat_buf.st_nlink == 2){ 1.50 - unlink(hitch_name); 1.51 - ok = TRUE; 1.52 - } 1.53 - } 1.54 - } 1.55 - } 1.56 - } 1.57 - } 1.58 - if(!ok){ 1.59 - unlink(hitch_name); 1.60 - } 1.61 - }else 1.62 - logwrite(LOG_WARNING, "could not create lock file %s: %s\n", 1.63 - lock_name, strerror(errno)); 1.64 + link(hitch_name, lock_name); 1.65 + if (stat(hitch_name, &stat_buf) == 0) { 1.66 + if (stat_buf.st_nlink == 2) { 1.67 + unlink(hitch_name); 1.68 + ok = TRUE; 1.69 + } 1.70 + } 1.71 + } 1.72 + } 1.73 + } 1.74 + } 1.75 + if (!ok) { 1.76 + unlink(hitch_name); 1.77 + } 1.78 + } else 1.79 + logwrite(LOG_WARNING, "could not create lock file %s: %s\n", lock_name, strerror(errno)); 1.80 1.81 - return ok; 1.82 + return ok; 1.83 } 1.84 1.85 -gboolean dot_unlock(gchar *lock_name) 1.86 +gboolean 1.87 +dot_unlock(gchar * lock_name) 1.88 { 1.89 - unlink(lock_name); 1.90 + unlink(lock_name); 1.91 1.92 - return TRUE; 1.93 + return TRUE; 1.94 }