mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
Clean up cothread destruction code
Original commit message from CVS: Clean up cothread destruction code
This commit is contained in:
parent
384d119c72
commit
af978603db
1 changed files with 13 additions and 61 deletions
|
@ -183,15 +183,19 @@ cothread_context_free (cothread_context *ctx)
|
||||||
|
|
||||||
GST_INFO (GST_CAT_COTHREADS, "free cothread context");
|
GST_INFO (GST_CAT_COTHREADS, "free cothread context");
|
||||||
|
|
||||||
for (i = 0; i < COTHREAD_MAXTHREADS; i++) {
|
for (i = 1; i < COTHREAD_MAXTHREADS; i++) {
|
||||||
if (ctx->cothreads[i]) {
|
if (ctx->cothreads[i]) {
|
||||||
cothread_destroy (ctx->cothreads[i]);
|
cothread_destroy (ctx->cothreads[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ctx->cothreads[0]) {
|
||||||
|
g_free(ctx->cothreads[0]);
|
||||||
|
ctx->cothreads[0] = NULL;
|
||||||
|
}
|
||||||
g_hash_table_destroy (ctx->data);
|
g_hash_table_destroy (ctx->data);
|
||||||
/* make sure we free the private key for cothread context */
|
/* make sure we free the private key for cothread context */
|
||||||
GST_INFO (GST_CAT_COTHREADS, "setting private _cothread_ctx_key to NULL in thread %p",
|
GST_INFO (GST_CAT_COTHREADS, "setting private _cothread_ctx_key to NULL in thread %p",
|
||||||
g_thread_self());
|
g_thread_self());
|
||||||
g_static_private_set (&_cothread_ctx_key, NULL, NULL);
|
g_static_private_set (&_cothread_ctx_key, NULL, NULL);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
|
@ -346,66 +350,14 @@ cothread_destroy (cothread_state *cothread)
|
||||||
* with the lock held */
|
* with the lock held */
|
||||||
cothread_unlock (cothread);
|
cothread_unlock (cothread);
|
||||||
|
|
||||||
if (cothreadnum == 0)
|
/* doing cleanups of the cothread create */
|
||||||
{
|
GST_DEBUG (GST_CAT_COTHREADS, "destroy cothread %d with magic number 0x%x",
|
||||||
GST_INFO (GST_CAT_COTHREADS,
|
cothreadnum, cothread->magic_number);
|
||||||
"trying to destroy cothread 0 with %d cothreads left",
|
g_assert (cothread->magic_number == COTHREAD_MAGIC_NUMBER);
|
||||||
ctx->ncothreads);
|
|
||||||
if (ctx->ncothreads > 1)
|
|
||||||
{
|
|
||||||
/* we're trying to destroy cothread 0 when there are still cothreads
|
|
||||||
* active, so kill those first */
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 1; i < COTHREAD_MAXTHREADS; ++i)
|
g_assert (cothread->priv == NULL);
|
||||||
{
|
|
||||||
if (ctx->cothreads[i] != NULL)
|
|
||||||
{
|
|
||||||
cothread_destroy (ctx->cothreads[i]);
|
|
||||||
GST_INFO (GST_CAT_COTHREADS,
|
|
||||||
"destroyed cothread %d, %d cothreads left",
|
|
||||||
i, ctx->ncothreads);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_assert (ctx->ncothreads == 1);
|
|
||||||
GST_INFO (GST_CAT_COTHREADS, "freeing 0th cothread");
|
|
||||||
g_free (cothread);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* int res;
|
|
||||||
* Replaced with version below until cothreads issues solved */
|
|
||||||
int res = 0;
|
|
||||||
|
|
||||||
/* doing cleanups of the cothread create */
|
|
||||||
GST_DEBUG (GST_CAT_COTHREADS, "destroy cothread %d with magic number 0x%x",
|
|
||||||
cothreadnum, cothread->magic_number);
|
|
||||||
g_assert (cothread->magic_number == COTHREAD_MAGIC_NUMBER);
|
|
||||||
|
|
||||||
g_assert (cothread->priv == NULL);
|
memset(cothread,0,sizeof(*cothread));
|
||||||
|
|
||||||
GST_DEBUG (GST_CAT_COTHREADS,
|
|
||||||
"munmap cothread slot stack from %p to %p (size 0x%lx)",
|
|
||||||
cothread, cothread + COTHREAD_STACKSIZE,
|
|
||||||
(long) COTHREAD_STACKSIZE);
|
|
||||||
/* res = munmap (thread, COTHREAD_STACKSIZE);
|
|
||||||
* Commented out waiting for resolution for cothread issue */
|
|
||||||
if (res != 0)
|
|
||||||
{
|
|
||||||
switch (res)
|
|
||||||
{
|
|
||||||
case EINVAL:
|
|
||||||
g_warning ("munmap doesn't like start %p or length %d\n",
|
|
||||||
cothread, COTHREAD_STACKSIZE);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_warning ("Thomas was too lazy to check for all errors, "
|
|
||||||
"so I can't tell you what is wrong.\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GST_DEBUG (GST_CAT_COTHREADS, "munmap done");
|
|
||||||
|
|
||||||
ctx->cothreads[cothreadnum] = NULL;
|
ctx->cothreads[cothreadnum] = NULL;
|
||||||
ctx->ncothreads--;
|
ctx->ncothreads--;
|
||||||
|
@ -492,7 +444,7 @@ static void
|
||||||
cothread_stub (void)
|
cothread_stub (void)
|
||||||
{
|
{
|
||||||
cothread_context *ctx = cothread_get_current_context();
|
cothread_context *ctx = cothread_get_current_context();
|
||||||
register cothread_state *thread = ctx->cothreads[ctx->current];
|
cothread_state *thread = ctx->cothreads[ctx->current];
|
||||||
|
|
||||||
GST_DEBUG_ENTER ("");
|
GST_DEBUG_ENTER ("");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue