diff --git a/src/include/ChangeLog b/src/include/ChangeLog index 6d2f4016d24f08f759eb756d8a9265673775f4f1..774d56e65247f5529a6589a4cb9b2339e2a25bcb 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,3 +1,7 @@ +Sun Nov 22 16:04:11 1992 Per Cederqvist (ceder@mauritz) + + * config.h (LOGACCESSES): New symbol. + Sat Apr 4 19:08:51 1992 Per Cederqvist (ceder@lysator) * kom-types.h (Who_info_ident, Who_info_ident_list, diff --git a/src/include/config.h b/src/include/config.h index d7761a85102a1d063eaee71102c2e5ed3dbdecb3..b8a0be5909174448546d86963651aa09d200cbd0 100644 --- a/src/include/config.h +++ b/src/include/config.h @@ -1,5 +1,5 @@ /* - * $Id: config.h,v 0.5 1992/03/31 20:52:09 ceder Exp $ + * $Id: config.h,v 0.6 1992/11/22 15:14:15 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -34,7 +34,7 @@ #include <m-config.h> #define DEBUG /* We're still debugging and want traces. */ - +#define LOGACCESSES /* Log all accesses to the data base. */ /* * Add some checks that really shouldn't be necessary. */ diff --git a/src/server/ChangeLog b/src/server/ChangeLog index 542751120aeefa9f08f72d8068d47d3d74cdca57..320cddbf7ae18cb61ca23ed5cde694af2310d1ab 100644 --- a/src/server/ChangeLog +++ b/src/server/ChangeLog @@ -1,3 +1,22 @@ +Sun Nov 22 16:06:36 1992 Per Cederqvist (ceder@mauritz) + + * version.incl: Version 1.2.7. + + * Support for logging of all db accesses: + * ramkomd.c (main): Added -L option. + * cache.h (tell_cache_garb_text): New function. + * simple-cache.c: Do the logging. + * text-garb.c (garb_text): Inhibit the logging while garbing. + + * cache.h: Removed unused stuff. + +Mon Nov 2 19:18:08 1992 Per Cederqvist (ceder@mauritz) + + * simple-cache.c (LOGFILE): Deleted the changes from Tue Oct 27. + + * cache.h (MAX_CACHED_PERSONS, MAX_CACHED_WHATEVER, + cached_load_names, cached_add_name): was unused, is deleted. + Tue Oct 27 05:27:55 1992 Per Cederqvist (ceder@ruben) * version.incl: Version 1.2.6. diff --git a/src/server/cache.h b/src/server/cache.h index 24391e24324a1dd2111b8e91b5c3cf29cf95968d..624025315fc876ca70138447dbfcd63ffedd97a1 100644 --- a/src/server/cache.h +++ b/src/server/cache.h @@ -1,5 +1,5 @@ /* - * $Id: cache.h,v 0.8 1991/11/10 19:02:48 linus Exp $ + * $Id: cache.h,v 0.9 1992/11/22 15:14:37 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -23,7 +23,7 @@ * Please mail bug reports to bug-lyskom@lysator.liu.se. */ /* - * $Id: cache.h,v 0.8 1991/11/10 19:02:48 linus Exp $ + * $Id: cache.h,v 0.9 1992/11/22 15:14:37 ceder Exp $ * * This file contains the cached data that the server stores. * .h file created by ceder 1990-04-18 @@ -67,10 +67,6 @@ cache_sync(void); /* S}d{r ja. Tack f|r mig. /ceder */ -#define MAX_CACHED_PERSONS 5 /* To be increased after debugging */ -#define MAX_CACHED_WHATEVER /* To be added */ - - /* * Name caching routines */ @@ -87,24 +83,6 @@ cached_change_name(Conf_no name_num, String new_name ); -/* add_name adds a name to the list of cached conference names. It is only - * used when a new conference is created. - */ -extern void -cached_add_name( char * new_name ); - -/* load all the conference names from disk and store them in memory */ -extern void -cached_load_names( void ); - -#if 0 -/* get one name (I want this call! /ceder) */ -/* I no longer want it. */ -extern String -cached_get_name( Conf_no conf_no ); /* Returns NULL if the conference */ - /* doesn't exist. */ -#endif - extern Bool cached_conf_exists( Conf_no conf_no ); @@ -132,13 +110,6 @@ cached_get_highest_local_no (Conf_no conf_no); -/* - * Person caching routines - */ -#if 0 -extern Person * -cached_read_person( Pers_no pers_no ); -#endif /* * Various function calls to tell the cache that something is changed. */ @@ -258,3 +229,10 @@ dump_cache_mem_usage(FILE *stat_file); */ int query_next_text_num(void); + +/* + * Tell the cache that a text garbage collection operation is in progress + * or is finished. + */ +void +tell_cache_garb_text(int running); diff --git a/src/server/ramkomd.c b/src/server/ramkomd.c index f3a0c40d008824134e60f03c581e2f03569dc3f1..8272e30d3b1d15907204080e4a464948300e025b 100644 --- a/src/server/ramkomd.c +++ b/src/server/ramkomd.c @@ -1,5 +1,5 @@ /* - * $Id: ramkomd.c,v 0.30 1992/06/10 01:37:39 ceder Exp $ + * $Id: ramkomd.c,v 0.31 1992/11/22 15:14:41 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -31,7 +31,7 @@ * It has grown! /ceder */ -static char *rcsid = "$Id: ramkomd.c,v 0.30 1992/06/10 01:37:39 ceder Exp $"; +static char *rcsid = "$Id: ramkomd.c,v 0.31 1992/11/22 15:14:41 ceder Exp $"; #include <m-config.h> @@ -83,7 +83,9 @@ int buglevel = 0; Bool never_save = FALSE; #endif - +#ifdef LOGACCESSES +char *logaccess_file = NULL; +#endif EXPORT char datafilename[BUFSIZ]; /* Full pathname to the database file */ EXPORT char backupfilename[BUFSIZ]; /* Full pathname to the backup file */ @@ -333,9 +335,19 @@ main (int argc, send_async_messages = FALSE; break; +#ifdef LOGACCESSES + case 'L': + logaccess_file = argv[i] + 2; + break; +#endif + default: restart_kom("usage: %s [-d] [-q] [-Ddir] [-pport] [-Pmuxport]" - " [-a]\n", argv[0]); + " [-a]" +#ifdef LOGACCESSES + " [-Ldb_trace_file]" +#endif + "\n", argv[0]); } if (i < argc) diff --git a/src/server/simple-cache.c b/src/server/simple-cache.c index 1cdb1144cb7034b485b6dc9e380b61f865befe76..8b957f709be050cd533d5e83ca2fe6d2c3916d35 100644 --- a/src/server/simple-cache.c +++ b/src/server/simple-cache.c @@ -1,5 +1,5 @@ /* - * $Id: simple-cache.c,v 0.27 1992/11/02 18:46:31 ceder Exp $ + * $Id: simple-cache.c,v 0.28 1992/11/22 15:14:47 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -33,8 +33,7 @@ * New save algorithm by ceder. */ -static char *rcsid = "$Id: simple-cache.c,v 0.27 1992/11/02 18:46:31 ceder Exp $"; - +static char *rcsid = "$Id: simple-cache.c,v 0.28 1992/11/22 15:14:47 ceder Exp $"; /* @@ -124,6 +123,59 @@ static Text_no highest_text_no; BUGDECL; +/* Define LOGACCESSES if you want to be able to log all accesses to + the data base. */ + +#ifdef LOGACCESSES +extern char *logaccess_file; /* From ramkomd.c */ + +typedef enum { + lt_restart, + lt_text_stat, + lt_text_mass, + lt_conf_stat, + lt_pers_stat, + + lt_text_def, + lt_conf_def, + lt_pers_def, + + lt_create_text, + lt_garb_text, + lt_delete_text, + lt_create_conf, + lt_delete_conf, + lt_create_pers, + lt_delete_pers, + + lt_lock_conf, + lt_unlock_conf, + lt_lock_pers, + lt_unlock_pers, + + lt_get_highest, /* Get highest Local_text_no for a conf. */ + lt_get_conf_type + /* Note: mark_*_as_changed is not logged. */ +} Log_type; + +static FILE *logfile = NULL; +static int syncing_or_saving = 0; +static int garb_running = 0; + +static void log_access(Log_type t, + int id) +{ + if (garb_running + syncing_or_saving == 0) + { + putc(t, logfile); + putw(id, logfile); + } +} +#define LOGACC(a,b) {if (logfile) log_access(a, b);} +#else +#define LOGACC(a,b) +#endif + /* Macros */ @@ -286,6 +338,8 @@ cached_get_conf_type (Conf_no conf_no) restart_kom("cached_get_conf_type(%d): conference does not exist.\n", conf_no); + LOGACC(lt_get_conf_type, conf_no); + return small_conf_arr [ conf_no ]->type; } @@ -395,11 +449,14 @@ cached_create_person( Pers_no person ) if ( node == NULL ) restart_kom("cached_create_person(): couldn't get cache_node.\n"); - + node->ptr = alloc_person(); node->s.dirty = 1; node->s.exists = 1; pers_set_mru( person ); + + LOGACC(lt_create_pers, person); + return OK; } @@ -431,6 +488,8 @@ cached_get_person_stat( Pers_no person ) return NULL; } + LOGACC(lt_pers_stat, person); + if ( node->ptr != NULL ) { pers_set_mru( person ); @@ -528,7 +587,9 @@ cached_create_conf (String name) cached_change_name( conf_no, name); TRACE2("Created conference number %d\n", conf_no); - + + LOGACC(lt_create_conf, conf_no); + return conf_no; } @@ -566,6 +627,8 @@ cached_delete_conf( Conf_no conf ) node->ptr = NULL; node->s.exists = 0; + LOGACC(lt_delete_conf, conf); + return OK; } @@ -602,6 +665,8 @@ cached_delete_person(Pers_no pers) log("cached_delete_pers(%lu): lock_cnt === %lu\n", (u_long)pers, (u_long)node->lock_cnt); + LOGACC(lt_delete_pers, pers); + free_person (node->ptr); node->ptr = NULL; node->s.exists = 0; @@ -639,6 +704,15 @@ cached_delete_text(Text_no text) node->ptr = NULL; node->s.exists = 0; +#ifdef LOGACCESSES + if (garb_running) + { + putc(t, lt_garb_text); + putw(id, text); + } + else + log_access(lt_delete_text, text); +#endif return OK; } @@ -664,6 +738,8 @@ cached_get_conf_stat (Conf_no conf_no) return NULL; } + LOGACC(lt_conf_stat, conf_no); + if ( node->ptr != NULL ) { conf_set_mru (conf_no); @@ -722,6 +798,7 @@ cached_get_text( Text_no text ) return EMPTY_STRING; else { + LOGACC(lt_text_mass, text); the_string.string = tmp_alloc( t_stat->no_of_chars ); the_string.len = t_stat->no_of_chars; fseek(text_file, t_stat->file_pos, SEEK_SET); @@ -763,6 +840,8 @@ cached_get_text_stat( Text_no text ) return NULL; } + LOGACC(lt_text_stat, text); + if ( node->ptr != NULL ) { TRACE1("Found in ptr.\n"); @@ -840,6 +919,7 @@ cached_create_text( String message) fflush(text_file); + LOGACC(lt_create_text, tno); TRACE2("cached_create_text -> %d\n", tno); return tno; @@ -913,6 +993,8 @@ cached_get_garb_nice (Conf_no conf_no) extern Local_text_no cached_get_highest_local_no (Conf_no conf_no) { + LOGACC(lt_get_highest, conf_no); + return small_conf_arr[ conf_no ]->highest_local_no; } @@ -922,6 +1004,8 @@ cached_lock_person(Pers_no pers_no) { Cache_node *node; + LOGACC(lt_lock_pers, pers_no); + node = get_pers_node(pers_no); if ( node == NULL || node->s.exists == 0 ) @@ -952,6 +1036,8 @@ cached_unlock_person(Pers_no pers_no) { Cache_node *node; + LOGACC(lt_unlock_pers, pers_no); + node = get_pers_node (pers_no); if ( node == NULL ) @@ -983,6 +1069,8 @@ cached_lock_conf(Conf_no conf_no) if ( node->s.exists == 0 ) restart_kom("cached_lock_conf(%d): nonexistent.\n", conf_no); + LOGACC(lt_lock_conf, conf_no); + if ( node->ptr == NULL ) { Conference *conference_ptr; @@ -1008,6 +1096,8 @@ cached_unlock_conf(Conf_no conf_no) { Cache_node *node; + LOGACC(lt_unlock_conf, conf_no); + node = get_conf_node(conf_no); if ( node == NULL ) restart_kom("cached_unlock_conf(): can't get node.\n"); @@ -1668,6 +1758,10 @@ sync_part(void) sync_state = sync_ready; } +#ifdef LOGACCESSES + syncing_or_saving = 1; +#endif + switch(sync_state) { case sync_save_conf: @@ -1684,7 +1778,12 @@ sync_part(void) case sync_ready: if ( difftime(time(NULL), last_sync_start) < 60 * SYNC_INTERVAL ) + { +#ifdef LOGACCESSES + syncing_or_saving = 0; +#endif return TRUE; + } last_sync_start = time(NULL); @@ -1693,7 +1792,12 @@ sync_part(void) case sync_wait: if ( difftime(time(NULL), last_sync_start) < 60 * SYNC_RETRY_INTERVAL ) + { +#ifdef LOGACCESSES + syncing_or_saving = 0; +#endif return TRUE; + } last_sync_start = time(NULL); @@ -1716,6 +1820,10 @@ sync_part(void) if ( file_b != NULL && ferror(file_b) != 0) sync_state = sync_error; +#ifdef LOGACCESSES + syncing_or_saving = 0; +#endif + return FALSE; } @@ -1748,7 +1856,16 @@ init_cache(void) conf_mcb = create_cache_node_mcb(100, MAX_CONF); text_mcb = create_cache_node_mcb(100, MAX_TEXT); - +#ifdef LOGACCESSES + if (logaccess_file) + logfile = fopen(logaccess_file, "a"); + if (logfile) + log("Logging db accesses to %s.\n", logaccess_file); + else + log("Failed to open db log file %s. Ignoring -L option.\n", + logaccess_file); +#endif + LOGACC(lt_restart, time(NULL)); if ( (text_file = fopen(textfilename, "a+b")) == NULL ) { @@ -1795,6 +1912,7 @@ init_cache(void) break; case '+': + LOGACC(lt_conf_def, i); create_cache_node(conf_mcb, i); node = get_conf_node(i); node->s.exists = 1; @@ -1825,6 +1943,7 @@ init_cache(void) break; case '+': + LOGACC(lt_pers_def, i); create_cache_node(pers_mcb, i); node = get_pers_node(i); node->s.exists = 1; @@ -1851,6 +1970,7 @@ init_cache(void) break; case '+': + LOGACC(lt_text_def, i); create_cache_node(text_mcb, i); node = get_text_node(i); node->s.exists = 1; @@ -1894,6 +2014,11 @@ free_all_cache (void) int i; Cache_node *node; +#ifdef LOGACCESSES + if (logfile) + fclose(logfile); +#endif + for ( i = 0; i < next_free_num; i++ ) { node = get_conf_node(i); @@ -2137,3 +2262,12 @@ query_next_text_num(void) { return next_text_num; } + +EXPORT void +tell_cache_garb_text(int running) +{ +#ifdef LOGACCESSES + garb_running = running; +#endif +} + diff --git a/src/server/text-garb.c b/src/server/text-garb.c index 51a7472b6e3cb65ebfdeb13c58693b959dc425df..4b3d86c3c1c053d07a9396a340b6b6552fbb3b62 100644 --- a/src/server/text-garb.c +++ b/src/server/text-garb.c @@ -1,5 +1,5 @@ /* - * $Id: text-garb.c,v 0.7 1992/10/06 23:45:00 ceder Exp $ + * $Id: text-garb.c,v 0.8 1992/11/22 15:14:52 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -28,7 +28,7 @@ * Author: Per Cederqvist. */ -static char *rcsid = "$Id: text-garb.c,v 0.7 1992/10/06 23:45:00 ceder Exp $"; +static char *rcsid = "$Id: text-garb.c,v 0.8 1992/11/22 15:14:52 ceder Exp $"; #include <time.h> @@ -43,7 +43,7 @@ static char *rcsid = "$Id: text-garb.c,v 0.7 1992/10/06 23:45:00 ceder Exp $"; /* * This comment is a description of how this _could_ be done in a more * efficient way. It is not yet implemented. Design by Inge Wallin - * and Per Cederqvist 1992-10-07. + * and Per Cederqvist 1992-10-07. +++FIXME. * * Today, all text statuses are read into the core during the garbage * collection phase. Due to step 3 below we think that we can reduce @@ -106,19 +106,22 @@ garb_text(void) log("MSG: garb started.\n"); time( &last_start ); } - + + tell_cache_garb_text(1); last_checked = traverse_text( last_checked ); if ( last_checked == 0 ) { log("MSG: garb ready. %lu texts deleted.\n", (u_long)deleted_texts); deleted_texts = 0; + tell_cache_garb_text(0); return FALSE; } if ( (text_s = cached_get_text_stat( last_checked )) == NULL ) { log("ERROR: garb_text(): Can't get text-stat.\n"); + tell_cache_garb_text(0); return FALSE; } @@ -126,6 +129,7 @@ garb_text(void) if ( text_s->no_of_marks > 0 || age < 24 * 3600 ) { + tell_cache_garb_text(0); return FALSE; } @@ -141,7 +145,10 @@ garb_text(void) limit = (24 * 3600 * cached_get_garb_nice( misc->datum.recipient )); if ( age < limit ) + { + tell_cache_garb_text(0); return FALSE; + } } break; @@ -152,7 +159,10 @@ garb_text(void) limit = ( 24 * 3600 * cached_get_garb_nice( misc->datum.cc_recipient )); if ( age < limit ) + { + tell_cache_garb_text(0); return FALSE; + } } break; @@ -173,6 +183,7 @@ garb_text(void) if ( difftime ( time(NULL), misc->datum.sent_at ) < limit ) { + tell_cache_garb_text(0); return FALSE; } @@ -188,6 +199,7 @@ garb_text(void) VBUG(("garb_text: deleting %d\n", last_checked)); do_delete_text ( last_checked, text_s ); deleted_texts++; + tell_cache_garb_text(0); return FALSE; } diff --git a/src/server/version.incl b/src/server/version.incl index 5b7d113eec455dcbd3a5e84223a2d60ef87cd0d0..038a231b79ebf6106df803e7fbe672369bd7f117 100644 --- a/src/server/version.incl +++ b/src/server/version.incl @@ -1,5 +1,5 @@ /* - * $Id: version.incl,v 0.33 1992/10/27 04:43:02 ceder Exp $ + * $Id: version.incl,v 0.34 1992/11/22 15:14:55 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -27,4 +27,4 @@ * The version number is encoded in a long. It shall be printed as * in sed s/\(.*\)\(..\)\(..\)/\1.\2.\3/ */ -10206 +10207