Commit fc2a9dcc authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Cosmetics.

Added support for memuse_file.
Fixed erronous definition of the sighandlers.
All clients are now logged out when the server shuts down.
parent cdfa1181
......@@ -11,6 +11,7 @@
#include <getopt.h>
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <ctype.h>
#include <netdb.h>
#include <string.h>
......@@ -31,6 +32,8 @@
#include "com.h"
#include "connections.h"
#include "config.h"
#include "exp.h"
#include "memory.h"
Kom_err kom_errno;
u_long err_stat;
......@@ -43,14 +46,13 @@ Bool never_save = FALSE;
#endif
extern int chdir (char * path);
char datafilename[1024]; /* Full pathname to the database file */
char backupfilename[1024]; /* Full pathname to the backup file */
char textfilename[1024]; /* Full pathname to the text file. */
char statisticfile[1024]; /* Dito to statistics file. */
char pidfile[1024]; /* Dito pid-file. */
EXPORT char datafilename[1024]; /* Full pathname to the database file */
EXPORT char backupfilename[1024]; /* Full pathname to the backup file */
EXPORT char textfilename[1024]; /* Full pathname to the text file. */
EXPORT char statisticfile[1024]; /* Dito to statistics file. */
EXPORT char pidfile[1024]; /* Dito pid-file. */
INTERNAL char memusefile[1024]; /* Memory useage file. */
char ip_client_port[80]; /* Port to listen to for clients */
char ip_mux_port[80]; /* Port to listen to for mux:es */
......@@ -105,6 +107,7 @@ init_data_base(const char *dbase_dir)
sprintf(textfilename, "%s/%s", dbase_dir, TEXTFILE_NAME);
sprintf(statisticfile, "%s/%s", dbase_dir, STATISTIC_NAME);
sprintf(pidfile, "%s/%s", dbase_dir, PID_NAME);
sprintf(memusefile, "%s/%s", dbase_dir, MEMUSE_NAME);
log("Database = %s\n", datafilename);
log("Backup = %s\n", backupfilename);
......@@ -132,14 +135,14 @@ init_data_base(const char *dbase_dir)
}
void
sighandler_hup (void)
sighandler_hup (int sig)
{
log ("Signal HUP received. Shutting down server.\n");
go_and_die = TRUE;
}
void
sighandler_quit (void)
sighandler_quit (int sig)
{
log ("Signal QUIT received - syncing...\n");
cache_sync_all();
......@@ -149,13 +152,13 @@ sighandler_quit (void)
}
void
sighandler_usr1 (void)
sighandler_usr1 (int sig)
{
do_sync_db = TRUE;
}
void
sighandler_usr2 (void)
sighandler_usr2 (int sig)
{
int child;
extern int fork(void);
......@@ -196,7 +199,9 @@ main (int argc,
char **argv)
{
int i;
FILE *stat_file;
s_set_storage_management(smalloc, srealloc, sfree);
strcpy(ip_client_port, DEFAULT_CLIENT_SERVICE);
strcpy(ip_mux_port, DEFAULT_MUX_SERVICE);
......@@ -237,8 +242,6 @@ main (int argc,
restart_kom("usage: ramkomd\n");
}
s_set_storage_management(smalloc, srealloc, sfree);
signal(SIGHUP, sighandler_hup);
signal(SIGQUIT, sighandler_quit);
signal(SIGUSR1, sighandler_usr1);
......@@ -247,11 +250,26 @@ main (int argc,
server_init(ip_client_port, ip_mux_port);
init_data_base(dbase_dir);
save_pid();
toploop();
logout_all_clients();
cache_sync_all();
free_all_tmp();
free_all_cache();
stat_file = fopen(memusefile, "w");
if ( stat_file == NULL )
restart_kom("Can't open file to save memory usage to.\n");
dump_smalloc_counts(stat_file);
dump_alloc_counts(stat_file);
fclose (stat_file);
log("ramkomd terminated normally.\n");
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment