void mwSession_stop(struct mwSession *s, guint32 reason) { GList *list, *l = NULL; struct mwMsgChannelDestroy *msg; g_return_if_fail(s != NULL); if(mwSession_isStopped(s) || mwSession_isStopping(s)) { g_debug("attempted to stop session that is already stopped/stopping"); return; } state(s, mwSession_STOPPING, GUINT_TO_POINTER(reason)); for(list = l = mwSession_getServices(s); l; l = l->next) mwService_stop(MW_SERVICE(l->data)); g_list_free(list); msg = (struct mwMsgChannelDestroy *) mwMessage_new(mwMessage_CHANNEL_DESTROY); msg->head.channel = MW_MASTER_CHANNEL_ID; msg->reason = reason; /* don't care if this fails, we're closing the connection anyway */ mwSession_send(s, MW_MESSAGE(msg)); mwMessage_free(MW_MESSAGE(msg)); session_buf_free(s); /* close the connection */ io_close(s); state(s, mwSession_STOPPED, GUINT_TO_POINTER(reason)); }
static void recv_destroy(struct mwServiceDirectory *srvc, struct mwChannel *chan, struct mwMsgChannelDestroy *msg) { srvc->channel = NULL; mwService_stop(MW_SERVICE(srvc)); /** @todo session sense service */ }
void mwService_free(struct mwService *srvc) { g_return_if_fail(srvc != NULL); mwService_stop(srvc); if(srvc->clear) srvc->clear(srvc); if(srvc->client_cleanup) srvc->client_cleanup(srvc->client_data); g_free(srvc); }
static void recv_channelDestroy(struct mwService *srvc, struct mwChannel *chan, struct mwMsgChannelDestroy *msg) { struct mwSession *session; struct mwServiceStorage *srvc_stor; g_return_if_fail(srvc != NULL); g_return_if_fail(chan != NULL); session = mwService_getSession(srvc); g_return_if_fail(session != NULL); srvc_stor = (struct mwServiceStorage *) srvc; srvc_stor->channel = NULL; mwService_stop(srvc); mwSession_senseService(session, mwService_getType(srvc)); }