Changeset 4ff66ae in mainline for uspace/srv/taskman/event.c


Ignore:
Timestamp:
2019-08-07T11:18:35Z (6 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
87a31ef2
Parents:
bb57a00
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-11-13 03:13:03)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 11:18:35)
Message:

taskman: Bind events dump to register handler

  • So that no events are processed twice or omitted.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/taskman/event.c

    rbb57a00 r4ff66ae  
    188188}
    189189
    190 int event_register_listener(task_id_t id, async_sess_t *sess)
     190static bool dump_walker(task_t *t, void *arg)
     191{
     192        event_notify(t, arg);
     193        return true;
     194}
     195
     196void event_register_listener(task_id_t id, bool past_events, async_sess_t *sess,
     197    ipc_callid_t iid)
    191198{
    192199        int rc = EOK;
     200        /*
     201         * We have lock of tasks structures so that we can guarantee
     202         * that dump receiver will receive tasks correctly ordered (retval,
     203         * exit updates are serialized via exclusive lock).
     204         */
    193205        fibril_rwlock_write_lock(&task_hash_table_lock);
    194206        fibril_rwlock_write_lock(&listeners_lock);
     
    203215        t->sess = sess;
    204216
     217        /*
     218         * Answer caller first, so that they are not unnecessarily waiting
     219         * while we dump events.
     220         */
     221        async_answer_0(iid, rc);
     222        if (past_events) {
     223                task_foreach(&dump_walker, t->sess);
     224        }
     225
    205226finish:
    206227        fibril_rwlock_write_unlock(&listeners_lock);
    207228        fibril_rwlock_write_unlock(&task_hash_table_lock);
    208         return rc;
    209 }
    210 
    211 static bool dump_walker(task_t *t, void *arg)
    212 {
    213         event_notify(t, arg);
    214         return true;
    215 }
    216 
    217 void dump_events(task_id_t receiver_id, ipc_callid_t iid)
    218 {
    219         int rc = EOK;
    220         /*
    221          * We have shared lock of tasks structures so that we can guarantee
    222          * that dump receiver will receive tasks correctly ordered (retval,
    223          * exit updates are serialized via exclusive lock).
    224          */
    225         fibril_rwlock_read_lock(&task_hash_table_lock);
    226 
    227         task_t *receiver = task_get_by_id(receiver_id);
    228         if (receiver == NULL) {
    229                 rc = ENOENT;
    230                 goto finish;
    231         }
    232         if (receiver->sess == NULL) {
    233                 rc = ENOENT;
    234                 goto finish;
    235         }
    236 
    237         /*
    238          * Answer caller first, so that they are not unnecessarily waiting
    239          * while we dump events.
    240          */
    241         async_answer_0(iid, rc);
    242         task_foreach(&dump_walker, receiver->sess);
    243 
    244 finish:
    245         fibril_rwlock_read_unlock(&task_hash_table_lock);
    246229        if (rc != EOK) {
    247230                async_answer_0(iid, rc);
Note: See TracChangeset for help on using the changeset viewer.