]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
locking: remove lock wrappers, lock is now handled an open() time
authorBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 9 Dec 2021 09:18:58 +0000 (10:18 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 9 Dec 2021 09:18:58 +0000 (10:18 +0100)
include/mylocking.h [deleted file]
src/Makefile.am
src/incindexfile.c
src/log_oper.c
src/mlmmj-maintd.c
src/mlmmj-send.c
src/mlmmj-sub.c
src/mylocking.c [deleted file]

diff --git a/include/mylocking.h b/include/mylocking.h
deleted file mode 100644 (file)
index 6027438..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (C) 2002, 2003 Mads Martin Joergensen <mmj at mmj.dk>
- *
- * $Id$
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef MYLOCKING_H
-#define MYLOCKING_H
-
-int myexcllock(int fd);
-int myunlock(int fd);
-
-#endif /* MYLOCKING_H */
index 3d4c474a3902ca2f4c81902bcf11937268eecb92..12a5953a357010f66e164f79b5b74c95baba725a 100644 (file)
@@ -13,17 +13,17 @@ EXTRA_DIST = mlmmj-make-ml
 
 mlmmj_send_SOURCES = mlmmj.c mlmmj-send.c  mail-functions.c itoa.c chomp.c \
                      incindexfile.c checkwait_smtpreply.c  utils.c \
-                    mylocking.c init_sockfd.c strgen.c random-int.c \
+                    init_sockfd.c strgen.c random-int.c \
                     print-version.c log_error.c mygetline.c memory.c \
                     controls.c getaddrsfromfd.c readn.c send_mails.c
 
 mlmmj_receive_SOURCES = mlmmj-receive.c  random-int.c strgen.c \
                        print-version.c log_error.c dumpfd2fd.c memory.c \
-                       log_oper.c mylocking.c readn.c
+                       log_oper.c readn.c
 
 mlmmj_process_SOURCES = mlmmj.c mlmmj-process.c  find_email_adr.c \
                        incindexfile.c itoa.c  chomp.c utils.c \
-                       mylocking.c listcontrol.c random-int.c strgen.c \
+                       listcontrol.c random-int.c strgen.c \
                        print-version.c send_help.c prepstdreply.c \
                        do_all_the_voodoo_here.c mygetline.c gethdrline.c \
                        log_error.c controls.c dumpfd2fd.c \
@@ -32,14 +32,14 @@ mlmmj_process_SOURCES = mlmmj.c mlmmj-process.c  find_email_adr.c \
                        send_mails.c checkwait_smtpreply.c \
                        mail-functions.c init_sockfd.c
 
-mlmmj_sub_SOURCES = mlmmj.c mlmmj-sub.c  mylocking.c \
+mlmmj_sub_SOURCES = mlmmj.c mlmmj-sub.c \
                         chomp.c random-int.c strgen.c \
                        subscriberfuncs.c print-version.c \
                        log_error.c mygetline.c prepstdreply.c memory.c \
                        controls.c readn.c utils.c unistr.c send_mails.c checkwait_smtpreply.c \
                        mail-functions.c init_sockfd.c
 
-mlmmj_unsub_SOURCES = mlmmj.c mlmmj-unsub.c  mylocking.c \
+mlmmj_unsub_SOURCES = mlmmj.c mlmmj-unsub.c  \
                         chomp.c subscriberfuncs.c random-int.c \
                        strgen.c print-version.c log_error.c mygetline.c \
                        prepstdreply.c memory.c controls.c readn.c utils.c \
@@ -55,7 +55,7 @@ mlmmj_bounce_SOURCES = mlmmj.c mlmmj-bounce.c print-version.c log_error.c \
 mlmmj_maintd_SOURCES = mlmmj.c mlmmj-maintd.c print-version.c log_error.c mygetline.c \
                       strgen.c random-int.c chomp.c  memory.c \
                       send_digest.c  dumpfd2fd.c utils.c \
-                      mylocking.c log_oper.c readn.c \
+                      log_oper.c readn.c \
                       prepstdreply.c gethdrline.c unistr.c controls.c \
                       send_mails.c checkwait_smtpreply.c \
                        mail-functions.c init_sockfd.c subscriberfuncs.c
index 855c34b623f6eb84a5151739515c6fa6447f750b..6ce28b0d997707cffcb7eb658890d193fb38118a 100644 (file)
@@ -34,7 +34,6 @@
 #include <string.h>
 
 #include "wrappers.h"
-#include "mylocking.h"
 #include "incindexfile.h"
 #include "itoa.h"
 #include "log_error.h"
index 359d969d7868722a6e3bcb2355b691babfb4e36c..9bdbc0d90d4061e91f6cac264b0b3d2fafdb356a 100644 (file)
@@ -36,7 +36,6 @@
 #include "log_error.h"
 #include "log_oper.h"
 #include "strgen.h"
-#include "mylocking.h"
 #include "wrappers.h"
 #include "memory.h"
 
@@ -66,7 +65,7 @@ int log_oper(const char *prefix, const char *basename, const char *fmt, ...)
                myfree(tmp);
        }
        
