diff options
Diffstat (limited to 'concurrency.c')
-rw-r--r-- | concurrency.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/concurrency.c b/concurrency.c index 81ff7b1..1d06a9c 100644 --- a/concurrency.c +++ b/concurrency.c @@ -49,7 +49,7 @@ spawnthread(Function f, Array *left, Array *right) */ Channel *setupdone = chancreate(sizeof(int), 0); SpawnData *sp = emalloc(sizeof(SpawnData)); - sp->func = f; + sp->func = dupfunction(f); sp->left = left ? duparray(left) : nil; sp->right = duparray(right); sp->setupdone = setupdone; @@ -87,6 +87,8 @@ messagesend(Array *a, int id) td->lastmail = newmail; rwakeup(&td->empty); qunlock(&td->lock); + }else{ + throwerror(L"Invalid thread id", EDomain); } } @@ -134,6 +136,7 @@ newprocfn(void *data) unlock(&threadlock); freearray(sp->left); freearray(sp->right); + freefunction(sp->func); free(sp); free(td); } |