diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2022-10-03 18:53:15 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2022-10-04 16:12:38 +0200 |
commit | 8396471638d95318d41b85bf7f3e4ad7eee678ea (patch) | |
tree | dd1109add22e421c62f5ba16ab6b333863ae99cb | |
parent | 0db38d6521020d76563ca65d8f92d5ca463708b0 (diff) |
osmux: Close osmux socket when bts is freed
Related: SYS#5987
Change-Id: Ibd3faa33b28d45048c340b177f13d5685f41a784
-rw-r--r-- | src/common/osmux.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/common/osmux.c b/src/common/osmux.c index 498fe248..3f137e54 100644 --- a/src/common/osmux.c +++ b/src/common/osmux.c @@ -25,6 +25,7 @@ #include <stdint.h> #include <stdbool.h> #include <inttypes.h> +#include <unistd.h> #include <osmocom/core/logging.h> #include <osmocom/core/utils.h> @@ -288,14 +289,19 @@ int bts_osmux_init(struct gsm_bts *bts) bts->osmux.batch_size = OSMUX_BATCH_DEFAULT_MAX; bts->osmux.dummy_padding = false; INIT_LLIST_HEAD(&bts->osmux.osmux_handle_list); + bts->osmux.fd.fd = -1; return 0; } void bts_osmux_release(struct gsm_bts *bts) { - /* FIXME: not needed? YES,we probably need to iterare over - bts->osmux.osmux_handle_list and free everything there, see - osmux_handle_put() */ + /* bts->osmux.osmux_handle_list should end up empty when all lchans are + * released/freed upon talloc_free(bts). */ + /* If bts->osmux.fd.data is NULL, bts is being released/freed without + * passing bts_osmux_init()/through bts_osmux_open() and hence fd is + * probably 0 (memzeored). Avoid accessing it if not initialized. */ + if (bts->osmux.fd.fd != -1 && bts->osmux.fd.data) + osmo_fd_close(&bts->osmux.fd); } /* Called after config file read, start services */ |