const char *lock_file,
int fd,
ino_t inode,
- unsigned long recheck_interval)
+ unsigned long recheck_interval,
+ bool send_pings)
{
struct tevent_req *req, *subreq;
struct lock_test_child_state *state;
+ unsigned int interval = send_pings ? 1 : 0;
req = tevent_req_create(mem_ctx, &state, struct lock_test_child_state);
if (req == NULL) {
return NULL;
}
- subreq = tmon_ping_send(state, ev, fd, TMON_FD_BOTH, 0, 0);
+ subreq = tmon_ping_send(state, ev, fd, TMON_FD_BOTH, 0, interval);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
static void lock_test_child(const char *lock_file,
int lock_fd,
int pipe_fd,
- unsigned long recheck_interval)
+ unsigned long recheck_interval,
+ bool send_pings)
{
struct tevent_context *ev;
struct tevent_req *req;
lock_file,
pipe_fd,
inode,
- recheck_interval);
+ recheck_interval,
+ send_pings);
if (req == NULL) {
fprintf(stderr,
"%s: lock_test_child_send() failed\n",
struct tevent_context *ev,
const char *lock_file,
int *fdp,
- unsigned long recheck_interval)
+ unsigned long recheck_interval,
+ unsigned long ping_timeout)
{
struct tevent_req *req, *subreq;
struct lock_test_state *state;
close(sv[0]);
TALLOC_FREE(ev);
- lock_test_child(lock_file, *fdp, sv[1], recheck_interval);
+ lock_test_child(lock_file,
+ *fdp,
+ sv[1],
+ recheck_interval,
+ ping_timeout != 0);
/* Above does not return */
}
state->pipe_fd = sv[0];
state->child_pid = pid;
- subreq = tmon_ping_send(state, ev, sv[0], TMON_FD_BOTH, 0, 0);
+ subreq = tmon_ping_send(state, ev, sv[0], TMON_FD_BOTH, ping_timeout, 0);
if (tevent_req_nomem(subreq, req)) {
close(sv[0]);
return tevent_req_post(req, ev);
pid_t ppid,
const char *lock_file,
int *fdp,
- unsigned long recheck_interval)
+ unsigned long recheck_interval,
+ unsigned long ping_timeout)
{
struct tevent_req *req, *subreq;
struct wait_for_exit_state *state;
ev,
lock_file,
fdp,
- recheck_interval);
+ recheck_interval,
+ ping_timeout);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
static void usage(void)
{
- fprintf(stderr, "Usage: %s <file> [recheck_interval]\n", progname);
+ fprintf(stderr,
+ "Usage: %s <file> [recheck_interval [ping_timeout]]\n",
+ progname);
}
int main(int argc, char *argv[])
int ppid;
const char *file = NULL;
unsigned long recheck_interval;
+ unsigned long ping_timeout;
int ret;
int fd = -1;
struct tevent_req *req;
strlcpy(progpath, argv[0], sizeof(progpath));
progname = basename(progpath);
- if (argc < 2 || argc > 3) {
+ if (argc < 2 || argc > 4) {
usage();
exit(1);
}
file = argv[1];
recheck_interval = 5;
- if (argc == 3) {
+ ping_timeout = 0;
+ if (argc >= 3) {
recheck_interval = smb_strtoul(argv[2],
NULL,
10,
exit(1);
}
}
+ if (argc >= 4) {
+ ping_timeout = smb_strtoul(argv[3],
+ NULL,
+ 10,
+ &ret,
+ SMB_STR_STANDARD);
+ if (ret != 0) {
+ usage();
+ exit(1);
+ }
+ }
result = fcntl_lock(file, &fd);
sys_write(STDOUT_FILENO, &result, 1);
return 0;
}
- req = wait_for_exit_send(ev, ev, ppid, file, &fd, recheck_interval);
+ req = wait_for_exit_send(ev,
+ ev,
+ ppid,
+ file,
+ &fd,
+ recheck_interval,
+ ping_timeout);
if (req == NULL) {
fprintf(stderr,
"%s: wait_for_exit_send() failed\n",