Change in osmo-remsim[master]: bankd: Introduce SIGMAPADD to tell worker about new mapping

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Dec 17 01:03:03 UTC 2019


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/16595 )

Change subject: bankd: Introduce SIGMAPADD to tell worker about new mapping
......................................................................

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
---
M src/bankd/bankd_main.c
1 file changed, 15 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



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 @@
 			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 @@
 
 	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 @@
 	}
 }
 
+/* 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 @@
 	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;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/16595
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: If0130ab4b49ffcae6ab7a8b9926a6d9477eb3981
Gerrit-Change-Number: 16595
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191217/52ec94d3/attachment.htm>


More information about the gerrit-log mailing list