aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-18 14:53:46 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-18 14:53:46 +0300
commit7c8140491ce8547fe45a791fb0a185817b5ff8ec (patch)
tree079f04ba8448930c9bc926bd7d2d71a5efa3b04f
parent1c754c175e78d36aec8c4437d5a024169445f798 (diff)
downloadwydawca-7c8140491ce8547fe45a791fb0a185817b5ff8ec.tar.gz
wydawca-7c8140491ce8547fe45a791fb0a185817b5ff8ec.tar.bz2
Remove spool locking
* NEWS: Document changes. * doc/wydawca.texi: Document changes. * src/Makefile.am: Remove lock.c * src/lock.c: Delete. * src/config.c: Remove the locking statement. * tests/etc/wydawca.cfin: Likewise. * src/wydawca.c: Check pidfile before startup, unless in dry-run mode. * src/wydawca.h: Remove prototypes of locking functions * src/process.c (scan_spool_unlocked): Merge into scan_spool. * src/timer.c (struct timer_slot): Use reference counter instead of timer state
-rw-r--r--NEWS15
-rw-r--r--doc/wydawca.texi67
-rw-r--r--src/Makefile.am1
-rw-r--r--src/config.c39
-rw-r--r--src/lock.c275
-rw-r--r--src/process.c54
-rw-r--r--src/timer.c36
-rw-r--r--src/triplet.c51
-rw-r--r--src/wydawca.c28
-rw-r--r--src/wydawca.h15
-rw-r--r--tests/etc/wydawca.cfin2
11 files changed, 83 insertions, 500 deletions
diff --git a/NEWS b/NEWS
index 1f77c3a..3e48f6d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Wydawca NEWS -- history of user-visible changes. 2020-04-17
+Wydawca NEWS -- history of user-visible changes. 2020-04-18
See the end of file for copying conditions.
Please send Wydawca bug reports to <bug-wydawca@gnu.org.ua>.
@@ -35,10 +35,23 @@ where S is the number of configured spools, D is the number of
dictionaries, and T is the maximum number of triplets to handle
simultaneously.
+* Simultaneous use and spool locking
+
+Previous versions of wydawca allowed for several instances to be run
+at the same time. In particular, it allowed for wydawca to be started
+in cron mode while another instance of the program was running as a
+deamon. To prevent two wydawca instances from accessing the same
+spool simultaneously lock files were used.
+
+This version does not allow for such usage. Only one copy of wydawca
+can be running. Therefore spool locking has been discontinued.
+
* Configuration changes
** The wakeup-interval statement removed
+** The locking statement removed
+
** max-connections statement
This new statement configures the maximum number of upload
diff --git a/doc/wydawca.texi b/doc/wydawca.texi
index 4f40cb0..83669f4 100644
--- a/doc/wydawca.texi
+++ b/doc/wydawca.texi
@@ -99,7 +99,6 @@ How to Configure @command{wydawca}.
* user privileges::
* daemon::
* tcp-wrapper::
-* locking::
* syslog::
* sql::
* dictionaries::
@@ -416,9 +415,7 @@ the standard error.
in the command line. Command line options take precedence over
configuration settings. The cron mode is the default. It can also
be requested explicitly, using the @option{--cron} command
-line option. This may be needed, for example, to schedule a daily
-@command{wydawca} run when the main daemon instance is already
-running.
+line option.
@xopindex{daemon, described}
Similarly, the @option{--daemon} option enables daemon mode.
@@ -526,7 +523,6 @@ directives any time by running @command{wydawca --config-help}.
* user privileges::
* daemon::
* tcp-wrapper::
-* locking::
* syslog::
* sql::
* dictionaries::
@@ -1203,51 +1199,6 @@ and @samp{deny-syslog-priority} statements are: @samp{emerg},
@samp{alert}, @samp{crit}, @samp{err}, @samp{warning}, @samp{notice},
@samp{info}, and @samp{debug}.
-@node locking
-@section Locking Configuration
- To avoid a possibility of two @command{wydawca} instances handling
-the same triplet, @command{wydawca} @dfn{locks} the spool before
-processing it. This is done by creating a @dfn{lock file}. The
-parameters of the locking subsystem are configured via the
-@code{locking} statement:
-
-@deffn {Config} locking @{ @dots{} @}
-@smallexample
-locking @{
- enable @var{arg:@i{boolean}};
- directory @var{dir:@i{string}};
- expire-time @var{time:@i{interval}};
- timeout @var{time:@i{interval}};
-@}
-@end smallexample
-@end deffn
-
-@deffn {Config: locking} enable bool
-Enable or disable locking. By default it is enabled.
-@end deffn
-
-@deffn {Config: locking} directory dir
-Sets directory for lock files. Make sure @var{dir} is writable
-for the user (or group) @command{wydawca} runs at (@pxref{user
-privileges}.
-
-The default directory is @file{@var{localstatedir}/@/lock/@/wydawca}.
-@end deffn
-
-@deffn {Config: locking} expire-time time
-Sets expiration interval for lock files. An existing lock file
-older than @var{time} is considered stale and removed.
-
-@xref{time interval specification}, for the syntax of @var{time}.
-@end deffn
-
-@deffn {Config: locking} timeout time
-Timeout for acquiring locks. If a lock file cannot be acquired during
-this time, @command{wydawca} reports error and exits.
-
-@xref{time interval specification}, for the syntax of @var{time}.
-@end deffn
-
@node syslog
@section Syslog Configuration Directives
@cindex syslog, configuration
@@ -3376,22 +3327,6 @@ user @var{name:@i{string}};
# @xref{user privileges}.
group @var{arg:@i{list of string}};
-# @r{Configure locking}
-# @xref{locking}.
-locking @{
- # @r{Enable or disable locking.}
- enable @var{arg:@i{boolean}};
-
- # @r{Set directory for lock files.}
- directory @var{dir:@i{string}};
-
- # @r{Define lock expiration interval.}
- expire-time @var{time:@i{interval}};
-
- # @r{Locking timeout.}
- timeout @var{time:@i{interval}};
-@}
-
# @r{Listen on this address.}
# @xref{daemon, listen}.
listen @var{socket:@i{sock-addr}};
diff --git a/src/Makefile.am b/src/Makefile.am
index 9d9d4d9..f7a2201 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,7 +33,6 @@ wydawca_SOURCES=\
event.c\
gpg.c\
interval.c\
- lock.c\
module.c\
net.c\
pidfile.c\
diff --git a/src/config.c b/src/config.c
index 9c381ea..3be3a00 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1308,40 +1308,6 @@ cb_supp_groups(enum grecs_callback_command cmd, grecs_node_t * node,
return 0;
}
-static struct grecs_keyword locking_kw[] = {
- { "enable", NULL,
- N_("Enable or disable locking"),
- grecs_type_bool, GRECS_DFLT, &enable_locking },
- { "directory", N_("dir"),
- N_("Set directory for lock files"),
- grecs_type_string, GRECS_CONST, &lockdir },
- { "expire-time", N_("interval"),
- N_("Define lock expiration interval"),
- grecs_type_string, GRECS_CONST, &lock_expire_time, 0, cb_interval },
- { "timeout", N_("interval"), N_("Locking timeout"),
- grecs_type_string, GRECS_CONST, &lock_timeout, 0, cb_interval },
- { NULL }
-};
-
-static int
-cb_locking(enum grecs_callback_command cmd, grecs_node_t * node,
- void *varptr, void *cb_data)
-{
- grecs_locus_t *locus = &node->locus;
- grecs_value_t *value = node->v.value;
-
- if (cmd == grecs_callback_set_value) {
- if (!value || value->type != GRECS_TYPE_STRING) {
- grecs_error(value ? &value->locus : locus, 0,
- _("expected scalar value as a tag"));
- return 1;
- }
- grecs_string_convert(&enable_locking, grecs_type_bool,
- value->v.string, locus);
- }
- return 0;
-}
-
static int
cb_load_path(enum grecs_callback_command cmd, grecs_node_t * node,
void *varptr, void *cb_data)
@@ -1481,11 +1447,6 @@ static struct grecs_keyword wydawca_kw[] = {
grecs_type_string, GRECS_CONST,
&max_directive_version, 0, cb_upload_version },
- { "locking", NULL,
- N_("Configure locking"),
- grecs_type_section, GRECS_DFLT, NULL, 0,
- cb_locking, NULL, locking_kw },
-
{ "listen", N_("socket"),
N_("Listen on this address for upload notification connections."),
grecs_type_sockaddr, GRECS_DFLT, &listen_sockaddr, },
diff --git a/src/lock.c b/src/lock.c
deleted file mode 100644
index f2ed532..0000000
--- a/src/lock.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/* wydawca - automatic release submission daemon
- Copyright (C) 2007, 2009-2013, 2017, 2019-2020 Sergey Poznyakoff
-
- Wydawca is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 3 of the License, or (at your
- option) any later version.
-
- Wydawca is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with wydawca. If not, see <http://www.gnu.org/licenses/>. */
-
-#include "wydawca.h"
-
-int enable_locking = 1;
-char *lockdir;
-time_t lock_expire_time = 5 * 60;
-time_t lock_timeout = 60;
-
-#define LOCKFILE_MODE 0644
-
-static int
-stat_check(const char *file, int fd, int links)
-{
- struct stat fn_stat;
- struct stat fd_stat;
- int err = 0;
- int localfd = -1;
-
- if (fd == -1) {
- localfd = open(file, O_RDONLY);
-
- if (localfd == -1)
- return errno;
- fd = localfd;
- }
-
- /* We should always be able to stat a valid fd, so this
- is an error condition. */
- if (lstat(file, &fn_stat) || fstat(fd, &fd_stat))
- err = errno;
- else {
- /* If the link and stat don't report the same info, or the
- file is a symlink, fail the locking. */
-#define CHK(X) if(X) err = EINVAL
-
- CHK(!S_ISREG(fn_stat.st_mode));
- CHK(!S_ISREG(fd_stat.st_mode));
- CHK(fn_stat.st_nlink != links);
- CHK(fn_stat.st_dev != fd_stat.st_dev);
- CHK(fn_stat.st_ino != fd_stat.st_ino);
- CHK(fn_stat.st_mode != fd_stat.st_mode);
- CHK(fn_stat.st_nlink != fd_stat.st_nlink);
- CHK(fn_stat.st_uid != fd_stat.st_uid);
- CHK(fn_stat.st_gid != fd_stat.st_gid);
- CHK(fn_stat.st_rdev != fd_stat.st_rdev);
-
-#undef CHK
- }
- if (localfd != -1)
- close(localfd);
-
- return err;
-}
-
-int
-_lock_internal(const char *file, const char *fname)
-{
- int err = 0;
- int fd;
- FILE *fp;
-
- fd = open(fname, O_WRONLY | O_CREAT | O_EXCL, LOCKFILE_MODE);
- if (fd == -1) {
- if (errno == EEXIST)
- return LOCK_RETRY;
- else {
- wy_log(LOG_ERR, _("cannot create lock file %s: %s"),
- fname, strerror(errno));
- return LOCK_FAILURE;
- }
- }
- close(fd);
-
- /* Try to link to the lockfile. */
- if (link(fname, file) == -1) {
- unlink(fname);
- if (errno == EEXIST)
- return LOCK_RETRY;
- else {
- wy_log(LOG_ERR, _("cannot create lock file %s: %s"),
- file, strerror(errno));
- return LOCK_FAILURE;
- }
- }
-
- if ((fd = open(file, O_RDWR)) == -1) {
- unlink(fname);
- wy_log(LOG_ERR, _("cannot open lock file %s: %s"),
- fname, strerror(errno));
- return LOCK_FAILURE;
- }
-
- err = stat_check(fname, fd, 2);
- if (err) {
- unlink(fname);
- wy_log(LOG_ERR, _("lock file check failed: %s"), strerror(errno));
- return (err == EINVAL) ? LOCK_INVALID : LOCK_FAILURE;
- }
-
- unlink(fname);
-
- fp = fdopen(fd, "w");
- fprintf(fp, "%lu", (unsigned long) getpid());
- fclose(fp);
-
- return 0;
-}
-
-static void
-expire_stale_lock(const char *file)
-{
- int stale = 0;
- char buf[80];
- int fd;
- int len;
-
- fd = open(file, O_RDONLY);
- if (fd == -1)
- return;
-
- len = read(fd, buf, sizeof(buf) - 1);
- if (len > 0) {
- pid_t pid;
-
- buf[len] = 0;
- pid = strtoul(buf, NULL, 10);
- if (pid > 0) {
- /* Process is gone so we try to remove the lock. */
- if (kill(pid, 0) == -1)
- stale = 1;
- } else
- stale = 1; /* Corrupted file, remove the lock. */
- }
-
- if (!stale && lock_expire_time > 0) {
- struct stat stbuf;
- fstat(fd, &stbuf);
- /* The lock has expired. */
- if ((time(NULL) - stbuf.st_mtime) > lock_expire_time)
- stale = 1;
- }
-
- close(fd);
- if (stale)
- unlink(file);
-}
-
-static char *
-host_name()
-{
- static char *hostbuf = NULL;
- size_t size = 0;
- int rc;
-
- if (hostbuf)
- return hostbuf;
-
- do {
- if (!hostbuf) {
- size = 256;
- hostbuf = grecs_malloc(size);
- } else {
- size_t ns = size * 2;
- if (size < ns)
- grecs_alloc_die();
- size = ns;
- hostbuf = grecs_realloc(hostbuf, size);
- }
- }
- while ((rc = gethostname(hostbuf, size)) == -1
- && (errno == EINVAL
-#ifdef ENAMETOOLONG
- || errno == ENAMETOOLONG
-#endif
- ));
- if (rc) {
- wy_log(LOG_ERR, _("cannot get hostname: %s"), strerror(rc));
- exit(EX_SOFTWARE);
- }
- return hostbuf;
-}
-
-int
-wydawca_lock(const char *lockname)
-{
- char *tempname = NULL;
- size_t size = 0;
- int rc;
-
- if (!enable_locking)
- return 0;
- expire_stale_lock(lockname);
-
- /* build the NFS hitching-post to the lock file */
- grecs_asprintf(&tempname, &size, "%s.%lu.%lu.%s",
- lockname,
- (unsigned long) getpid(),
- (unsigned long) time(NULL), host_name());
- if (!tempname)
- return LOCK_FAILURE;
- if (lock_timeout) {
- time_t start = time(NULL);
-
- do {
- rc = _lock_internal(lockname, tempname);
- if (rc == LOCK_RETRY)
- sleep(1);
- else
- break;
- }
- while (time(NULL) - start < lock_timeout);
- } else
- rc = _lock_internal(lockname, tempname);
-
- free(tempname);
- return rc;
-}
-
-void
-wydawca_unlock(const char *lockfile)
-{
- if (enable_locking)
- unlink(lockfile);
-}
-
-static char *
-fix_tagname(const char *tag)
-{
- char *tagname = grecs_strdup(tag);
- char *p;
-
- for (p = tagname; *p; p++)
- if (!isalnum(*p) && *p != '_' && *p != '-')
- *p = '_';
- return tagname;
-}
-
-char *
-wydawca_lockname(const char *tag)
-{
- char *lockname = NULL;
- size_t size = 0;
- char *tagname = fix_tagname(tag);
- grecs_asprintf(&lockname, &size, "%s/LCK.%s", lockdir, tagname);
- if (!lockname)
- grecs_alloc_die();
- free(tagname);
- return lockname;
-}
-
-void
-wydawca_lock_init()
-{
- if (enable_locking) {
- if (!lockdir)
- lockdir = grecs_strdup(LOCALSTATEDIR "/lock/" PACKAGE);
- if (create_hierarchy(AT_FDCWD, lockdir))
- exit(EX_OSFILE);
- }
-}
diff --git a/src/process.c b/src/process.c
index 4c14fd5..beb0d72 100644
--- a/src/process.c
+++ b/src/process.c
@@ -164,12 +164,15 @@ spool_add_new_file(struct spool *spool, const char *name)
/* Scan upload directory from SPOOL and register all files found
there, forming triplets when possible */
-void
-scan_spool_unlocked(struct spool *spool)
+int
+scan_spool(struct spool *spool)
{
DIR *dir;
struct dirent *ent;
+ if (!enabled_spool_p(spool))
+ return -1;
+
wy_debug(1, ("%s -> %s", spool->source_dir,
wy_url_printable(spool->dest_url)));
@@ -177,7 +180,7 @@ scan_spool_unlocked(struct spool *spool)
if (!dir) {
wy_log(LOG_ERR, _("cannot open directory %s: %s"),
spool->source_dir, strerror(errno));
- return;
+ return -1;
}
timer_start("spool");
@@ -194,30 +197,7 @@ scan_spool_unlocked(struct spool *spool)
timer_stop(spool->tag);
timer_stop("spool");
-}
-
-int
-scan_spool(struct spool *spool)
-{
- char *lockfile = wydawca_lockname(spool->tag);
- int rc = wydawca_lock(lockfile);
- switch (rc) {
- case LOCK_OK:
- scan_spool_unlocked(spool);
- wydawca_unlock(lockfile);
- break;
-
- case LOCK_FAILURE:
- wy_log(LOG_ERR, _("cannot lock spool %s"), spool->tag);
- break;
-
- case LOCK_RETRY:
- wy_log(LOG_WARNING, _("timed out while looking spool %s"),
- spool->tag);
- break;
- }
- free(lockfile);
- return rc;
+ return 0;
}
int
@@ -256,26 +236,10 @@ dictionaries_close(void)
}
/* Scan all configured update directories */
-int
-scan_all_spools(void)
-{
- struct spool_list *sp;
- int rc = 0;
-
- timer_start("wydawca");
- for (sp = spool_list; sp; sp = sp->next)
- if (enabled_spool_p(&sp->spool))
- if (scan_spool(&sp->spool))
- rc++;
- timer_stop("wydawca");
- return rc;
-}
-
void
-spool_create_timers()
+scan_all_spools(void)
{
struct spool_list *sp;
-
for (sp = spool_list; sp; sp = sp->next)
- timer_start(sp->spool.tag);
+ scan_spool(&sp->spool);
}
diff --git a/src/timer.c b/src/timer.c
index 268b096..864415c 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -23,7 +23,7 @@
struct timer_slot {
char *name;
- enum { STOPPED, RUNNING } state;
+ size_t refcnt;
double real;
double self_user; /* user time in sec */
double self_system; /* system time in sec */
@@ -85,15 +85,15 @@ get_thread_timer_table(void)
}
/* Lookup a timer by its name. If it does not exist, create it. */
-wydawca_timer_t
-timer_get(const char *name)
+struct timer_slot *
+timer_slot_lookup(const char *name)
{
struct timer_slot slot, *ret;
int install = 1;
- struct grecs_symtab *timer_table = get_thread_timer_table();
slot.name = (char *)name;
- ret = grecs_symtab_lookup_or_install(timer_table, &slot, &install);
+ ret = grecs_symtab_lookup_or_install(get_thread_timer_table(),
+ &slot, &install);
if (!ret)
grecs_alloc_die();
return ret;
@@ -102,12 +102,13 @@ timer_get(const char *name)
wydawca_timer_t
timer_start(const char *name)
{
- wydawca_timer_t t = timer_get(name);
+ wydawca_timer_t t = timer_slot_lookup(name);
- gettimeofday(&t->real_mark, NULL);
- getrusage(RUSAGE_SELF, &t->self_mark);
- getrusage(RUSAGE_CHILDREN, &t->children_mark);
- t->state = RUNNING;
+ if (t->refcnt++ == 0) {
+ gettimeofday(&t->real_mark, NULL);
+ getrusage(RUSAGE_SELF, &t->self_mark);
+ getrusage(RUSAGE_CHILDREN, &t->children_mark);
+ }
return t;
}
@@ -135,13 +136,20 @@ _timer_compute(wydawca_timer_t t)
}
wydawca_timer_t
+timer_get(const char *name)
+{
+ wydawca_timer_t t = timer_slot_lookup(name);
+ if (t->refcnt)
+ _timer_compute(t);
+ return t;
+}
+
+wydawca_timer_t
timer_stop(const char *name)
{
wydawca_timer_t t = timer_get(name);
- if (t->state == RUNNING) {
- _timer_compute(t);
- t->state = STOPPED;
- }
+ if (t->refcnt)
+ --t->refcnt;
return t;
}
diff --git a/src/triplet.c b/src/triplet.c
index d9e503f..3f8536c 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -352,30 +352,34 @@ void
triplet_enqueue(struct wy_triplet *trp)
{
pthread_t tid;
-
+ struct spool *spool = trp->spool;
if (!trp)
return;
- if (spool_open_dictionaries(trp->spool))
- return;
- switch (check_triplet_state(trp)) {
- case triplet_directive:
- case triplet_complete:
- triplet_list_lock(&triplet_pending_list);
- triplet_list_unlink(&triplet_pending_list, trp);
- triplet_list_unlock(&triplet_pending_list);
+ timer_start("spool");
+ timer_start(spool->name);
+ if (spool_open_dictionaries(spool) == 0) {
+ switch (check_triplet_state(trp)) {
+ case triplet_directive:
+ case triplet_complete:
+ triplet_list_lock(&triplet_pending_list);
+ triplet_list_unlink(&triplet_pending_list, trp);
+ triplet_list_unlock(&triplet_pending_list);
- triplet_list_lock(&triplet_running_list);
- triplet_list_insert(&triplet_running_list, trp,
- triplet_running_list.tail, 1);
- triplet_list_unlock(&triplet_running_list);
-
- pthread_create(&tid, NULL, wy_thr_triplet, trp);
- break;
- case triplet_incomplete:
- break;
- case triplet_bad:
- remove_triplet(trp);
+ triplet_list_lock(&triplet_running_list);
+ triplet_list_insert(&triplet_running_list, trp,
+ triplet_running_list.tail, 1);
+ triplet_list_unlock(&triplet_running_list);
+
+ pthread_create(&tid, NULL, wy_thr_triplet, trp);
+ break;
+ case triplet_incomplete:
+ break;
+ case triplet_bad:
+ remove_triplet(trp);
+ }
}
+ timer_stop(spool->name);
+ timer_stop("spool");
}
/* Unlink all parts of the triplet TRP */
@@ -428,7 +432,7 @@ triplet_commit(struct wy_triplet *trp)
process_directives(trp);
timer_stop(trp->spool->tag);
}
- timer_stop("spool");
+ timer_stop("spool");
}
void
@@ -544,10 +548,7 @@ void *
wy_thr_triplet(void *ptr)
{
struct wy_triplet *trp = ptr;
- timer_start("wydawca");
- spool_create_timers();
triplet_commit(trp);
- timer_stop("wydawca");
logstats();
remove_triplet(trp);
return NULL;
@@ -604,7 +605,7 @@ try_timer_var(char **retval, char const *var, size_t len, char **timers)
wydawca_timer_t t = NULL;
if (member(timers, ws.ws_wordv[1]))
- t = timer_stop(ws.ws_wordv[1]);
+ t = timer_get(ws.ws_wordv[1]);
if (t) {
double (*tfn) (wydawca_timer_t) = NULL;
diff --git a/src/wydawca.c b/src/wydawca.c
index 5c7d5d7..31ca52d 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -262,20 +262,6 @@ grecs_print_diag(grecs_locus_t * locus, int err, int errcode,
}
}
-void
-wydawca_daemon()
-{
- if (!foreground) {
- if (daemon(0, 0)) {
- wy_log(LOG_ERR, "%s", strerror(errno));
- exit(EX_OSERR);
- }
- wy_log(LOG_NOTICE, _("daemon launched"));
- }
-
- check_pidfile();
-}
-
#include "cmdline.h"
void
@@ -331,7 +317,13 @@ wy_main(void)
scan_all_spools();
if (wy_mode == WY_MODE_DAEMON) {
- wydawca_daemon();
+ if (!foreground) {
+ if (daemon(0, 0)) {
+ wy_log(LOG_ERR, "%s", strerror(errno));
+ exit(EX_OSERR);
+ }
+ wy_log(LOG_NOTICE, _("daemon launched"));
+ }
// Start cleaner thread
pthread_create(&tid, NULL, wy_thr_cleaner, NULL);
@@ -454,12 +446,12 @@ main(int argc, char **argv)
exit(EX_UNAVAILABLE);
}
- wydawca_lock_init();
-
wy_log(LOG_NOTICE, _("wydawca (%s) started"), PACKAGE_STRING);
+ if (!wy_dry_run)
+ check_pidfile();
wy_main();
-
+
dictionaries_close();
modules_close();
remove_pidfile();
diff --git a/src/wydawca.h b/src/wydawca.h
index c671429..92a73fd 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -390,8 +390,7 @@ enum exec_result wydawca_exec(int argc, const char **argv, int *retcode);
/* Directory scanning and registering */
int scan_spool(struct spool *spool);
-int scan_all_spools(void);
-void spool_create_timers(void);
+void scan_all_spools(void);
struct wy_triplet *spool_add_new_file(struct spool *spool, const char *name);
int spool_open_dictionaries(struct spool *spool);
@@ -521,7 +520,6 @@ double timer_get_real(wydawca_timer_t t);
double timer_get_user(wydawca_timer_t t);
double timer_get_system(wydawca_timer_t t);
char *timer_format_time(double t);
-size_t timer_get_count(void);
void report_init(void);
void report_add(const char *fmt, ...);
@@ -536,17 +534,6 @@ void remove_pidfile(void);
void *wy_thr_listen(void *);
void trim_crlf(char *s);
-#define LOCK_OK 0
-#define LOCK_CONFLICT 1
-#define LOCK_RETRY 2
-#define LOCK_INVALID 3
-#define LOCK_FAILURE 4
-
-char *wydawca_lockname(const char *tag);
-int wydawca_lock(const char *lockname);
-void wydawca_unlock(const char *lockname);
-void wydawca_lock_init(void);
-
/* tcpwrap.h */
extern struct grecs_keyword tcpwrapper_kw[];
int tcpwrap_access(int fd);
diff --git a/tests/etc/wydawca.cfin b/tests/etc/wydawca.cfin
index 1daf435..06461f7 100644
--- a/tests/etc/wydawca.cfin
+++ b/tests/etc/wydawca.cfin
@@ -19,8 +19,6 @@ statistics all;
umask 022;
-locking no;
-
dictionary project-owner {
type builtin;
query "${project}";

Return to:

Send suggestions and report system problems to the System administrator.