Changeset 338a1a76 in mainline


Ignore:
Timestamp:
2020-01-09T01:03:40Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
e7faeba
Parents:
7dd7bc0
git-author:
Matthieu Riolo <matthieu.riolo@…> (2019-12-14 18:05:37)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2020-01-09 01:03:40)
Message:

Correcting sysman registering a port

  • Correcting port handler - the new API does not need to accept the call
  • Allowing multiple registration of event handler
  • removing global variable holding the handler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • abi/include/abi/ipc/interfaces.h

    r7dd7bc0 r338a1a76  
    186186        INTERFACE_PCI =
    187187            FOURCC_COMPACT('p', 'c', 'i', ' ') | IFACE_EXCHANGE_SERIALIZE,
     188        INTERFACE_SYSMAN =
     189            FOURCC_COMPACT('s', 'y', 's', 'm') | IFACE_EXCHANGE_SERIALIZE,
    188190        INTERFACE_TASKMAN_CB =
    189             FOURCC_COMPACT('t', 'a', 's', 'k') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
    190         INTERFACE_SYSMAN =
    191             FOURCC_COMPACT('s', 'y', 's', 'm') | IFACE_EXCHANGE_SERIALIZE
     191            FOURCC_COMPACT('t', 'a', 's', 'k') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK
    192192} iface_t;
    193193
  • uspace/lib/c/generic/task_event.c

    r7dd7bc0 r338a1a76  
    4141#include "private/taskman.h"
    4242
    43 static task_event_handler_t task_event_handler = NULL;
    44 
    45 static void taskman_task_event(ipc_call_t *icall)
     43static void taskman_task_event(ipc_call_t *icall, task_event_handler_t handler)
    4644{
    4745        task_id_t tid = (task_id_t)
     
    5149        int retval = ipc_get_arg5(icall);
    5250
    53         task_event_handler(tid, flags, texit, retval);
     51        handler(tid, flags, texit, retval);
    5452
    5553        async_answer_0(icall, EOK);
     
    5856static void taskman_event_conn(ipc_call_t *icall, void *arg)
    5957{
    60         /* Accept connection */
    61         async_answer_0(icall, EOK);
    62 
    6358        while (true) {
    6459                ipc_call_t call;
     
    6661                if (!async_get_call(&call) || !ipc_get_imethod(&call)) {
    6762                        /* Hangup, end of game */
    68                         break;
     63                        async_answer_0(&call, EOK);
     64                        return;
    6965                }
    7066
    7167                switch (ipc_get_imethod(&call)) {
    7268                case TASKMAN_EV_TASK:
    73                         taskman_task_event(&call);
     69                        taskman_task_event(&call, (task_event_handler_t)arg);
    7470                        break;
    7571                default:
     
    8581errno_t task_register_event_handler(task_event_handler_t handler, bool past_events)
    8682{
    87         /*
    88          * so far support assign once, modification cannot be naïve due to
    89          * races
    90          */
    91         assert(task_event_handler == NULL);
    9283        assert(handler != NULL); /* no support for "unregistration" */
    93 
    94         task_event_handler = handler;
    9584
    9685        async_exch_t *exch = taskman_exchange_begin();
     
    9988        port_id_t port;
    10089        errno_t rc = async_create_callback_port(exch, INTERFACE_TASKMAN_CB, 0, 0,
    101             taskman_event_conn, NULL, &port);
     90            taskman_event_conn, handler, &port);
    10291        taskman_exchange_end(exch);
    10392
Note: See TracChangeset for help on using the changeset viewer.