projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
we always want to DOTLOCK mboxes.
[apps/madmutt.git]
/
mx.c
diff --git
a/mx.c
b/mx.c
index
d1534ea
..
88537ab
100644
(file)
--- a/
mx.c
+++ b/
mx.c
@@
-26,6
+26,7
@@
#include "copy.h"
#include "keymap.h"
#include "compress.h"
#include "copy.h"
#include "keymap.h"
#include "compress.h"
+#include "dotlock.h"
#include <imap/imap.h>
#include <imap/mx_imap.h>
#include <imap/imap.h>
#include <imap/mx_imap.h>
@@
-38,10
+39,6
@@
#include "nntp/mx_nntp.h"
#endif
#include "nntp/mx_nntp.h"
#endif
-#ifdef USE_DOTLOCK
-#include "dotlock.h"
-#endif
-
#include <lib-crypt/crypt.h>
static mx_t const *mxfmts[] = {
#include <lib-crypt/crypt.h>
static mx_t const *mxfmts[] = {
@@
-60,12
+57,10
@@
static mx_t const *mxfmts[] = {
#define MX_IDX(idx) (idx >= 0 && idx < countof(mxfmts))
#define mutt_is_spool(s) (m_strcmp(Spoolfile, s) == 0)
#define MX_IDX(idx) (idx >= 0 && idx < countof(mxfmts))
#define mutt_is_spool(s) (m_strcmp(Spoolfile, s) == 0)
-#ifdef USE_DOTLOCK
/* parameters:
* path - file to lock
* retry - should retry if unable to lock?
*/
/* parameters:
* path - file to lock
* retry - should retry if unable to lock?
*/
-
static int invoke_dotlock (const char *path, int flags, int retry)
{
char cmd[LONG_STRING + _POSIX_PATH_MAX];
static int invoke_dotlock (const char *path, int flags, int retry)
{
char cmd[LONG_STRING + _POSIX_PATH_MAX];
@@
-125,8
+120,6
@@
static int undotlock_file (const char *path)
DL_EX_OK ? 0 : -1);
}
DL_EX_OK ? 0 : -1);
}
-#endif /* USE_DOTLOCK */
-
/* looks up index of type for path in mxfmts */
static int mx_get_idx (const char* path) {
int i = 0, t = 0;
/* looks up index of type for path in mxfmts */
static int mx_get_idx (const char* path) {
int i = 0, t = 0;
@@
-242,10
+235,8
@@
int mx_lock_file (const char *path, int fd, int excl, int dot, int time_out)
}
#endif /* USE_FLOCK */
}
#endif /* USE_FLOCK */
-#ifdef USE_DOTLOCK
if (r == 0 && dot)
r = dotlock_file (path, time_out);
if (r == 0 && dot)
r = dotlock_file (path, time_out);
-#endif /* USE_DOTLOCK */
if (r == -1) {
/* release any other locks obtained in this routine */
if (r == -1) {
/* release any other locks obtained in this routine */
@@
-280,10
+271,8
@@
int mx_unlock_file (const char *path, int fd, int dot)
flock (fd, LOCK_UN);
#endif
flock (fd, LOCK_UN);
#endif
-#ifdef USE_DOTLOCK
if (dot)
undotlock_file (path);
if (dot)
undotlock_file (path);
-#endif
return 0;
}
return 0;
}
@@
-291,10
+280,7
@@
int mx_unlock_file (const char *path, int fd, int dot)
static void mx_unlink_empty (const char *path)
{
int fd;
static void mx_unlink_empty (const char *path)
{
int fd;
-
-#ifndef USE_DOTLOCK
struct stat sb;
struct stat sb;
-#endif
if ((fd = open (path, O_RDWR)) == -1)
return;
if ((fd = open (path, O_RDWR)) == -1)
return;
@@
-304,12
+290,7
@@
static void mx_unlink_empty (const char *path)
return;
}
return;
}
-#ifdef USE_DOTLOCK
- invoke_dotlock (path, DL_FL_UNLINK, 1);
-#else
- if (fstat (fd, &sb) == 0 && sb.st_size == 0)
- unlink (path);
-#endif
+ invoke_dotlock(path, DL_FL_UNLINK, 1);
mx_unlock_file (path, fd, 0);
close (fd);
mx_unlock_file (path, fd, 0);
close (fd);