file-dotlock.c revision 413835a5cf1cb44f62a2adc3123a7d3342b62066
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen/* Copyright (c) 2003-2007 Dovecot authors, see the included COPYING file */
22535a9e685e29214082878e37a267157044618eTimo Sirainen/* 0.1 .. 0.2msec */
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen#define LOCK_RANDOM_USLEEP_TIME (100000 + (unsigned int)rand() % 100000)
9f431ccfb6932746db56245c8a3d3415717ef545Timo Sirainen/* If the dotlock is newer than this, don't verify that the PID it contains
9f431ccfb6932746db56245c8a3d3415717ef545Timo Sirainen is valid (since it most likely is). */
66d2db642fe24d555d113ba463e446b038d476efTimo Sirainen/* Maximum difference between current time and create file's ctime before
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen logging a warning. Should be less than a second in normal operation. */
char *lock_path;
int fd;
struct file_change_info {
struct lock_info {
int fd;
static struct dotlock *
return dotlock;
int fd;
if (ret <= 0)
ret--;
return TRUE;
return FALSE;
bool *changed_r)
bool changed;
int ret;
return ret;
return ret;
if (!changed) {
if (stale_timeout == 0) {
const char *str;
if (p != NULL) {
if (write_pid) {
int fd;
if (write_pid) {
case IO_NOTIFY_ADDED:
case IO_NOTIFY_NOTFOUND:
case IO_NOTIFY_DISABLED:
const char **lock_path_r)
const char *lock_path;
unsigned int stale_notify_threshold;
int ret;
bool do_wait;
if (do_wait) {
if (ret < 0)
tmp_path);
if (ret != 0)
unsigned int secs_left =
if (ret > 0) {
if (ret == 0)
return ret;
int old_errno;
const char *lock_path;
return ret;
int ret;
t_push();
t_pop();
return ret;
const char *lock_path;
const char *lock_path;
int ret;
t_push();
t_pop();
if (ret <= 0) {
const char *lock_path;
int fd;
const char *lock_path;
int ret = 0;
t_push();
t_pop();
return ret;