Ejemplo n.º 1
0
/**
 * Destroy a UPnP service
 *
 * @param service The service to destroy
 * @return -1 on errors, 0 on success
 */
gint sib_controller_destroy(SIBController* self)
{

  whiteboard_log_debug_fb();

  g_return_val_if_fail(self != NULL, -1);

  /* Ensure that the ctrl is stopped */
  sib_controller_stop(self);

  g_hash_table_destroy(self->services);
  
  sib_controller_lock(self);

  sib_controller_unlock(self);

  whiteboard_log_debug_fe();

  return 0;
}
/**
 * Stop a UPnP service.
 *
 * @param service The service to stop
 * @return -1 on errors, 0 on success
 */
gint sib_service_stop(SIBService* service)
{
  whiteboard_log_debug_fb();

  g_return_val_if_fail(service != NULL, -1);
  g_return_val_if_fail(service->main_loop != NULL, -1);

  if (g_main_loop_is_running(service->main_loop) == TRUE)
    {
      /* Ensure that there are no servers left in the cache */
      whiteboard_log_debug("Cleaning SIBServer list\n");
      //sib_service_lock(service);
      while (service->siblist != NULL )
	{
	  GList *item = service->siblist;
	  service->siblist = g_list_remove_link(service->siblist,
						item);
	  
	  sib_server_unref((SIBServer*)item->data);
	  
	  g_list_free(item);
	}
      // sib_service_unlock(service);
      

      sib_controller_stop(service->controller);
      service->ctrl_running = FALSE;
      
      

      g_main_loop_quit(service->main_loop);
    }

  whiteboard_log_debug_fe();

  return 0;
}