Mercurial > dovecot > core-2.2
view src/lib-storage/index/index-mailbox-check.c @ 903:fd8888f6f037 HEAD
Naming style changes, finally got tired of most of the typedefs. Also the
previous enum -> macro change reverted so that we don't use the highest bit
anymore, that's incompatible with old indexes so they will be rebuilt.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 05 Jan 2003 15:09:51 +0200 |
parents | 3b44bc64afd4 |
children | f782b3319553 |
line wrap: on
line source
/* Copyright (C) 2002 Timo Sirainen */ #include "lib.h" #include "ioloop.h" #include "index-storage.h" #include <stdlib.h> #include <sys/stat.h> static int check_interval = -1; static void check_timeout(void *context, struct timeout *timeout __attr_unused__) { struct index_mailbox *ibox = context; struct stat st; if (ioloop_time - ibox->last_check < check_interval) return; ibox->last_check = ioloop_time; if (stat(ibox->check_path, &st) == 0 && ibox->check_file_stamp != st.st_mtime) { ibox->check_file_stamp = st.st_mtime; ibox->box.sync(&ibox->box, FALSE); } } void index_mailbox_check_add(struct index_mailbox *ibox, const char *path) { const char *str; struct stat st; if (check_interval < 0) { str = getenv("MAILBOX_CHECK_INTERVAL"); check_interval = str == NULL ? 0 : atoi(str); if (check_interval < 0) check_interval = 0; } if (check_interval == 0) return; ibox->check_path = i_strdup(path); ibox->check_file_stamp = stat(path, &st) < 0 ? 0 : st.st_mtime; ibox->check_to = timeout_add(1000, check_timeout, ibox); } void index_mailbox_check_remove(struct index_mailbox *ibox) { if (ibox->check_to != NULL) timeout_remove(ibox->check_to); i_free(ibox->check_path); }