Logo Search packages:      
Sourcecode: hal version File versions

int hal_shutdown ( LibHalContext ctx  ) 

Shutdown the HAL library. All resources allocated are freed.

Parameters:
ctx The context for the connection to hald
Returns:
Zero if the shutdown went well, otherwise non-zero if an error occured

Definition at line 687 of file libhal.c.

References LibHalContext_s::connection, LibHalContext_s::is_initialized, and LibHalContext_s::is_shutdown.

Referenced by main().

{
      DBusError error;

      if (!ctx->is_initialized)
            return 1;

      /* unsubscribe the match rule we added in initialize; this is safe even with multiple
       * instances of libhal running - see the dbus docs */
      dbus_error_init (&error);
      dbus_bus_remove_match (ctx->connection,
                         "type='signal',"
                         "interface='org.freedesktop.Hal.Manager',"
                         "sender='org.freedesktop.Hal',"
                         "path='/org/freedesktop/Hal/Manager'", &error);
      if (dbus_error_is_set (&error)) {
            fprintf (stderr, "%s %d : Error removing match rule, error=%s\r\n",
                   __FILE__, __LINE__, error.message);
      }

      /* TODO: remove all other match rules */

      /* set a flag so we don't propagte callbacks from this context anymore */
      ctx->is_shutdown = TRUE;

      /* yikes, it's dangerous to unref the connection since it will terminate the process
       * because this connection may be shared so we cannot set the exit_on_disconnect flag
       *
       * so we don't do that right now 
       *
       */
      /*dbus_connection_unref (ctx->connection);*/

      /* we also refuse to free the resources as filter_function may reference these 
       * 
       * should free async when our connection goes away.
       */
      /* free (ctx); */
      return 0;
}


Generated by  Doxygen 1.6.0   Back to index