Skip to content

Commit

Permalink
Fixed nesting tasks through arguments bug
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Jan 30, 2024
1 parent 89532e8 commit 0ed0eab
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* A bug with adding enumerators to restricted lists has been fixed.
* A bug with applying a new relation to existing data has been fixed.
* A bug with async future error reporting has been fixed.
* A bug with clearing nesting tasks through arguments has been fixed.
* The `change._tasks` structure in C code has been renamed.
This has no impact on user-facing functionality.
* Replaced Docker images _(both tests and builds)_ with newer versions.
Expand Down
5 changes: 5 additions & 0 deletions inc/ti/val.inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,11 @@ static inline _Bool ti_val_is_nil(ti_val_t * val)
return val->tp == TI_VAL_NIL;
}

static inline _Bool ti_val_is_opt_chain(ti_val_t * val)
{
return val->tp == TI_VAL_NIL || val->tp == TI_VAL_ERROR;
}

static inline _Bool ti_val_is_str(ti_val_t * val)
{
return val->tp == TI_VAL_STR || val->tp == TI_VAL_NAME;
Expand Down
2 changes: 1 addition & 1 deletion inc/ti/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* "-rc0"
* ""
*/
#define TI_VERSION_PRE_RELEASE "-alpha10"
#define TI_VERSION_PRE_RELEASE "-alpha11"

#define TI_MAINTAINER \
"Jeroen van der Heijden <jeroen@cesbit.com>"
Expand Down
3 changes: 1 addition & 2 deletions src/ti/do.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,7 @@ static int do__chain(ti_query_t * query, cleri_node_t * nd, ex_t * e)
cleri_node_t * node = child; /* function, assignment, name */
cleri_node_t * index_node = child->next;

if (nd->children->len == 2 &&
(ti_val_is_nil(query->rval) || ti_val_is_error(query->rval)))
if (nd->children->len == 2 && ti_val_is_opt_chain(query->rval))
return 0;

child = child->next->next; /* set to chain child (or NULL) */
Expand Down
12 changes: 10 additions & 2 deletions src/ti/vtask.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void ti_vtask_destroy(ti_vtask_t * vtask)
if (vtask && vtask->id)
{
ti_user_drop(vtask->user);
ti_closure_unsafe_drop(vtask->closure);
ti_closure_drop(vtask->closure);
ti_verror_drop(vtask->verr);
vec_destroy(vtask->args, (vec_destroy_cb) ti_val_unsafe_drop);
}
Expand Down Expand Up @@ -197,7 +197,7 @@ int ti_vtask_run(ti_vtask_t * vtask, ti_collection_t * collection)
static void vtask__clear(ti_vtask_t * vtask)
{
ti_user_drop(vtask->user);
ti_closure_unsafe_drop(vtask->closure);
ti_closure_drop(vtask->closure);
ti_verror_drop(vtask->verr);
vec_destroy(vtask->args, (vec_destroy_cb) ti_val_unsafe_drop);
vtask->id = 0;
Expand All @@ -219,7 +219,15 @@ void ti_vtask_del(uint64_t vtask_id, ti_collection_t * collection)
{
ti_vtask_t * vtask = vec_swap_remove(vtasks, idx);
if (--vtask->ref)
{
++vtask->ref; /* temporary add one reference for when tasks
* are nested in the task arguments */
vtask__clear(vtask);

/* check again as all the references might be cleared by now */
if (!--vtask->ref)
ti_vtask_destroy(vtask);
}
else
ti_vtask_destroy(vtask);
break;
Expand Down

0 comments on commit 0ed0eab

Please sign in to comment.