From: Thomas V. S. <tho...@pr...> - 2002-11-18 22:45:00
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: thomasvs Date: Mon Nov 18 2002 14:44:59 PST Log message: a little cleanup also, clear the global we use here so we can reuse cothreads Modified files: gst : cothreads.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/cothreads.c.diff?r1=1.88&r2=1.89 ====Begin Diffs==== Index: cothreads.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/cothreads.c,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -r1.88 -r1.89 --- cothreads.c 15 Nov 2002 09:51:41 -0000 1.88 +++ cothreads.c 18 Nov 2002 22:44:47 -0000 1.89 @@ -88,8 +88,11 @@ /* if there already is a cotread context for this thread, * just return it */ ctx = g_private_get (_cothread_ctx_key); - if (ctx) + if (ctx) { + GST_INFO (GST_CAT_COTHREADS, + "returning private _cothread_ctx_key %p", ctx); return ctx; + } /* * initalize the whole of the cothreads context @@ -114,10 +117,11 @@ } /* set this thread's context pointer */ + GST_INFO (GST_CAT_COTHREADS, "setting private _cothread_ctx_key to %p", + ctx); g_private_set (_cothread_ctx_key, ctx); /* clear the cothread data */ - memset (ctx->cothreads, 0, sizeof (ctx->cothreads)); sp = CURRENT_STACK_FRAME; @@ -172,6 +176,8 @@ } } g_hash_table_destroy (ctx->data); + /* make sure we free the private key for cothread context */ + g_private_set (_cothread_ctx_key, NULL); g_free (ctx); } @@ -223,7 +229,7 @@ /* FIXME: an assumption is made that the stack segment is STACK_SIZE * aligned. */ stack_top = ((gulong) sp | (STACK_SIZE - 1)) + 1; - GST_DEBUG (GST_CAT_COTHREADS, "stack top is %lu", stack_top); + GST_DEBUG (GST_CAT_COTHREADS, "stack top is 0x%lx", stack_top); #endif /* cothread stack space of the thread is mapped in reverse, with cothread 0 @@ -240,7 +246,8 @@ * ie. we state explicitly that we are going to use it */ /* FIXME: maybe we should map slightly less than COTHREAD_STACKSIZE, * so that stack overruns possibly could segfault ? */ - mmaped = mmap ((void *) cothread, COTHREAD_STACKSIZE, + mmaped = mmap ((void *) (cothread), + COTHREAD_STACKSIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); GST_DEBUG (GST_CAT_COTHREADS, "coming out of mmap"); @@ -253,9 +260,9 @@ return NULL; } + cothread->magic_number = COTHREAD_MAGIC_NUMBER; GST_DEBUG (GST_CAT_COTHREADS, "create cothread %d with magic number 0x%x", slot, cothread->magic_number); - cothread->magic_number = COTHREAD_MAGIC_NUMBER; cothread->ctx = ctx; cothread->cothreadnum = slot; cothread->flags = 0; @@ -327,12 +334,13 @@ { cothread_destroy (ctx->cothreads[i]); GST_INFO (GST_CAT_COTHREADS, - "destroyed cothread %d, %d cothreads left\n", + "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 { @@ -368,7 +376,7 @@ } } } - GST_DEBUG (GST_CAT_COTHREADS, "munmap done\n"); + GST_DEBUG (GST_CAT_COTHREADS, "munmap done"); ctx->cothreads[cothreadnum] = NULL; ctx->ncothreads--; |