[ekg2-commit] ekg2: scripts.h (HEAD) scripts.c (HEAD) [darkjames]

CVS commit cvs w toxygen.net
Czw, 3 Maj 2007, 18:16:36 CEST


Module name:	ekg2
Changes by:	darkjames	2007-05-03 18:16:34

Modified files:
	scripts.h scripts.c

Log message:
don't allow scripts create handlers during deinit.

Index: scripts.h
===================================================================
RCS file: /home/cvs/ekg2/ekg/scripts.h,v
diff -d -u -r1.19 -r1.20
--- scripts.h	3 May 2007 14:41:29 -0000	1.19
+++ scripts.h	3 May 2007 16:16:33 -0000	1.20
@@ -27,6 +27,7 @@
 	char 		*name;
 	char 		*path;
 	void 		*private;
+	int		inited;
 } script_t;
 extern list_t 		scripts;
 
@@ -197,7 +198,12 @@
 /* BINDING && UNBINDING */
 
 #define SCRIPT_BIND_HEADER(x) \
-        x *temp = xmalloc(sizeof(x)); \
+        x *temp; \
+	if (scr && scr->inited != 1) {\
+		debug_error("[script_bind_error] script not inited!\n");	\
+		return NULL;	\
+	}	\
+	temp = xmalloc(sizeof(x)); \
         temp->scr  = scr;\
 	temp->private = handler;
 

Index: scripts.c
===================================================================
RCS file: /home/cvs/ekg2/ekg/scripts.c,v
diff -d -u -r1.43 -r1.44
--- scripts.c	3 May 2007 15:36:04 -0000	1.43
+++ scripts.c	3 May 2007 16:16:33 -0000	1.44
@@ -278,6 +278,8 @@
 	void 	     *t;    /* t comes from temporary !from timer ;> */
 	list_t 	      l;
 
+	scr->inited = 0;
+
 #define s(x) ((tmpstruct *) x)
 /* przeszukac liste timerow i komand, jak cos to je wywalic */
 	for (l = script_timers; l;)   { t = l->data; l = l->next; if (!t) continue;
@@ -405,6 +407,7 @@
 		scr->path = xstrdup(path);
 		scr->name = name2;
 		scr->lang = slang;
+		scr->inited = 1;
 		
 		list_add(&scripts, scr, 0); /* BUG: this should be before `script_loaded`...  */
 
@@ -421,7 +424,6 @@
 			xfree(name);
 			script_unload(scr);
 			return -1;
-		
 		}
 		print("script_loaded", scr->name, scr->path, slang->name);
 	}
@@ -744,11 +746,9 @@
 	return 0;
 }
 
-static TIMER(script_timer_handlers)
-{
+static TIMER(script_timer_handlers) {
 	script_timer_t *temp = data;
 	SCRIPT_HANDLER_HEADER(script_handler_timer_t);
-	debug("::: -> %s %d\n", temp->private, type);
 	SCRIPT_HANDLER_FOOTER(script_handler_timer, type) {
 		if (!type) {
 			return -1; /* timer_free(temp->self); */


Więcej informacji o liście dyskusyjnej ekg2-commit