Changeset 1c635d6 in mainline for uspace/app/init/init.c


Ignore:
Timestamp:
2014-08-26T15:12:12Z (10 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
613d644
Parents:
df7f5cea
Message:

Do not hold a task's return value after it has disconnected.

Holding the task's return value meant that if nobody waited
for task's result, it polluted NS's memory. This was apparently
done because of a race between spawning a task and waiting for it.

We solve this problem in another way: ns discards the return value
as soon as the task disconnects from it. This typically happens
when the task finishes its execution. In order to avoid the race,
we send the wait request to ns while spawning the task (i.e. when
we talk to the loader), but before we allow the loaded program
to run.

Fixes #132

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/init/init.c

    rdf7f5cea r1c635d6  
    172172        va_start(ap, path);
    173173        task_id_t id;
    174         int rc = task_spawn(&id, path, cnt, ap);
     174        task_wait_t wait;
     175        int rc = task_spawn(&id, &wait, path, cnt, ap);
    175176        va_end(ap);
    176177       
     
    189190        task_exit_t texit;
    190191        int retval;
    191         rc = task_wait(id, &texit, &retval);
     192        rc = task_wait(&wait, &texit, &retval);
    192193        if (rc != EOK) {
    193194                printf("%s: Error waiting for %s (%s)\n", NAME, path,
     
    253254       
    254255        task_id_t id;
    255         int rc = task_spawnl(&id, app, app, winreg, NULL);
     256        task_wait_t wait;
     257        int rc = task_spawnl(&id, &wait, app, app, winreg, NULL);
    256258        if (rc != EOK) {
    257259                printf("%s: Error spawning %s %s (%s)\n", NAME, app,
     
    262264        task_exit_t texit;
    263265        int retval;
    264         rc = task_wait(id, &texit, &retval);
     266        rc = task_wait(&wait, &texit, &retval);
    265267        if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) {
    266268                printf("%s: Error retrieving retval from %s (%s)\n", NAME,
     
    278280                    APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
    279281               
    280                 int rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, svc,
     282                int rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
    281283                    LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
    282284                if (rc != EOK)
     
    287289                    APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
    288290               
    289                 int rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, svc,
     291                int rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
    290292                    LOCFS_MOUNT_POINT, "--wait", "--", app, NULL);
    291293                if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.