sync/watch: reduce memory usage

Currently we get a different inotify handle for every file in the
synclist, and register all of them with sd_event.  A single fd will
work and saves memory in libsystemd and the kernel, so do that instead.

This in turn allows the fileMap structure to be simplified down to a
basic map of watch descriptor / filename pairs.

Remove redundant calls to both close and inotify_rm_watch - let the
kernel do the work for us.  From the inotify man page:

  When all file descriptors referring to an inotify instance have been
  closed (using close(2)), the underlying object and its resources are
  freed for reuse by the kernel; all associated watches are auto‐
  matically freed.

Change-Id: Ia63cb667cdf41c171276a0351d95347a54578f2f
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
2 files changed