diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-11-05 13:59:20 +0100 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2013-11-05 13:59:20 +0100 |
commit | ee04e7ef1cd18268a956a4ff3521642b2cfff84e (patch) | |
tree | db91d3c023b08aeafe3f2531ad97873b66d76baa | |
parent | d45b99bd7c998107108126f6fa659399ebc713dd (diff) |
owfd: p2pd: ignore inotify_add_watch() failure
If the parent directory does not exist, yet, we cannot watch it. We would
have to watch the parent of it until the directory itself is created
(maybe multiple layers). Avoid this complexity by just polling with
reasonable timeouts instead.
Same for the file itself which might already exist (due to unclean
shutdown) and might get recreated.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
-rw-r--r-- | src/p2pd_interface.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/p2pd_interface.c b/src/p2pd_interface.c index 8a17864..8f2bfab 100644 --- a/src/p2pd_interface.c +++ b/src/p2pd_interface.c @@ -127,8 +127,10 @@ static int wait_for_wpa(struct owfd_p2pd_interface *iface, w = inotify_add_watch(fd, iface->config->wpa_ctrldir, IN_CREATE | IN_MOVED_TO | IN_ONLYDIR); if (w < 0) { - r = log_ERRNO(); - goto err_close; + /* Ignore failure to watch directory. The directory might not + * have been created, yet (neither it's parents). Avoid any + * complexity to watch the parent-path and just poll for + * changes below with a reasonable sleep-time. */ } /* verify wpa_supplicant is still alive */ @@ -186,14 +188,14 @@ static int wait_for_wpa(struct owfd_p2pd_interface *iface, } /* remove directory watch */ - inotify_rm_watch(fd, w); + if (w >= 0) + inotify_rm_watch(fd, w); /* add socket watch */ w = inotify_add_watch(fd, file, IN_OPEN | IN_DELETE_SELF | IN_MOVE_SELF); if (w < 0) { - r = log_ERRNO(); - goto err_close; + /* see above why we can ignore this */ } /* verify wpa_supplicant is still alive */ |