aboutsummaryrefslogtreecommitdiffstats
path: root/src/gb/gprs_ns.c
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2012-09-28 10:11:25 +0200
committerHarald Welte <laforge@gnumonks.org>2012-09-29 20:36:31 +0200
commitaaccdac55d2adae276c5b882bbc70fe00e191516 (patch)
tree5a8b9e4f48b0c971c1e3a2081e62e639ce7f6a68 /src/gb/gprs_ns.c
parent779d2f42a411fd9ce298c205b797519f64d95bfb (diff)
Fix: gprs_ns_destroy() now frees all NSVCs and its timers
Freeing memory of registered timers and file descriptors cause corrupt lists.
Diffstat (limited to 'src/gb/gprs_ns.c')
-rw-r--r--src/gb/gprs_ns.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index aa7ff939..cdcf36e1 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -920,14 +920,24 @@ struct gprs_ns_inst *gprs_ns_instantiate(gprs_ns_cb_t *cb, void *ctx)
/*! \brief Destroy an entire NS instance
* \param nsi gprs_ns_inst that is to be destroyed
*
- * This function SHOULD release all resources associated with the
- * NS-instance but is actually not completely implemented!
+ * This function releases all resources associated with the
+ * NS-instance.
*/
void gprs_ns_destroy(struct gprs_ns_inst *nsi)
{
- /* FIXME: clear all timers */
+ struct gprs_nsvc *nsvc, *nsvc2;
- /* recursively free the NSI and all its NSVCs */
+ /* delete all NSVCs and clear their timers */
+ llist_for_each_entry_safe(nsvc, nsvc2, &nsi->gprs_nsvcs, list)
+ gprs_nsvc_delete(nsvc);
+
+ /* close socket and unregister */
+ if (nsi->nsip.fd.data) {
+ close(nsi->nsip.fd.fd);
+ osmo_fd_unregister(&nsi->nsip.fd);
+ }
+
+ /* free the NSI */
talloc_free(nsi);
}