Changeset 613d644 in mainline for uspace/srv


Ignore:
Timestamp:
2014-08-26T15:30:15Z (11 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0b811da2, 2cc1ec0, da904f7
Parents:
cb1fd3e (diff), 1c635d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge fix for leaking task retvals in ns

Location:
uspace/srv
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/audio/hound/main.c

    rcb1fd3e r613d644  
    4343#include <hound/server.h>
    4444#include <hound/protocol.h>
     45#include <task.h>
    4546
    4647#include "hound.h"
  • uspace/srv/bd/sata_bd/sata_bd.c

    rcb1fd3e r613d644  
    4545#include <loc.h>
    4646#include <macros.h>
     47#include <task.h>
    4748
    4849#include <ahci_iface.h>
  • uspace/srv/devman/driver.c

    rcb1fd3e r613d644  
    4040#include <str_error.h>
    4141#include <stdio.h>
     42#include <task.h>
    4243
    4344#include "dev.h"
     
    290291        log_msg(LOG_DEFAULT, LVL_DEBUG, "start_driver(drv=\"%s\")", drv->name);
    291292       
    292         rc = task_spawnl(NULL, drv->binary_path, drv->binary_path, NULL);
     293        rc = task_spawnl(NULL, NULL, drv->binary_path, drv->binary_path, NULL);
    293294        if (rc != EOK) {
    294295                log_msg(LOG_DEFAULT, LVL_ERROR, "Spawning driver `%s' (%s) failed: %s.",
  • uspace/srv/hid/isdv4_tablet/main.c

    rcb1fd3e r613d644  
    3636#include <ipc/mouseev.h>
    3737#include <inttypes.h>
     38#include <task.h>
    3839
    3940#include "isdv4.h"
  • uspace/srv/hid/remcons/remcons.c

    rcb1fd3e r613d644  
    226226       
    227227        task_id_t task;
    228         int rc = task_spawnl(&task, APP_GETTERM, APP_GETTERM, user->service_name,
     228        task_wait_t wait;
     229        int rc = task_spawnl(&task, &wait, APP_GETTERM, APP_GETTERM, user->service_name,
    229230            "/loc", "--msg", "--", APP_SHELL, NULL);
    230231        if (rc != EOK) {
     
    246247        task_exit_t task_exit;
    247248        int task_retval;
    248         task_wait(task, &task_exit, &task_retval);
     249        task_wait(&wait, &task_exit, &task_retval);
    249250        telnet_user_log(user, "%s terminated %s, exit code %d.", APP_GETTERM,
    250251            task_exit == TASK_EXIT_NORMAL ? "normally" : "unexpectedly",
  • uspace/srv/hid/rfb/main.c

    rcb1fd3e r613d644  
    3535#include <inttypes.h>
    3636#include <io/log.h>
     37#include <task.h>
    3738
    3839#include <abi/fb/visuals.h>
  • uspace/srv/net/ethip/ethip.c

    rcb1fd3e r613d644  
    4444#include <stdio.h>
    4545#include <stdlib.h>
     46#include <task.h>
    4647#include "arp.h"
    4748#include "ethip.h"
  • uspace/srv/net/inetsrv/inetsrv.c

    rcb1fd3e r613d644  
    4646#include <stdlib.h>
    4747#include <sys/types.h>
     48#include <task.h>
    4849#include "addrobj.h"
    4950#include "icmp.h"
  • uspace/srv/net/loopip/loopip.c

    rcb1fd3e r613d644  
    4444#include <stdio.h>
    4545#include <stdlib.h>
     46#include <task.h>
    4647
    4748#define NAME  "loopip"
  • uspace/srv/net/nconfsrv/nconfsrv.c

    rcb1fd3e r613d644  
    4848#include <stdlib.h>
    4949#include <sys/types.h>
     50#include <task.h>
    5051#include "iplink.h"
    5152#include "nconfsrv.h"
  • uspace/srv/net/slip/slip.c

    rcb1fd3e r613d644  
    4343#include <io/log.h>
    4444#include <errno.h>
     45#include <task.h>
    4546
    4647#define NAME            "slip"
  • uspace/srv/ns/ns.c

    rcb1fd3e r613d644  
    6666        while (true) {
    6767                process_pending_conn();
    68                 process_pending_wait();
    6968               
    7069                ipc_call_t call;
  • uspace/srv/ns/task.c

    rcb1fd3e r613d644  
    4040#include <macros.h>
    4141#include <malloc.h>
     42#include <types/task.h>
    4243#include "task.h"
    4344#include "ns.h"
    4445
    45 
    46 /* TODO:
    47  *
    48  * As there is currently no convention that each task has to be waited
    49  * for, the NS can leak memory because of the zombie tasks.
    50  *
    51  */
    5246
    5347/** Task hash table item. */
     
    195189                }
    196190               
    197                 hash_table_remove(&task_hash_table, &pr->id);
    198191                list_remove(&pr->link);
    199192                free(pr);
     
    204197void wait_for_task(task_id_t id, ipc_call_t *call, ipc_callid_t callid)
    205198{
    206         sysarg_t retval;
    207         task_exit_t texit;
    208         bool remove = false;
    209        
    210199        ht_link_t *link = hash_table_find(&task_hash_table, &id);
    211200        hashed_task_t *ht = (link != NULL) ?
     
    218207        }
    219208       
    220         if (!ht->finished) {
    221                 /* Add to pending list */
    222                 pending_wait_t *pr =
    223                     (pending_wait_t *) malloc(sizeof(pending_wait_t));
    224                 if (!pr) {
    225                         retval = ENOMEM;
    226                         goto out;
    227                 }
    228                
    229                 link_initialize(&pr->link);
    230                 pr->id = id;
    231                 pr->callid = callid;
    232                 list_append(&pr->link, &pending_wait);
     209        if (ht->finished) {
     210                task_exit_t texit = ht->have_rval ? TASK_EXIT_NORMAL :
     211                    TASK_EXIT_UNEXPECTED;
     212                ipc_answer_2(callid, EOK, texit, ht->retval);
    233213                return;
    234214        }
    235215       
    236         remove = true;
    237         retval = EOK;
    238        
    239 out:
    240         if (!(callid & IPC_CALLID_NOTIFICATION)) {
    241                 texit = ht->have_rval ? TASK_EXIT_NORMAL : TASK_EXIT_UNEXPECTED;
    242                 ipc_answer_2(callid, retval, texit, ht->retval);
    243         }
    244         if (remove)
    245                 hash_table_remove_item(&task_hash_table, link);
     216        /* Add to pending list */
     217        pending_wait_t *pr =
     218            (pending_wait_t *) malloc(sizeof(pending_wait_t));
     219        if (!pr) {
     220                if (!(callid & IPC_CALLID_NOTIFICATION))
     221                        ipc_answer_0(callid, ENOMEM);
     222                return;
     223        }
     224       
     225        link_initialize(&pr->link);
     226        pr->id = id;
     227        pr->callid = callid;
     228        list_append(&pr->link, &pending_wait);
    246229}
    247230
     
    314297        ht->retval = IPC_GET_ARG1(*call);
    315298       
     299        process_pending_wait();
     300       
    316301        return EOK;
    317302}
     
    336321        ht->finished = true;
    337322       
     323        process_pending_wait();
     324        hash_table_remove(&task_hash_table, &id);
     325       
    338326        return EOK;
    339327}
  • uspace/srv/ns/task.h

    rcb1fd3e r613d644  
    3535
    3636#include <ipc/common.h>
    37 #include <task.h>
     37#include <abi/proc/task.h>
    3838
    3939extern int task_init(void);
  • uspace/srv/taskmon/taskmon.c

    rcb1fd3e r613d644  
    8282
    8383                printf(NAME ": Executing %s -c %s -t %s\n", fname, dump_fname, s_taskid);
    84                 rc = task_spawnl(NULL, fname, fname, "-c", dump_fname, "-t", s_taskid,
     84                rc = task_spawnl(NULL, NULL, fname, fname, "-c", dump_fname, "-t", s_taskid,
    8585                    NULL);
    8686        } else {
    8787                printf(NAME ": Executing %s -t %s\n", fname, s_taskid);
    88                 rc = task_spawnl(NULL, fname, fname, "-t", s_taskid, NULL);
     88                rc = task_spawnl(NULL, NULL, fname, fname, "-t", s_taskid, NULL);
    8989        }
    9090
Note: See TracChangeset for help on using the changeset viewer.