cvsuser 04/01/16 01:08:05
Modified: include/parrot events.h
src events.c interpreter.c
Log:
parrot-threads-23
* terminate the even loop thread on destroying of the last interp
* this could help against the spurious hangs reported on p6i
Revision Changes Path
1.9 +4 -1 parrot/include/parrot/events.h
Index: events.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/events.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- events.h 9 Jan 2004 10:28:15 -0000 1.8
+++ events.h 16 Jan 2004 09:08:03 -0000 1.9
@@ -1,7 +1,7 @@
/* events.h
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: events.h,v 1.8 2004/01/09 10:28:15 leo Exp $
+ * $Id: events.h,v 1.9 2004/01/16 09:08:03 leo Exp $
* Overview:
* This api will handle parrot events
* Data Structure and Algorithms:
@@ -23,6 +23,7 @@
EVENT_TYPE_ASYNC_IO,
EVENT_TYPE_TIMER,
EVENT_TYPE_TERMINATE,
+ EVENT_TYPE_EVENT_TERMINATE,
EVENT_TYPE_CLASS_CHANGED,
EVENT_TYPE_SIGNAL
} parrot_event_type_enum;
@@ -67,6 +68,8 @@
void Parrot_new_terminate_event(Parrot_Interp);
void disable_event_checking(Parrot_Interp);
void enable_event_checking(Parrot_Interp);
+
+void Parrot_kill_event_loop(void);
#endif
1.18 +28 -5 parrot/src/events.c
Index: events.c
===================================================================
RCS file: /cvs/public/parrot/src/events.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -w -r1.17 -r1.18
--- events.c 9 Jan 2004 10:28:17 -0000 1.17
+++ events.c 16 Jan 2004 09:08:05 -0000 1.18
@@ -1,7 +1,7 @@
/* events.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: events.c,v 1.17 2004/01/09 10:28:17 leo Exp $
+ * $Id: events.c,v 1.18 2004/01/16 09:08:05 leo Exp $
* Overview:
* Event handling stuff
* Data Structure and Algorithms:
@@ -199,6 +199,18 @@
Parrot_schedule_event(interpreter, ev);
}
+/*
+ * schedule event-loop terminate event
+ */
+void
+Parrot_kill_event_loop(void)
+{
+ parrot_event* ev = mem_sys_allocate(sizeof(parrot_event));
+ ev->type = EVENT_TYPE_EVENT_TERMINATE;
+ ev->data = NULL;
+ Parrot_schedule_event(NULL, ev);
+}
+
void
Parrot_schedule_interp_qentry(Parrot_Interp interpreter, QUEUE_ENTRY* entry)
{
@@ -253,8 +265,10 @@
queue_timedwait(event_q, &abs_time);
}
else {
- /* we shouldn't get here probably */
- internal_exception(1, "Spurious event in event queue");
+ /* we shouldn't get here probably
+ * - the event queue terminating event is seen here
+ */
+
}
/*
* one or more entries arrived - we hold the mutex again
@@ -303,6 +317,10 @@
mem_sys_free(entry);
continue;
}
+ else if (event->type == EVENT_TYPE_EVENT_TERMINATE) {
+ mem_sys_free(entry);
+ goto out;
+ }
/*
* now insert entry in interpreter task queue
*/
@@ -313,15 +331,20 @@
/*
* TODO broadcast or deliver to first interp
*/
+ mem_sys_free(entry);
}
} /* while events */
again:
;
- } /* forever */
+ } /* event loop */
+out:
/*
- * not reached yet
+ * the main interpreter is dying
*/
+ mem_sys_free(event);
UNLOCK(event_q->queue_mutex);
+ queue_destroy(event_q);
+ return NULL;
}
/*
1.257 +7 -2 parrot/src/interpreter.c
Index: interpreter.c
===================================================================
RCS file: /cvs/public/parrot/src/interpreter.c,v
retrieving revision 1.256
retrieving revision 1.257
diff -u -w -r1.256 -r1.257
--- interpreter.c 14 Jan 2004 10:21:06 -0000 1.256
+++ interpreter.c 16 Jan 2004 09:08:05 -0000 1.257
@@ -1,7 +1,7 @@
/* interpreter.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: interpreter.c,v 1.256 2004/01/14 10:21:06 leo Exp $
+ * $Id: interpreter.c,v 1.257 2004/01/16 09:08:05 leo Exp $
* Overview:
* The interpreter api handles running the operations
* Data Structure and Algorithms:
@@ -1122,8 +1122,13 @@
/*
* wait for threads to complete if needed
*/
- if (!interpreter->parent_interpreter)
+ if (!interpreter->parent_interpreter) {
pt_join_threads(interpreter);
+ /*
+ * and terminate the event loop
+ */
+ Parrot_kill_event_loop();
+ }
/* if something needs destruction (e.g. closing PIOs)
* we must destroy it now:
* no DOD run, so everything is considered dead