Changeset 62273d1 in mainline for uspace/srv/taskman/main.c


Ignore:
Timestamp:
2019-08-07T04:27:24Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
2f44fafd
Parents:
70d28e8
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-10-08 21:46:22)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 04:27:24)
Message:

taskman: Implement simple task exit monitoring

File:
1 edited

Legend:

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

    r70d28e8 r62273d1  
    7979        async_exchange_end(exch);
    8080
     81        // TODO leak? what happens with referenced sessions
    8182        free(sess_ref);
    8283
     
    116117        int rc = task_set_retval(icall);
    117118        async_answer_0(iid, rc);
     119}
     120
     121static void task_exit_event(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     122{
     123        printf("%s:%i\n", __func__, __LINE__);
     124        // TODO design substitution for taskmon (monitoring)
     125        task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));
     126        task_terminated(id, (task_exit_t)arg);
    118127}
    119128
     
    161170                async_answer_0(iid, ENOMEM);
    162171        }
    163        
    164172
    165173        /* Create callback connection */
     
    170178                return;
    171179        }
     180
     181        /* Remember task_id */
     182        int rc = task_id_intro(icall);
     183
     184        if (rc != EOK) {
     185                async_answer_0(iid, rc);
     186                free(sess_ref);
     187                return;
     188        }
    172189        async_answer_0(iid, EOK);
    173190
     191        /* Notify spawners */
    174192        link_initialize(&sess_ref->link);
    175193        prodcons_produce(&sess_queue, &sess_ref->link);
     
    220238        printf(NAME ": HelenOS task manager\n");
    221239
     240        /* Initialization */
    222241        prodcons_initialize(&sess_queue);
    223242        int rc = task_init();
     
    226245        }
    227246
     247        rc = async_event_subscribe(EVENT_EXIT, task_exit_event, (void *)EVENT_EXIT);
     248        if (rc != EOK) {
     249                printf("Cannot register for exit events (%i).\n", rc);
     250                return rc;
     251        }
     252
     253        rc = async_event_subscribe(EVENT_FAULT, task_exit_event, (void *)EVENT_FAULT);
     254        if (rc != EOK) {
     255                printf("Cannot register for fault events (%i).\n", rc);
     256                return rc;
     257        }
     258
    228259        /* We're service too */
    229260        rc = service_register(SERVICE_TASKMAN);
    230261        if (rc != EOK) {
    231                 printf("Cannot register at naming service (%i).", rc);
     262                printf("Cannot register at naming service (%i).\n", rc);
    232263                return rc;
    233264        }
Note: See TracChangeset for help on using the changeset viewer.