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
This commit is contained in:
Harald Welte 2019-12-05 22:05:39 +01:00
parent a49678309d
commit 0fd77a5790
1 changed files with 15 additions and 1 deletions

View File

@ -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,9 +205,11 @@ 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);
break;
@ -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;