summaryrefslogtreecommitdiffstats
path: root/sync_watch.cpp
Commit message (Collapse)AuthorAgeFilesLines
* sync/watch: reduce memory usageBrad Bishop2018-12-031-47/+37
| | | | | | | | | | | | | | | | | | | | | 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>
* sync_watch: Handle IN_IGNOREDAdriana Kobylak2018-11-261-37/+51
| | | | | | | | | | | | | | | | | When the hostname is updated via systemd, it modifies the /etc/hostname file in a way that triggers a IN_CLOSE_NOWRITE and IN_IGNORED signal. * When IN_IGNORED is received, re-subscribe the file, since it means that the inotify watch was removed. * A subsequent IN_CLOSE_WRITE signal is received after the re-subscribe which takes care of syncing the hostname file. Tested: The hostname was synced when changed multiple times in a row using the REST API. Change-Id: I30abfcdc8b33f77adc6349d345cc957b07898018 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* clang-format: Update to match docs repoGunnar Mills2018-09-111-4/+7
| | | | | | | | Update the .clang-format file. Now includes header sorting and updating PointerAlignment. Change-Id: I5c7690d8d83cdebe26ff3a73b90a2a8c17dd8054 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* sync_manager: Add callback to do rsyncAdriana Kobylak2018-05-081-2/+37
| | | | | | | | | | | | Call rsync when the subscribed file or directory is modified or deleted. Don't create error logs as syncing is used for backup and does not affect the system's operation. Any errors will be logged into the journal. Closes openbmc/openbmc#2918 Change-Id: I2671f0afd2924c15ea883d4d037c641c6e9680b4 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* sync_manager: Create sync watch classAdriana Kobylak2018-05-081-0/+89
Create a watch class to monitor the files and directories specified in the synclist file. Store the file descriptors and file names in a map to be able to know the full path of the file that triggered the event. The watch descriptor number does not change so it can be a single variable. Change-Id: I211225ddc012af85d9be39ae5d40b8258d73435d Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
OpenPOWER on IntegriCloud