From 0fd77a579057618caaae780f01008e7dab83144d Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 5 Dec 2019 22:05:39 +0100 Subject: [PATCH] bankd: Introduce SIGMAPADD to tell worker about new mapping So far the wokrer used to sleep 10s and only check in those intervals if [finally] a mapping had arrived. Using SIGMAPADD, we can directly break the worker out of its select() call and hence make it pick up a new mapping instantaneously. This also makes RemsimBankd_Tests.TC_removeMapping_connected() pass Change-Id: If0130ab4b49ffcae6ab7a8b9926a6d9477eb3981 --- src/bankd/bankd_main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c index 29a13ed..af25ded 100644 --- a/src/bankd/bankd_main.c +++ b/src/bankd/bankd_main.c @@ -53,9 +53,11 @@ /* signal indicates to worker thread that its map has been deleted */ #define SIGMAPDEL SIGRTMIN+1 +#define SIGMAPADD SIGRTMIN+2 static void handle_sig_usr1(int sig); static void handle_sig_mapdel(int sig); +static void handle_sig_mapadd(int sig); __thread void *talloc_asn1_ctx; struct bankd *g_bankd; @@ -203,8 +205,10 @@ static int bankd_srvc_handle_rx(struct rspro_server_conn *srvc, const RsproPDU_t if (!map) { LOGPFSML(srvc->fi, LOGL_ERROR, "could not create slotmap\n"); resp = rspro_gen_CreateMappingRes(ResultCode_illegalSlotId); - } else + } else { + send_signal_to_worker(NULL, &cs, SIGMAPADD); resp = rspro_gen_CreateMappingRes(ResultCode_ok); + } } send_resp: server_conn_send_rspro(srvc, resp); @@ -359,6 +363,7 @@ int main(int argc, char **argv) g_bankd->main = pthread_self(); signal(SIGMAPDEL, handle_sig_mapdel); + signal(SIGMAPADD, handle_sig_mapadd); signal(SIGUSR1, handle_sig_usr1); /* Np lock or mutex required for the pcsc_slot_names list, as this is only @@ -448,6 +453,13 @@ static void handle_sig_mapdel(int sig) } } +/* signal handler for receiving SIGMAPADD from main thread */ +static void handle_sig_mapadd(int sig) +{ + LOGW(g_worker, "SIGMAPADD received\n"); + /* do nothing */ +} + static void handle_sig_usr1(int sig) { OSMO_ASSERT(sig == SIGUSR1); @@ -769,6 +781,8 @@ restart_wait: if (rc == -1 && errno == EINTR) { if (worker->state == BW_ST_CONN_CLIENT_UNMAPPED) return -23; + else + worker_try_slotmap(worker); goto restart_wait; } else if (rc < 0) return rc;