agent: Move inotify code to common and improve it.
authorWerner Koch <wk@gnupg.org>
Sat, 15 Oct 2016 19:35:05 +0000 (21:35 +0200)
committerWerner Koch <wk@gnupg.org>
Sat, 15 Oct 2016 19:35:05 +0000 (21:35 +0200)
commit2f7d4c38c9e7bcc14e6e0bf219d688c40a4afecb
tree5b8d91c526f29c50a24c17492dc807ad9f3ee6f4
parentc318561ef4c97f0c2767aef377531d58174060a1
agent: Move inotify code to common and improve it.

* common/sysutils.c: Include sys/inotify.h.
(my_error_from_syserror, my_error): New.
(gnupg_inotify_watch_socket): New.
(gnupg_inotify_has_name): New.
* agent/gpg-agent.c: Do not include sys/inotify.h.
(my_inotify_is_name): Remove.
(handle_connections): Remove HAVE_INOTIFY_INIT protected code and use
the new functions.
--

When removing not a simple socket file but the entire directory the
old code missed most events and thus did not worked properly.

IN_DELETE_SELF has also been added to the watch list to detect a
removal of the directory.  However, in all tests that event was not
triggered.  The only way it could be triggered was by not watching
the socket dir but an arbitary directory and rmdir that.

GnuPG-bug-id: 2756
Signed-off-by: Werner Koch <wk@gnupg.org>
agent/gpg-agent.c
common/sysutils.c
common/sysutils.h