sd-device: check whether filter is updated or not in sd_device_monitor_filter_update()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 25 Nov 2018 05:44:46 +0000 (14:44 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 25 Nov 2018 06:26:43 +0000 (15:26 +0900)
src/libsystemd/sd-device/device-monitor.c

index aaf4f38..ff0fdbc 100644 (file)
@@ -269,11 +269,9 @@ int device_monitor_enable_receiving(sd_device_monitor *m) {
 
         assert_return(m, -EINVAL);
 
-        if (!m->filter_uptodate) {
-                r = sd_device_monitor_filter_update(m);
-                if (r < 0)
-                        return log_debug_errno(r, "sd-device-monitor: Failed to update filter: %m");
-        }
+        r = sd_device_monitor_filter_update(m);
+        if (r < 0)
+                return log_debug_errno(r, "sd-device-monitor: Failed to update filter: %m");
 
         if (!m->bound) {
                 if (bind(m->sock, &m->snl.sa, sizeof(struct sockaddr_nl)) < 0)
@@ -595,6 +593,9 @@ _public_ int sd_device_monitor_filter_update(sd_device_monitor *m) {
 
         assert_return(m, -EINVAL);
 
+        if (m->filter_uptodate)
+                return 0;
+
         if (hashmap_isempty(m->subsystem_filter) &&
             set_isempty(m->tag_filter)) {
                 m->filter_uptodate = true;