Fix an event leak
authorWim Taymans <wim.taymans@gmail.com>
Sun, 23 Dec 2001 14:50:44 +0000 (14:50 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Sun, 23 Dec 2001 14:50:44 +0000 (14:50 +0000)
Original commit message from CVS:
Fix an event leak
Ne need to save signals on longjmp

gst/cothreads.c
gst/cothreads.h
gst/gstevent.c
gst/gstpad.c

index ef5fdc6..2639a9c 100644 (file)
@@ -233,8 +233,10 @@ cothread_destroy (cothread_state *thread)
 
   GST_INFO (GST_CAT_COTHREADS, "destroy cothread %d %p %d", threadnum, thread, ctx->current);
 
+  /* we have to unlock here because we might be switched out with the lock held */
+  cothread_unlock (thread);
+
 #ifndef COTHREAD_ATOMIC
-  g_mutex_unlock (thread->lock);
   g_mutex_free (thread->lock);
 #endif
 
@@ -429,7 +431,7 @@ cothread_switch (cothread_state * thread)
 #ifdef GST_ARCH_PRESETJMP
   GST_ARCH_PRESETJMP ();
 #endif
-  enter = sigsetjmp (current->jmp, 1);
+  enter = setjmp (current->jmp);
   if (enter != 0) {
     GST_DEBUG (0, "enter thread #%d %d %p<->%p (%d)\n", current->threadnum, enter,
               current->sp, current->top_sp, (char*)current->top_sp - (char*)current->sp);
@@ -447,7 +449,7 @@ cothread_switch (cothread_state * thread)
   if (thread->flags & COTHREAD_STARTED) {
     GST_DEBUG (0, "in thread \n");
     /* switch to it */
-    siglongjmp (thread->jmp, 1);
+    longjmp (thread->jmp, 1);
   }
   else {
     GST_ARCH_SETUP_STACK ((char*)thread->sp);
index 1d45009..5c5fdde 100644 (file)
@@ -54,7 +54,7 @@ struct _cothread_state {
 
   int flags;
   void *sp;
-  sigjmp_buf jmp;
+  jmp_buf jmp;
   /* is this needed any more? */
   void *top_sp;
   void *pc;
index f7557eb..7a4284f 100644 (file)
@@ -92,6 +92,8 @@ gst_event_new (GstEventType type)
 void
 gst_event_free (GstEvent* event)
 {
+  GST_INFO (GST_CAT_EVENT, "freeing event %p", event);
+
   g_mutex_lock (_gst_event_chunk_lock);
   if (GST_EVENT_SRC (event)) {
     gst_object_unref (GST_EVENT_SRC (event));
index cf7e65c..e6fcc5a 100644 (file)
@@ -2017,14 +2017,15 @@ gst_pad_event_default (GstPad *pad, GstEvent *event)
           pads = g_list_next (pads);
        }
       }
+      gst_event_free (event);
       /* we have to try to schedule another element because this one is deisabled */
       gst_element_yield (element);
       break;
     default:
       g_warning ("no default handler for event\n");
+      gst_event_free (event);
       break;
   }
-  gst_event_free (event);
 }
 
 /**