mirror of https://github.com/PentHertz/srsLTE.git
Fixed case where calling gw::setup_if_addr after ue attachment would spawn a new thread without closing the current one.
This would end up being a resource leak as the number of threads grow forever until the application crashes.
This commit is contained in:
parent
e2facef540
commit
55f5f74ff3
|
@ -54,14 +54,9 @@ public:
|
|||
void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu);
|
||||
|
||||
// NAS interface
|
||||
int setup_if_addr(uint32_t eps_bearer_id,
|
||||
uint8_t pdn_type,
|
||||
uint32_t ip_addr,
|
||||
uint8_t* ipv6_if_addr,
|
||||
char* err_str);
|
||||
int setup_if_addr(uint32_t eps_bearer_id, uint8_t pdn_type, uint32_t ip_addr, uint8_t* ipv6_if_addr, char* err_str);
|
||||
int deactivate_eps_bearer(const uint32_t eps_bearer_id);
|
||||
int apply_traffic_flow_template(const uint8_t& eps_bearer_id,
|
||||
const LIBLTE_MME_TRAFFIC_FLOW_TEMPLATE_STRUCT* tft);
|
||||
int apply_traffic_flow_template(const uint8_t& eps_bearer_id, const LIBLTE_MME_TRAFFIC_FLOW_TEMPLATE_STRUCT* tft);
|
||||
void set_test_loop_mode(const test_loop_mode_state_t mode, const uint32_t ip_pdu_delay_ms);
|
||||
|
||||
// RRC interface
|
||||
|
@ -76,7 +71,7 @@ private:
|
|||
gw_args_t args = {};
|
||||
|
||||
std::atomic<bool> running = {false};
|
||||
bool run_enable = false;
|
||||
std::atomic<bool> run_enable = {false};
|
||||
int32_t netns_fd = 0;
|
||||
int32_t tun_fd = 0;
|
||||
struct ifreq ifr = {};
|
||||
|
|
|
@ -179,6 +179,13 @@ void gw::write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
|
|||
int gw::setup_if_addr(uint32_t eps_bearer_id, uint8_t pdn_type, uint32_t ip_addr, uint8_t* ipv6_if_addr, char* err_str)
|
||||
{
|
||||
int err;
|
||||
|
||||
// Make sure the worker thread is terminated before spawning a new one.
|
||||
if (running) {
|
||||
run_enable = false;
|
||||
thread_cancel();
|
||||
wait_thread_finish();
|
||||
}
|
||||
if (pdn_type == LIBLTE_MME_PDN_TYPE_IPV4 || pdn_type == LIBLTE_MME_PDN_TYPE_IPV4V6) {
|
||||
err = setup_if_addr4(ip_addr, err_str);
|
||||
if (err != SRSRAN_SUCCESS) {
|
||||
|
@ -195,6 +202,7 @@ int gw::setup_if_addr(uint32_t eps_bearer_id, uint8_t pdn_type, uint32_t ip_addr
|
|||
default_eps_bearer_id = static_cast<int>(eps_bearer_id);
|
||||
|
||||
// Setup a thread to receive packets from the TUN device
|
||||
run_enable = true;
|
||||
start(GW_THREAD_PRIO);
|
||||
|
||||
return SRSRAN_SUCCESS;
|
||||
|
@ -446,6 +454,9 @@ int gw::setup_if_addr4(uint32_t ip_addr, char* err_str)
|
|||
}
|
||||
}
|
||||
|
||||
if (sock > 0) {
|
||||
close(sock);
|
||||
}
|
||||
// Setup the IP address
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
ifr.ifr_addr.sa_family = AF_INET;
|
||||
|
@ -495,6 +506,9 @@ int gw::setup_if_addr6(uint8_t* ipv6_if_id, char* err_str)
|
|||
}
|
||||
}
|
||||
|
||||
if (sock > 0) {
|
||||
close(sock);
|
||||
}
|
||||
// Setup the IP address
|
||||
sock = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
ifr.ifr_addr.sa_family = AF_INET6;
|
||||
|
|
Loading…
Reference in New Issue