+++ /dev/null
-/* 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 */
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 \
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 \
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
#include <string.h>
#include "wrappers.h"
-#include "mylocking.h"
#include "incindexfile.h"
#include "itoa.h"
#include "log_error.h"
#include "log_error.h"
#include "log_oper.h"
#include "strgen.h"
-#include "mylocking.h"
#include "wrappers.h"
#include "memory.h"
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);
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) {
#include "memory.h"
#include "controls.h"
#include "send_digest.h"
-#include "mylocking.h"
#include "log_oper.h"
#include "utils.h"
#include "send_mails.h"
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);
#include "wrappers.h"
#include "memory.h"
#include "controls.h"
-#include "mylocking.h"
#include "getaddrsfromfd.h"
#include "utils.h"
#include "send_mails.h"
#include "mlmmj.h"
#include "mlmmj-sub.h"
-#include "mylocking.h"
#include "wrappers.h"
#include "strgen.h"
#include "subscriberfuncs.h"
+++ /dev/null
-/* 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;
-}