From 1df60139e27ec58eb59812043e46339b15d707e6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt <robert.schmidt@openairinterface.org> Date: Thu, 30 Jun 2022 14:43:15 +0200 Subject: [PATCH] Automatically close GTP sockets at program end --- openair3/ocp-gtpu/gtp_itf.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index dc93960e5e3..afef8ea4357 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -142,6 +142,12 @@ class gtpEndPoints { pthread_mutex_t gtp_lock=PTHREAD_MUTEX_INITIALIZER; // the instance id will be the Linux socket handler, as this is uniq map<int, gtpEndPoint> instances; + + ~gtpEndPoints() { + // automatically close all sockets on quit + for (const auto p : instances) + close(p.first); + } }; gtpEndPoints globGtp; -- GitLab