chiark / gitweb /
scsi_id: export target port group
[elogind.git] / extras / gudev / gudevclient.c
index bb6d67326f781b94c2aec6f91299295c9c3a64ed..f5f7a198db1a77449045b33f2ea51fe4b654cbd9 100644 (file)
@@ -93,6 +93,8 @@ monitor_event (GIOChannel *source,
   GUdevDevice *device;
   struct udev_device *udevice;
 
+  if (client->priv->monitor == NULL)
+    goto out;
   udevice = udev_monitor_receive_device (client->priv->monitor);
   if (udevice == NULL)
     goto out;
@@ -197,7 +199,7 @@ g_udev_client_constructed (GObject *object)
 
   if (client->priv->subsystems != NULL)
     {
-      /* install subsytem filters to only wake up for certain events */
+      /* install subsystem filters to only wake up for certain events */
       for (n = 0; client->priv->subsystems[n] != NULL; n++)
         {
           gchar *subsystem;
@@ -216,17 +218,21 @@ g_udev_client_constructed (GObject *object)
               *s = '\0';
             }
 
-          udev_monitor_filter_add_match_subsystem_devtype (client->priv->monitor, subsystem, devtype);
+          if (client->priv->monitor != NULL)
+              udev_monitor_filter_add_match_subsystem_devtype (client->priv->monitor, subsystem, devtype);
 
           g_free (subsystem);
         }
 
       /* listen to events, and buffer them */
-      udev_monitor_enable_receiving (client->priv->monitor);
-
-      channel = g_io_channel_unix_new (udev_monitor_get_fd (client->priv->monitor));
-      client->priv->watch_id = g_io_add_watch (channel, G_IO_IN, monitor_event, client);
-      g_io_channel_unref (channel);
+      if (client->priv->monitor != NULL)
+        {
+          udev_monitor_enable_receiving (client->priv->monitor);
+          channel = g_io_channel_unix_new (udev_monitor_get_fd (client->priv->monitor));
+          client->priv->watch_id = g_io_add_watch (channel, G_IO_IN, monitor_event, client);
+          g_io_channel_unref (channel);
+        } else
+          client->priv->watch_id = NULL;
     }
 
   if (G_OBJECT_CLASS (g_udev_client_parent_class)->constructed != NULL)