Changeset 1c635d6 in mainline for uspace/app


Ignore:
Timestamp:
2014-08-26T15:12:12Z (12 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

Location:
uspace/app
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/exec.c

    rdf7f5cea r1c635d6  
    9797{
    9898        task_id_t tid;
     99        task_wait_t twait;
    99100        task_exit_t texit;
    100101        char *tmp;
     
    121122        file_handles_p[i] = NULL;
    122123
    123         rc = task_spawnvf(&tid, tmp, (const char **) argv, file_handles_p);
     124        rc = task_spawnvf(&tid, &twait, tmp, (const char **) argv, file_handles_p);
    124125        free(tmp);
    125126
     
    130131        }
    131132       
    132         rc = task_wait(tid, &texit, &retval);
     133        rc = task_wait(&twait, &texit, &retval);
    133134        if (rc != EOK) {
    134135                printf("%s: Failed waiting for command (%s)\n", progname,
  • uspace/app/getterm/getterm.c

    rdf7f5cea r1c635d6  
    165165       
    166166        task_id_t id;
     167        task_wait_t twait;
    167168       
    168         int rc = task_spawnv(&id, cmd, (const char * const *) args);
     169        int rc = task_spawnv(&id, &twait, cmd, (const char * const *) args);
    169170        if (rc != EOK) {
    170171                printf("%s: Error spawning %s (%s)\n", APP_NAME, cmd,
     
    175176        task_exit_t texit;
    176177        int retval;
    177         rc = task_wait(id, &texit, &retval);
     178        rc = task_wait(&twait, &texit, &retval);
    178179        if (rc != EOK) {
    179180                printf("%s: Error waiting for %s (%s)\n", APP_NAME, cmd,
  • 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)
  • uspace/app/redir/redir.c

    rdf7f5cea r1c635d6  
    7575}
    7676
    77 static task_id_t spawn(int argc, char *argv[])
     77static task_id_t spawn(task_wait_t *wait, int argc, char *argv[])
    7878{
    7979        const char **args;
     
    9393        args[argc] = NULL;
    9494       
    95         rc = task_spawnv(&id, argv[0], args);
     95        rc = task_spawnv(&id, wait, argv[0], args);
    9696       
    9797        free(args);
     
    152152         */
    153153        setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
    154        
    155         task_id_t id = spawn(argc - i, argv + i);
     154
     155        task_wait_t wait;       
     156        task_id_t id = spawn(&wait, argc - i, argv + i);
    156157       
    157158        if (id != 0) {
    158159                task_exit_t texit;
    159160                int retval;
    160                 task_wait(id, &texit, &retval);
     161                task_wait(&wait, &texit, &retval);
    161162               
    162163                return retval;
  • uspace/app/sbi/src/os/helenos.c

    rdf7f5cea r1c635d6  
    250250{
    251251        task_id_t tid;
     252        task_wait_t twait;
    252253        task_exit_t texit;
    253254        int rc, retval;
    254255
    255         rc = task_spawnv(&tid, cmd[0], (char const * const *) cmd);
     256        rc = task_spawnv(&tid, &twait, cmd[0], (char const * const *) cmd);
    256257        if (rc != EOK) {
    257258                printf("Error: Failed spawning '%s' (%s).\n", cmd[0],
     
    261262
    262263        /* XXX Handle exit status and return value. */
    263         rc = task_wait(tid, &texit, &retval);
     264        rc = task_wait(&twait, &texit, &retval);
    264265        (void) rc;
    265266
  • uspace/app/trace/trace.c

    rdf7f5cea r1c635d6  
    876876                printf("Waiting for task to exit.\n");
    877877
    878                 rc = task_wait(task_id, &texit, &retval);
     878                rc = task_wait_task_id(task_id, &texit, &retval);
    879879                if (rc != EOK) {
    880880                        printf("Failed waiting for task.\n");
  • uspace/app/viewer/viewer.c

    rdf7f5cea r1c635d6  
    4444#include <surface.h>
    4545#include <codec/tga.h>
     46#include <task.h>
    4647
    4748#define NAME  "viewer"
  • uspace/app/vlaunch/vlaunch.c

    rdf7f5cea r1c635d6  
    9494       
    9595        task_id_t id;
    96         int rc = task_spawnl(&id, app, app, winreg, NULL);
     96        task_wait_t wait;
     97        int rc = task_spawnl(&id, &wait, app, app, winreg, NULL);
    9798        if (rc != EOK) {
    9899                printf("%s: Error spawning %s %s (%s)\n", NAME, app,
     
    103104        task_exit_t texit;
    104105        int retval;
    105         rc = task_wait(id, &texit, &retval);
     106        rc = task_wait(&wait, &texit, &retval);
    106107        if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) {
    107108                printf("%s: Error retrieving retval from %s (%s)\n", NAME,
Note: See TracChangeset for help on using the changeset viewer.