-       fd = open(logfilename, O_RDWR|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR);
+       fd = open(logfilename, O_RDWR|O_CREAT|O_APPEND|O_EXLOCK, S_IRUSR|S_IWUSR);
        if(fd < 0) {
                log_error(LOG_ARGS, "Could not open %s", logfilename);
                myfree(logfilename);
@@ -78,12 +77,6 @@ int log_oper(const char *prefix, const char *basename, const char *fmt, ...)
        else
                ct[24] = '\0';
 
-       if(myexcllock(fd) < 0) {
-               log_error(LOG_ARGS, "Could not lock %s", logfilename);
-               myfree(logfilename);
-               return -1;
-       }
-
        va_start(ap, fmt);
        i = vsnprintf(log_msg, sizeof(log_msg), fmt, ap);
        if(i < 0) {
index 9c10e776416d2fe5a2155bf9ae5206af063e2018..9efb08c31d998b5f953566ee726eed367ee47d5e 100644 (file)
@@ -43,7 +43,6 @@
 #include "memory.h"
 #include "controls.h"
 #include "send_digest.h"
-#include "mylocking.h"
 #include "log_oper.h"
 #include "utils.h"
 #include "send_mails.h"
@@ -177,15 +176,10 @@ int discardmail(const char *old, const char *new, time_t age)
        time_t t;
        int fd, ret = 0;
 
-       fd = open(old, O_RDWR);
+       fd = open(old, O_RDWR|O_EXLOCK);
        if(fd < 0)
                return 0;
 
-       if(myexcllock(fd) < 0) {
-               close(fd);
-               return 0;
-       }
-
        stat(old, &st);
        t = time(NULL);
 
index 42f1d6065f14fceeccc3b4fd33cf942416f84d59..2ed84112a52e807cc276eab0a5a5f0cc7997721c 100644 (file)
@@ -56,7 +56,6 @@
 #include "wrappers.h"
 #include "memory.h"
 #include "controls.h"
-#include "mylocking.h"
 #include "getaddrsfromfd.h"
 #include "utils.h"
 #include "send_mails.h"
index d6b7ded8519fa730c84cafd4445c09402895a474..8d4ac8d38e719d041ddcc67960f22e0078169345 100644 (file)
@@ -38,7 +38,6 @@
 
 #include "mlmmj.h"
 #include "mlmmj-sub.h"
-#include "mylocking.h"
 #include "wrappers.h"
 #include "strgen.h"
 #include "subscriberfuncs.h"
diff --git a/src/mylocking.c b/src/mylocking.c
deleted file mode 100644 (file)
index 0501c7e..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (C) 2002, 2003, 2005 Mads Martin Joergensen <mmj at mmj.dk>
- *
- * $Id$
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include "mylocking.h"
-
-int myexcllock(int fd)
-{
-       int excllock;
-       struct flock locktype;
-
-       locktype.l_type = F_WRLCK;
-       locktype.l_whence = SEEK_SET;
-       locktype.l_start = 0;
-       locktype.l_len = 0;
-       do {
-               excllock = fcntl(fd, F_SETLKW, &locktype);
-       } while(excllock < 0 && errno == EINTR);
-
-       return excllock;
-}
-
-int myunlock(int fd)
-{
-       int unlock;
-       struct flock locktype;
-
-       locktype.l_type = F_UNLCK;
-       locktype.l_whence = SEEK_SET;
-       locktype.l_start = 0;
-       locktype.l_len = 0;
-       do {
-               unlock = fcntl(fd, F_SETLKW, &locktype);
-       } while(unlock < 0 && errno == EINTR);
-
-       return unlock;
-}