Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tasklet: do not call tasklet callbacks inside tasklet_lock
  • Loading branch information
perexg committed Mar 8, 2016
1 parent e522525 commit 25cb7a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 0 additions & 3 deletions src/dvr/dvr_vfsmgr.c
Expand Up @@ -396,8 +396,6 @@ dvr_get_disk_space_update(const char *path, int locked)
static void
dvr_get_disk_space_tcb(void *opaque, int dearmed)
{
pthread_mutex_unlock(&tasklet_lock);

if (!dearmed) {
htsmsg_t *m = htsmsg_create_map();

Expand All @@ -412,7 +410,6 @@ dvr_get_disk_space_tcb(void *opaque, int dearmed)
dvr_disk_space_check();
}

pthread_mutex_lock(&tasklet_lock);
free(opaque);
}

Expand Down
7 changes: 5 additions & 2 deletions src/main.c
Expand Up @@ -448,16 +448,19 @@ tasklet_thread ( void *aux )
tvh_cond_wait(&tasklet_cond, &tasklet_lock);
continue;
}
/* the callback might re-initiaze tasklet, save everythin */
/* the callback might re-initialize tasklet, save everythin */
TAILQ_REMOVE(&tasklets, tsk, tsk_link);
tsk_cb = tsk->tsk_callback;
opaque = tsk->tsk_opaque;
tsk->tsk_callback = NULL;
if (tsk->tsk_allocated)
free(tsk);
/* now, the callback can be safely called */
if (tsk_cb)
if (tsk_cb) {
pthread_mutex_unlock(&tasklet_lock);
tsk_cb(opaque, 0);
pthread_mutex_lock(&tasklet_lock);
}
}
pthread_mutex_unlock(&tasklet_lock);

Expand Down

0 comments on commit 25cb7a5

Please sign in to comment.