Update of /cvsroot/agd/server/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519
Modified Files:
main.c
Log Message:
preloading objects; crash() doesn't take sig argument
Index: main.c
===================================================================
RCS file: /cvsroot/agd/server/src/main.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- main.c 23 Jul 2004 17:07:59 -0000 1.23
+++ main.c 24 Jul 2004 17:53:16 -0000 1.24
@@ -30,6 +30,9 @@
#include "list.h"
#include "lpc.h"
#include "object.h"
+#include "net.h"
+#include "interpret.h"
+#include "array.h"
extern object_t *master;
static char *conf_file;
@@ -39,13 +42,13 @@
{
switch(num) {
case SIGINT:
- crash(SIGINT, "Interrupted", 4);
+ crash("Interrupted", 4);
break;
case SIGSEGV:
- crash(SIGSEGV, "Segmentation fault", 4);
+ crash("Segmentation fault", 4);
break;
case SIGPIPE:
- crash(SIGPIPE, "Broken pipe", 4);
+ crash("Broken pipe", 4);
break;
}
}
@@ -64,7 +67,7 @@
signal(SIGPIPE, SIG_IGN);
}
-void crash(int sig, char *reason, int retval)
+void crash(char *reason, int retval)
{
extern variable_t *fp, *sp;
@@ -72,14 +75,15 @@
stop_signals();
if(master) {
- int ret;
+ variable_t *ret;
fp = sp;
- ret = apply(master, "crash", "is", sig, reason);
+ ret = apply(master, "crash", "s", reason);
if(!ret)
fprintf(stderr, "master::crash() failed.\n");
else
fprintf(stderr, "master::crash() called successfully.\n");
}
+
exit(retval);
}
@@ -88,7 +92,7 @@
printf("Usage: %s [options] <configuration file>\n", s);
printf("Options:\n"
"\t-d: Increase debug level\n"
- "\t-f<text>: pass flag to master object\n"
+ "\t-f<text>: pass flag to master object\n"
"\t-? or -h: Show this text\n"
"\t-v: Show version and quit\n");
exit(5);
@@ -123,6 +127,24 @@
}
}
+void do_preload(void)
+{
+ variable_t *tmpv;
+ array_t *arr;
+ int i;
+
+ tmpv = apply(master, "preload_list", "");
+ if(!tmpv || !tmpv->u.a || !tmpv->u.a->length)
+ return;
+
+ arr = tmpv->u.a;
+ for(i=0;i<arr->length;i++) {
+ tmpv = &arr->data[i];
+ if(tmpv->type == T_STRING && tmpv->u.s)
+ apply(master, "preload", "s", tmpv->u.s);
+ }
+}
+
#define NEXTARG() { i++; if(i<argc) goto next_i; else return; }
void parse_args(int argc, char **argv)
{
@@ -223,10 +245,11 @@
master = load_object(conf.master);
if(!master)
- crash(0, "Master object doesn't load", 3);
-/* master->numref++; Is this really necessary? */
+ crash("Master object doesn't load", 3);
+ master->numref++;
do_flag(NULL); /* Apply flags. */
+ do_preload();
net_listen(conf.port);
|