Commit ecb3f088 ecb3f088be038c33bef2530c4befaf226f5c1464 by Sergey Poznyakoff

New locker options

1 parent b93d4032
...@@ -46,8 +46,12 @@ ...@@ -46,8 +46,12 @@
46 46
47 #define ARG_LOG_FACILITY 1 47 #define ARG_LOG_FACILITY 1
48 #define ARG_LOCK_FLAGS 2 48 #define ARG_LOCK_FLAGS 2
49 #define ARG_SHOW_OPTIONS 3 49 #define ARG_LOCK_RETRY_COUNT 3
50 #define ARG_LICENSE 4 50 #define ARG_LOCK_RETRY_TIMEOUT 4
51 #define ARG_LOCK_EXPIRE_TIMEOUT 5
52 #define ARG_LOCK_EXTERNAL_PROGRAM 6
53 #define ARG_SHOW_OPTIONS 7
54 #define ARG_LICENSE 8
51 55
52 static struct argp_option mu_common_argp_options[] = 56 static struct argp_option mu_common_argp_options[] =
53 { 57 {
...@@ -69,6 +73,14 @@ static struct argp_option mu_mailbox_argp_option[] = { ...@@ -69,6 +73,14 @@ static struct argp_option mu_mailbox_argp_option[] = {
69 N_("Use specified URL as a mailspool directory"), 0}, 73 N_("Use specified URL as a mailspool directory"), 0},
70 {"lock-flags", ARG_LOCK_FLAGS, N_("FLAGS"), 0, 74 {"lock-flags", ARG_LOCK_FLAGS, N_("FLAGS"), 0,
71 N_("Default locker flags (E=external, R=retry, T=time, P=pid)"), 0}, 75 N_("Default locker flags (E=external, R=retry, T=time, P=pid)"), 0},
76 {"lock-retry-timeout", ARG_LOCK_RETRY_TIMEOUT, N_("SECONDS"), 0,
77 N_("Set timeout for acquiring the lockfile") },
78 {"lock-retry-count", ARG_LOCK_RETRY_COUNT, N_("NUMBER"), 0,
79 N_("Set the maximum number of times to retry acquiring the lockfile") },
80 {"lock-expire-timeout", ARG_LOCK_EXPIRE_TIMEOUT, N_("SECONDS"), 0,
81 N_("Number of seconds after which the lock expires"), },
82 {"external-locker", ARG_LOCK_EXTERNAL_PROGRAM, N_("PATH"), 0,
83 N_("Set full path to the external locker program.") },
72 { NULL, 0, NULL, 0, NULL, 0 } 84 { NULL, 0, NULL, 0, NULL, 0 }
73 }; 85 };
74 86
...@@ -400,10 +412,39 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state) ...@@ -400,10 +412,39 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state)
400 argp_error (state, _("invalid lock flag '%c'"), *arg); 412 argp_error (state, _("invalid lock flag '%c'"), *arg);
401 } 413 }
402 } 414 }
403 locker_set_default_flags (flags); 415 locker_set_default_flags (flags, mu_locker_set_flags);
404 } 416 }
405 break; 417 break;
406 418
419 case ARG_LOCK_RETRY_COUNT:
420 {
421 size_t t = strtoul (arg, NULL, 0);
422 locker_set_default_retry_count (t);
423 locker_set_default_flags (MU_LOCKER_RETRY, mu_locker_set_bit);
424 }
425 break;
426
427 case ARG_LOCK_RETRY_TIMEOUT:
428 {
429 time_t t = strtoul (arg, NULL, 0);
430 locker_set_default_retry_timeout (t);
431 locker_set_default_flags (MU_LOCKER_RETRY, mu_locker_set_bit);
432 }
433 break;
434
435 case ARG_LOCK_EXPIRE_TIMEOUT:
436 {
437 time_t t = strtoul (arg, NULL, 0);
438 locker_set_default_expire_timeout (t);
439 locker_set_default_flags (MU_LOCKER_EXTERNAL, mu_locker_set_bit);
440 }
441 break;
442
443 case ARG_LOCK_EXTERNAL_PROGRAM:
444 locker_set_default_external_program (arg);
445 locker_set_default_flags (MU_LOCKER_TIME, mu_locker_set_bit);
446 break;
447
407 /* address */ 448 /* address */
408 case 'E': 449 case 'E':
409 if ((err = mu_set_user_email(arg)) != 0) 450 if ((err = mu_set_user_email(arg)) != 0)
......