extern int errno;
extern FILE *journal;
-extern char *malloc();
-extern int free();
extern char *inet_ntoa();
extern void mr_com_err();
extern void do_client();
extern time_t now;
+#ifdef _DEBUG_MALLOC_INC
+static char *dbg_malloc();
+static int dbg_free();
+#endif
+
/*
* Main MOIRA server loop.
*
int argc;
char **argv;
{
- int status;
+ int status, i;
time_t tardy;
+ char *port;
+ extern char *database;
struct stat stbuf;
whoami = argv[0];
*/
initialize_sms_error_table();
initialize_krb_error_table();
+ initialize_gdss_error_table();
set_com_err_hook(mr_com_err);
setlinebuf(stderr);
- if (argc != 1) {
- com_err(whoami, 0, "Usage: moirad");
+ database = "moira";
+ port = index(MOIRA_SERVER, ':') + 1;
+
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "-db") && i+1 < argc) {
+ database = argv[i+1];
+ i++;
+ } else if (!strcmp(argv[i], "-p") && i+1 < argc) {
+ port = argv[i+1];
+ i++;
+ } else {
+ com_err(whoami, 0, "Usage: moirad [-db database][-p port]");
exit(1);
- }
+ }
+ }
/* Profiling implies that getting rid of one level of call
* indirection here wins us maybe 1% on the VAX.
*/
+#ifdef _DEBUG_MALLOC_INC
+ gdb_amv = dbg_malloc;
+ gdb_fmv = dbg_free;
+#else
gdb_amv = malloc;
- gdb_fmv = free;
+ gdb_fmv = (int (*)()) free;
+#endif
/*
* GDB initialization.
/*
* Establish template connection.
*/
- if ((status = do_listen()) != 0) {
+ if ((status = do_listen(port)) != 0) {
com_err(whoami, status,
" while trying to create listening connection");
exit(1);
if (errno == EWOULDBLOCK) {
do_reset_listen();
} else {
+ static int count = 0;
com_err(whoami, errno,
- " error on listen");
- exit(1);
+ " error (%d) on listen", count);
+ if (count++ > 10)
+ exit(1);
}
} else if ((status = new_connection()) != 0) {
com_err(whoami, errno,
*/
int
-do_listen()
+do_listen(port)
+char *port;
{
- char *service = index(MOIRA_SERVER, ':') + 1;
-
- listencon = create_listening_connection(service);
+ listencon = create_listening_connection(port);
if (listencon == NULL)
return errno;
exit(1);
}
}
+
+#ifdef _DEBUG_MALLOC_INC
+static char *dbg_malloc(size)
+ SIZETYPE size;
+{
+ return( debug_malloc("somewhere in the gdb code",1,size) );
+}
+
+static int dbg_free(cptr)
+ DATATYPE *cptr;
+{
+ debug_free((char *)NULL, 0, cptr);
+ return 0; /* GDB is being stupid */
+}
+#endif
+