Rollback hook registration on errors
When subcribing the H_HOOK_INITs, unsubscribe from all
stops again, once a registration is not successful.
The transport does not stop then and should not maintain
any hook registrations (which case errors next time,
which aborts the pausing of the transport).
Change-Id: Ib0ddf1a152507e73f43cd10941b30b0d5a175d03
diff --git a/std/transport.c b/std/transport.c
index 1907f9a..a0e4a8b 100644
--- a/std/transport.c
+++ b/std/transport.c
@@ -568,11 +568,11 @@
}
// subscribes to H_HOOK_INIT in all rooms along the route
-// == 1 for success, < 0 for the number of errors
+// == 1 for success, < -1 if not (at least one hook failed, all registration
+// were already subscribed).
private int subscribe_init()
{
// subscribe to the H_HOOK_INIT of all rooms in the route...
- int no_hook;
foreach(mixed* arr : route)
{
if (arr[0] == HP_ROOM)
@@ -580,10 +580,14 @@
if (arr[1]->HRegisterToHook(H_HOOK_INIT, #'InitHookCallback,
H_HOOK_LIBPRIO(1), H_LISTENER,
0) <= 0)
- --no_hook; // Count non-success while subscribing
+ {
+ // von allen H_HOOK_INIT wieder abmelden...
+ unsubscribe_init();
+ return -1;
+ }
}
}
- return no_hook < 0 ? no_hook : 1;
+ return 1;
}
// unsubscribes from all the H_HOOK_INIT.