Commit 2eb7f042 authored by Andy Wingo Wingo's avatar Andy Wingo Wingo
Browse files

free stack properly s/prefered/preferred/

Original commit message from CVS:
* free stack properly
* s/prefered/preferred/
parent 781f489e
......@@ -94,22 +94,22 @@ gst_scheduler_setup (GstScheduler *sched)
}
/**
* gst_scheduler_get_prefered_stack:
* gst_scheduler_get_preferred_stack:
* @sched: the scheduler
* @stack: a pointer to the location of the prefered stack
* @size: a pointer to the size of the prefered stack
* @stack: a pointer to the location of the preferred stack
* @size: a pointer to the size of the preferred stack
*
* Get the prefered stack location and size of this scheduler.
* Get the preferred stack location and size of this scheduler.
*
* Returns: TRUE if the scheduler suggested a prefered stacksize and location.
* Returns: TRUE if the scheduler suggested a preferred stacksize and location.
*/
gboolean
gst_scheduler_get_prefered_stack (GstScheduler *sched, gpointer *stack, gulong *size)
gst_scheduler_get_preferred_stack (GstScheduler *sched, gpointer *stack, gulong *size)
{
g_return_val_if_fail (GST_IS_SCHEDULER (sched), FALSE);
if (CLASS (sched)->get_prefered_stack)
return CLASS (sched)->get_prefered_stack (sched, stack, size);
if (CLASS (sched)->get_preferred_stack)
return CLASS (sched)->get_preferred_stack (sched, stack, size);
return FALSE;
}
......
......@@ -85,7 +85,7 @@ struct _GstSchedulerClass {
/* virtual methods */
void (*setup) (GstScheduler *sched);
gboolean (*get_prefered_stack) (GstScheduler *sched, gpointer *stack, gulong *size);
gboolean (*get_preferred_stack) (GstScheduler *sched, gpointer *stack, gulong *size);
void (*reset) (GstScheduler *sched);
void (*add_element) (GstScheduler *sched, GstElement *element);
void (*remove_element) (GstScheduler *sched, GstElement *element);
......@@ -115,7 +115,7 @@ GType gst_scheduler_get_type (void);
void gst_scheduler_setup (GstScheduler *sched);
gboolean gst_scheduler_get_prefered_stack(GstScheduler *sched, gpointer *stack, gulong *size);
gboolean gst_scheduler_get_preferred_stack(GstScheduler *sched, gpointer *stack, gulong *size);
void gst_scheduler_reset (GstScheduler *sched);
void gst_scheduler_add_element (GstScheduler *sched, GstElement *element);
void gst_scheduler_remove_element (GstScheduler *sched, GstElement *element);
......
......@@ -154,8 +154,6 @@ static void
gst_thread_dispose (GObject *object)
{
GstThread *thread = GST_THREAD (object);
void *stack;
long stacksize;
GST_DEBUG (GST_CAT_REFCOUNTING, "dispose");
......@@ -164,12 +162,6 @@ gst_thread_dispose (GObject *object)
G_OBJECT_CLASS (parent_class)->dispose (object);
GST_DEBUG (GST_CAT_THREAD, "Disposing of thread");
pthread_attr_getstack (&thread->attr, &stack, (size_t *) &stacksize);
GST_DEBUG (GST_CAT_THREAD, "undoing posix_memalign at %p of size %ld",
stack, stacksize);
free (stack);
if (GST_ELEMENT_SCHED (thread)) {
gst_object_unref (GST_OBJECT (GST_ELEMENT_SCHED (thread)));
}
......@@ -252,7 +244,6 @@ gst_thread_change_state (GstElement * element)
gboolean stateset = GST_STATE_SUCCESS;
gint transition;
pthread_t self = pthread_self ();
void *stack;
glong stacksize;
g_return_val_if_fail (GST_IS_THREAD (element), GST_STATE_FAILURE);
......@@ -284,15 +275,14 @@ gst_thread_change_state (GstElement * element)
if (pthread_attr_init (&thread->attr) != 0)
g_warning ("pthread_attr_init returned an error !");
if (gst_scheduler_get_prefered_stack (GST_ELEMENT_SCHED (element), &stack, &stacksize)) {
if (pthread_attr_setstack (&thread->attr, stack, stacksize) != 0)
g_warning ("pthread_attr_setstack failed !\n");
GST_DEBUG (GST_CAT_THREAD,
"pthread attr set stack at %p of size %ld",
stack, stacksize);
if (gst_scheduler_get_preferred_stack (GST_ELEMENT_SCHED (element), &thread->stack, &stacksize)) {
if (pthread_attr_setstack (&thread->attr, thread->stack, stacksize) != 0) {
g_warning ("pthread_attr_setstack failed");
return GST_STATE_FAILURE;
}
GST_DEBUG (GST_CAT_THREAD, "pthread attr set stack at %p of size %ld",
thread->stack, stacksize);
}
else
g_warning ("_get_prefered_stack failed !\n");
/* create the thread */
THR_DEBUG ("going to pthread_create...");
......@@ -428,15 +418,12 @@ gst_thread_change_state (GstElement * element)
thread->thread_id = -1;
g_mutex_unlock (thread->lock);
/*
* FIXME: we moved this code to the scheduler dispose function
pthread_attr_getstack (&thread->attr, &stack, (size_t *) &stacksize);
GST_DEBUG (GST_CAT_THREAD, "undng posix_memalign at %p of size %ld\n",
stack, stacksize);
stack, stacksize);
free (thread->stack);
thread->stack = 0;
*/
if (thread->stack) {
GST_DEBUG (GST_CAT_THREAD, "freeing allocated stack (%p)", thread->stack);
free (thread->stack);
thread->stack = NULL;
}
GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING);
GST_FLAG_UNSET (thread, GST_THREAD_STATE_STARTED);
GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
......
......@@ -66,6 +66,7 @@ struct _GstThread {
pthread_t thread_id; /* id of the thread, if any */
pthread_attr_t attr; /* attributes for the stack space */
void *stack; /* set with gst_scheduler_get_preferred_stack */
gint pid; /* the pid of the thread */
gint ppid; /* the pid of the thread's parent process */
GMutex *lock; /* thread lock/condititon pair ... */
......
......@@ -109,7 +109,7 @@ static void gst_basic_scheduler_init (GstBasicScheduler * scheduler);
static void gst_basic_scheduler_dispose (GObject *object);
static void gst_basic_scheduler_setup (GstScheduler *sched);
static gboolean gst_basic_scheduler_get_prefered_stack (GstScheduler *sched, gpointer *stack, gulong *size);
static gboolean gst_basic_scheduler_get_preferred_stack (GstScheduler *sched, gpointer *stack, gulong *size);
static void gst_basic_scheduler_reset (GstScheduler *sched);
static void gst_basic_scheduler_add_element (GstScheduler *sched, GstElement *element);
static void gst_basic_scheduler_remove_element (GstScheduler *sched, GstElement *element);
......@@ -201,7 +201,7 @@ gst_basic_scheduler_class_init (GstBasicSchedulerClass * klass)
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_basic_scheduler_dispose);
gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_basic_scheduler_setup);
gstscheduler_class->get_prefered_stack= GST_DEBUG_FUNCPTR (gst_basic_scheduler_get_prefered_stack);
gstscheduler_class->get_preferred_stack= GST_DEBUG_FUNCPTR (gst_basic_scheduler_get_preferred_stack);
gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_basic_scheduler_reset);
gstscheduler_class->add_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_add_element);
gstscheduler_class->remove_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_remove_element);
......@@ -952,10 +952,10 @@ gst_basic_scheduler_setup (GstScheduler *sched)
}
static gboolean
gst_basic_scheduler_get_prefered_stack (GstScheduler *sched, gpointer *stack, gulong *size)
gst_basic_scheduler_get_preferred_stack (GstScheduler *sched, gpointer *stack, gulong *size)
{
if (do_cothreads_stackquery (stack, size)) {
GST_DEBUG (GST_CAT_SCHEDULING, "getting prefered stack size as %p and %lu", *stack, *size);
GST_DEBUG (GST_CAT_SCHEDULING, "getting preferred stack size as %p and %lu", *stack, *size);
return TRUE;
}
return FALSE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment