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
changes/95/16595/3
Harald Welte 3 years ago
parent a49678309d
commit 0fd77a5790
  1. 16
      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;

Loading…
Cancel
Save