1.1 --- a/libipc/lib/src/server.c Thu Mar 10 23:23:07 2022 +0100
1.2 +++ b/libipc/lib/src/server.c Fri Mar 11 22:09:09 2022 +0100
1.3 @@ -153,21 +153,24 @@
1.4
1.5 /* A server main loop with no endpoint deletion detection. */
1.6
1.7 -long ipc_server_loop(int expected_items, void *obj,
1.8 - ipc_server_handler_type handler)
1.9 +long ipc_server_loop(int expected_items, ipc_server_config_type *config)
1.10 {
1.11 - return ipc_server_managed_loop(expected_items, obj, L4_INVALID_CAP, handler);
1.12 + return ipc_server_managed_loop(expected_items, config, L4_INVALID_CAP);
1.13 }
1.14
1.15 /* A server main loop handling endpoint deletion for an IPC gate dedicated to
1.16 a particular object within its own thread. */
1.17
1.18 -long ipc_server_managed_loop(int expected_items, void *obj, l4_cap_idx_t irq,
1.19 - ipc_server_handler_type handler)
1.20 +long ipc_server_managed_loop(int expected_items, ipc_server_config_type *config,
1.21 + l4_cap_idx_t irq)
1.22 {
1.23 ipc_message_t msg;
1.24 l4_umword_t label, irq_label = (l4_umword_t) irq;
1.25
1.26 + /* Permit other endpoints by dynamically interpreting the label. */
1.27 +
1.28 + ipc_server_config_type *config_from_label;
1.29 +
1.30 /* Declare the extent to which capabilities are expected in messages. */
1.31
1.32 long err = ipc_message_expect(&msg, expected_items);
1.33 @@ -198,7 +201,10 @@
1.34 /* Message involves the IPC gate itself. */
1.35
1.36 if (label != irq_label)
1.37 - handler(&msg, obj);
1.38 + {
1.39 + config_from_label = (ipc_server_config_type *) label;
1.40 + config_from_label->handler(&msg, config_from_label->handler_obj);
1.41 + }
1.42
1.43 /* Message involves the IRQ or a termination condition occurred. */
1.44
1.45 @@ -219,8 +225,8 @@
1.46 {
1.47 ipc_server_config_type *config = (ipc_server_config_type *) data;
1.48
1.49 - long err = ipc_server_managed_loop(config->expected_items, config->handler_obj,
1.50 - config->irq, config->handler);
1.51 + long err = ipc_server_managed_loop(config->expected_items, config,
1.52 + config->irq);
1.53
1.54 if (config->finaliser != NULL)
1.55 config->finaliser(config);
1.56 @@ -317,7 +323,7 @@
1.57
1.58 if (l4_is_invalid_cap(config->server))
1.59 {
1.60 - err = ipc_server_new_for_thread(&config->server, config->handler_obj, config->thread);
1.61 + err = ipc_server_new_for_thread(&config->server, config, config->thread);
1.62
1.63 if (err)
1.64 return err;