laforge submitted this change.
bankd: implicit remove a client mapping when creating a new mapping
After a desynchronisation between the server and bankd happen (e.g. restart
the server), the server might request a mapping between a client slot and a
bankd slot while the bankd still has a different mapping for the same client
slot.
Example before this commit:
* server -> bankd: New Mapping (client 1/0, bankd 1/0)
* server <- bankd: Ack
* Restart server
* server -> bankd: New Mapping (client 1/0, bankd 2/0)
* server <- bankd: Reject (commit change to Ack)
Previous the second mapping got rejected, while the server
had no chance of knowing or asking the bankd about the old mapping.
Related: SYS#7470
Change-Id: Iae3f86a6e695e2d6580151b203df1dd0e2db625b
---
M src/bankd/bankd_main.c
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c
index c43fe97..fe11497 100644
--- a/src/bankd/bankd_main.c
+++ b/src/bankd/bankd_main.c
@@ -207,7 +207,8 @@
} else {
rspro2bank_slot(&bs, &creq->bank);
rspro2client_slot(&cs, &creq->client);
- /* check if map exists */
+
+ /* check if slot map exists */
map = slotmap_by_bank(g_bankd->slotmaps, &bs);
if (map) {
if (client_slot_equals(&map->client, &cs)) {
@@ -215,10 +216,20 @@
resp = rspro_gen_CreateMappingRes(ResultCode_ok);
goto send_resp;
} else {
- LOGPFSML(srvc->fi, LOGL_NOTICE, "implicitly removing slotmap\n");
+ LOGPFSML(srvc->fi, LOGL_NOTICE, "slot already connected to client %d:%d. Removing old mapping.\n",
+ map->client.client_id, map->client.slot_nr);
bankd_srvc_remove_mapping(map);
}
}
+
+ /* check if client map exists */
+ map = slotmap_by_client(g_bankd->slotmaps, &cs);
+ if (map) {
+ LOGPFSML(srvc->fi, LOGL_NOTICE, "client already connected to slot %d:%d. Removing old mapping.\n",
+ map->bank.bank_id, map->bank.slot_nr);
+ bankd_srvc_remove_mapping(map);
+ }
+
/* Add a new mapping */
map = slotmap_add(g_bankd->slotmaps, &bs, &cs);
if (!map) {
To view, visit change 40570. To unsubscribe, or for help writing mail filters, visit settings.