disco.c
changeset 9 ff475b333e44
parent 8 859e715adfcd
child 12 4d2ac929e61a
equal deleted inserted replaced
8:859e715adfcd 9:ff475b333e44
   221 	}
   221 	}
   222 
   222 
   223 	free_arg_lst (args);
   223 	free_arg_lst (args);
   224 }
   224 }
   225 
   225 
   226 static void disco_free_handlers (void)
   226 static void disco_free_reply_handlers (void)
   227 {
   227 {
   228 	GSList *hel;
   228 	GSList *hel;
   229 
   229 
   230 	if (lconnection) { // XXX more checks?
   230 	// let's hope, that after invalidation, lm will remove and free unreffed by us handler
   231 		// let's hope, that after invalidation, lm will remove and free unreffed by us handler
   231 	for (hel = reply_handlers; hel; hel = hel->next) {
   232 		for (hel = reply_handlers; hel; hel = hel->next) {
   232 		LmMessageHandler *handler = (LmMessageHandler *) hel->data;
   233 			LmMessageHandler *handler = (LmMessageHandler *) hel->data;
   233 		lm_message_handler_invalidate (handler);
   234 			lm_message_handler_invalidate (handler);
       
   235 		}
       
   236 	}
   234 	}
   237 
   235 
   238 	g_slist_free (reply_handlers);
   236 	g_slist_free (reply_handlers);
   239 	reply_handlers = NULL;
   237 	reply_handlers = NULL;
   240 }
   238 }
   241 
   239 
   242 // release handlers before reconnect
   240 // release handlers before reconnect
   243 static void disco_hh (guint32 hid, hk_arg_t *args, gpointer userdata)
   241 static void disco_hh (guint32 hid, hk_arg_t *args, gpointer userdata)
   244 {
   242 {
   245 	hk_arg_t *arg = args;
   243 	hk_arg_t *arg;
   246 
   244 
   247 	for (arg = args; arg->name; arg++) {
   245 	for (arg = args; arg->name; arg++) {
   248 		if (!strcmp (arg->name, "hook") && !strcmp (arg->value, "hook-pre-disconnect")) {
   246 		if (!strcmp (arg->name, "hook") && !strcmp (arg->value, "hook-pre-disconnect")) {
   249 			disco_free_handlers ();
   247 			disco_free_reply_handlers ();
   250 			return;
   248 			return;
   251 		}
   249 		}
   252 	}
   250 	}
   253 }
   251 }
   254 
   252 
   273 }
   271 }
   274 
   272 
   275 void g_module_unload(GModule *module)
   273 void g_module_unload(GModule *module)
   276 {
   274 {
   277 	// release handlers
   275 	// release handlers
   278 	disco_free_handlers ();
   276 	disco_free_reply_handlers ();
   279 
   277 
   280 	// remove hook handler
   278 	// remove hook handler
   281 	hk_del_handler (disco_hh, NULL);
   279 	hk_del_handler (disco_hh, NULL);
   282 
   280 
   283 	// command
   281 	// command