Commit 53acf950 authored by David Byers's avatar David Byers

Memory management

        Free everything on exit
        The server should now exit with zero allocated strings and
        zero allocated blocks.

Test cases
        Added a few test cases for improved coverage and recently
        fixed bugs.
parent bfa4c83a
1999-05-21 David Byers <davby@ida.liu.se>
* doc/lyskomd.texi: Merged lyskomdb.texi into this document.
* src/server/server-config.c: Unassign the lockfile name.
* doc/Makefile.am (info_TEXINFOS): Removed deleted files.
(EXTRA_DIST): Removed deleted files from EXTRA_DIST.
* src/server/conf-file.c (unassign_string): New function.
* src/server/conf-file.h (parameter): Added a free function.
* src/server/simple-cache.c (free_all_cache): Free the
small_conf_arr.
* src/server/ramkomd.c (dump_exit_statistics): Moved remaining
frees from main to here.
1999-05-20 David Byers <davby@ida.liu.se>
* src/server/testsuite/config/unix.exp: You can now supply
MEMTRACE, ATTACH and EFENCE algorithms on the runtest command
line.
* src/server/testsuite/Makefile.am (EXTRA_DIST): Added new leak
tests to EXTRA_DIST.
Eliminated memory leaks in aux-item definition parser
* src/server/aux-items.c (free_aux_item_definitions): Free each
individual aux item definition. Another memory leak down the
drain.
* src/server/aux-item-def-parse.y: Free the string of an ID
parameter when we see one. Another memory leak bites the dust.
* src/server/aux-items.c (aux_item_definition_cache_regexp): Plug
a really minor (constant size) memory leak.
* src/server/aux-item-def-parse.y: Use string_free to free stuff
allocated with s_crea_c_str.
* src/server/aux-items.c (aux_item_trigger_link_item): Use
string_free to free string allocated with s_crea_c_str.
(free_aux_item_definitions): Same here.
1999-05-19 David Byers <davby@ida.liu.se>
* src/server/prot-a-parse.c (prot_a_parse_aux_item_list): Clear
the dummy aux item after parsing it. Memory leak plugged.
* src/server/memory.c (clear_aux_item): New function.
(free_aux_item_list): Use it.
* src/server/prot-a-parse.c (prot_a_parse_num_list): Handle
truncation so protocol errors during truncation will not break the
server.
(prot_a_hunt_nl): Same here.
(prot_a_parse_aux_item_list): Same here.
* src/server/prot-a.c (prot_a_init): Initialize
array_parse_parsed_length
* src/server/internal-connections.c (init_connection): Initialize
array_parse_parsed_length
* src/server/connections.c (free_parsed): Initialize
array_parse_parsed_length.
* src/server/connections.h (Connection): Added
array_parse_parsed_length
* src/server/fncdef.txt: Truncate strings in set_client_version to
client_data_len.
* src/server/ramkomd.c (main): Free aux-item definitions on exit.
* src/server/aux-items.c (free_aux_item_definitions): New function
to free all data associated with aux-item defs.
* src/server/ramkomd.c (main): Free aux-item definition.
1999-05-18 David Byers <davby@ida.liu.se>
* src/server/prot-a-parse.c (prot_a_parse_aux_item_flags): Handle
variable-length bitfields.
* src/server/memory.c (init_aux_item_flags): New function.
* src/server/prot-a-parse.c (prot_a_parse_priv_bits): Handle
variable-length bitfields.
(prot_a_parse_membership_type): Same here.
(prot_a_parse_conf_type): Same here.
* src/server/memory.c (init_membership_type): New function.
* doc/Protocol-A.texi (set-client-version): Added list of known
clients.
* ChangeLog.1: Inserted doc/LOGG
* doc/LOGG: Added to ChangeLog.1
* src/server/conference.c (set_supervisor): Use
is_strictly_supervisor instead of is_supervisor.
1999-05-21 Per Cederqvist <ceder@gratia>
Lock the database file with an explicit lock file.
......
......@@ -1053,3 +1053,85 @@ Wed Apr 18 00:08:22 1990 Per Cederqvist (ceder at lage)
* Ny funktion i services: query_unread_mail. (Se m 230)
Wed Apr 18 00:08:22 1990 Per Cederqvist (ceder at lage)
Det SIST SKRIVNA hamnar F\RST I FILEN /Aronsson.
Loggfil d{r man skriver vad man g|r. Det {r b{ttre att du skriver
lite
{n inte alls (mest riktat till mig sj{lv...). /lw 900402
----------------------------------------------------------------------
3 juni 1991 Aronsson
Uppdaterat prot-A.txt och i denna inkluderat prot-A.bnf. Satt
prot-A.bnf till att vara en symbolisk l{nk till txt-filen.
14 oktober 1990 Aronsson was here
Lagt hit nedanst}ende filer. Originalen beh}ller jag hemma hos mig.
prot-A.txt Spec protokoll A. Textdelen. Svensk font.
prot-A.bnf Spec protokoll A. Koddelen. Engelsk font.
version Hantering av {ndringsf|rslag och versioner.
1990-04-17 /ceder
Tog bort den felaktiga definitionen av typen Connection ur kom-types.h. Den
riktiga finns i server/server.h.
Flyttade definitioner av Persons, Marks, String och Map till kom-types.h.
B|rjade anv{nda M-X Add-change-log-entry i st{llet.
900407 /lw
Det h{r {r c. Allts} b|r active_connection vara en pekare! (har {ndrat)
Flyttade smalloc ("s{ker" malloc) till cache.c.
Nu sparar ldb.c {ven texts-f{ltet i person-structen...
1990-04-04 /ceder
[ndrade i Person-structen: Tog bort created_texts. La till
first_text, last_text och texts (en lista med globala textnummer de globala
textnummer som personen har skapat.)
active_connection (server.h) {r index i arrayen connections (connections.c).
Skapade filen doc/security-levels.txt d{r det anges vad de olika priv-bitarna
inneb{r.
900404 /lw
[ndrade ldb:s felhantering. Nu finns den! Fortfarande inte speciellt
snygg, men n}got b{ttre {n tidigare. Returnerar intern felkod i
ldb_errno och filhandtag till felande filen i ldb_errfileno.
1990-04-02 /ceder
Fr}n och med nu anv{nder vi ISO-standard f|r datum. (:-)
kom-types.h: Tog bort flags och lade till user_area i Person-structen.
900402 /lw
Vi flyttade om filerna. Under ldb ligger nu i princip endast ldb.c och
ldb.h. Under client ligger de filer som {r specifika f|r klienten och
under server ligger de server-specifika filerna. doc-directoryt
inneh}ller dokumentationen f|r det vi h}ller p} med.
Direkt under 2kom ligger f|r n{rvarande allt som {r gemensamt f|r
s}v{l klient som server. Det {r types.h och kom-types.h (varf|r {r
det uppdelat i tv} filer?) samt services.h som tidigare hette
atomic.h.
Jag har f|rresten tagit bort parametern connection som alla
funktioner i atomic.h hade. Fr}n klientens synvinkel finns inte
den parametern och det verkar f}nigt att ha den i servern. Om man
har samma parameter till samtliga funktioner tycker jag det {r
ganska vettigt att i st{llet anv{nda en global variabel.
......@@ -4,64 +4,14 @@ server.
Before the next release
=======================
Dokumentera vad sessionsnummer 0 betyder.
Testfall för sända meddelande till hemligt möte
* Showstoppers
** Consider changing many paths so that it is safe to install lyskomd
with prefix=/usr/local.
How about saving this for the next release and then support
various other path conventions?
** Consider removing the pid file on exit.
** Consider locking the database, so that dbck cannot do harm, and so
that only one lyskomd can use the database (consider NFS).
** Add a checksum on each object in the database.
** The text-mass file should contain some redundancy. At a minimum, it
should store the text number and text length of each text, so that
there is absolutely no risk that the wrong text is displayed. (That
has actually happened more than once due to faulty hardware or
operating systems--we should do better.)
NU. ceder
** Documentation Issues
*** Remove the text "In all likelihood, the implementation of this flag
is screwed up." from lyskomd.texi after checking that
supervisor-only works properly.
*** Document updateLysKOM in lyskomd.texi.
There should be an "Invoking updateLysKOM" node.
updateLysKOM should use the "Status file" parameter (and other
parameters). (DONE)
Use parameters in src/server/updateLysKOM.c`savecore(). (DONE)
I will do this --ceder
*** Document komrunning in lyskomd.texi.
There should be an "Invoking komrunning" node.
komrunning should be rewritten i C; it only works with BSD-style ps
programs. (DONE, but it no longer displays the process)
I am doing this --ceder
*** Dump all little doc files into the texinfo manuals.
Remaining:
disc-cache.spec lyskomd.texi översätt, uppdatera
local-to-global.doc lyskomd.texi ceder?
prot-a-tankar *
prot_a *
security-levels.txt Protocol-A.texi DONE
what-is-unread.swe Protocol-A.texi DONE
I will do this --DCB
*** Fix the node structure of Protocol-A.texi (3228867).
I will do this --DCB
Looks done...
*** Update/rewrite README.
Introduction:
......@@ -72,6 +22,9 @@ Testfall f
Chapter 4 (Building): Needs major revisions.
Chapter 5 (Insallation): Needs writing.
--ceder
*** The protocol revision section of Protocol-A.info is incomplete.
I will do this --ceder
......@@ -87,119 +40,64 @@ Testfall f
** Testing
*** Try sending in negative lengths whenever we can send an array.
DONE for misc-info-list, add-aux delete-aux
*** Check that we don't leak memory when truncating a long
aux_item_list send from the client.
*** In prot_a_get_token, what is an insane token length?
*** Test validation of regexps containing groups. Try "X\\(YZ\\)?X".
I will do this. --DCB
*** Statement coverage tests for the aux-item-def parser
David.
** Known Bugs
*** Should anyone be able to set their letterbox to secret?
*** Timestamps of various things are not synchronized.
This is seen easily when lyskomd executes really slowly.
Known cases: last-written does not match text-stat (FIXED)
aux-item sent-at don't match created in text&conf
(FIXED)
There might be others.
*** Fixa s{kerhetsbuggen vid read_texts et c. Det b|r vara s} att man
inte f}r veta mappningen s} ofta som nu. Vilka texter som {r l{sta
b|r ocks} vara mer hemligt. Ett nytt anrop, query_unread(), b|r
inf|ras. Resultatet {r antalet ol{sat brev och _kanske_
Local_text_no f|r det h|gsta nummret.
(Det var l{nge sen jag skrev det h{r, och jag minns inte riktigt
vad jag menar, men man borde nog titta p} det h{r s} sm}ningom).
*** Asynchronous messages may not be censored enough. Check all
messages that contain conf-nos.
*** difftime is not used everywhere where it should be used. There are
a few places where '-' is still used to get a diff in seconds.
** Improvements
* High priority, but they can wait until after the next release.
** Improvements
** Uppmärkningen i texiinfofilerna
*** We have to be able to limit creation of certain aux-items to users
with special privileges. Most of the import/export items need
this. Put in a new flag in the aux-item-definition file, add it to
the parser, check it in aux_item_check_add_perm or whatever the
hell the function was named. Test it. The biggest problem is to
figure out what permissions should be needed. I suppose it's
possible that we could let the user specify level and bits in the
aux-items.conf file, but that would mean mucking more with the
parser.
I will do this. --DCB
** Consider changing many paths so that it is safe to install lyskomd
with prefix=/usr/local.
*** We have to be able to specify that some aux-items can only be
created by the server. It's possible that admins should be allowed
to create them as well. Perhaps this point and the previous point
can be solved as one.
How about saving this for the next release and then support
various other path conventions?
*** When creating an FAQ item create a reverse item on the text. Make
sure that they are always added and removed as a pair. Accomplish
this with the add, delete and undelete triggers.
** Add a checksum on each object in the database.
*** Add triggers have to have the capability of preventing addition.
This is difficult since we check the validity of addition before
adding the items. The prevention would have to happen in the check
phase, when the triggers are not called. The correct solution is
probably to implement validation functions in addition to
validation strings and let the validation function take care of
checking if the item can be added.
** The text-mass file should contain some redundancy. At a minimum, it
should store the text number and text length of each text, so that
there is absolutely no risk that the wrong text is displayed. (That
has actually happened more than once due to faulty hardware or
operating systems--we should do better.)
*** The mark text trigger has to cause add failure if the text does
not exist.
** Should anyone be able to set their letterbox to secret?
*** Fine-tune the Text_mapping data type (3623903, 3624144, 3624179, 3624173).
** Fixa s{kerhetsbuggen vid read_texts et c. Det b|r vara s} att man
inte f}r veta mappningen s} ofta som nu. Vilka texter som {r l{sta
b|r ocks} vara mer hemligt. Ett nytt anrop, query_unread(), b|r
inf|ras. Resultatet {r antalet ol{sat brev och _kanske_
Local_text_no f|r det h|gsta nummret.
*** The Info structure should contain statistics about the server
(uptime, other interesting stuff.) (from 1991) Implement, reject
or postpone.
(Det var l{nge sen jag skrev det h{r, och jag minns inte riktigt
vad jag menar, men man borde nog titta p} det h{r s} sm}ningom).
*** Read all texts in LysKOM (-) Systemet, protokollet mm created
after 1991 (start at text 170527) and incorporate selected
information in this document.
** Asynchronous messages may not be censored enough. Check all
messages that contain conf-nos.
*** Improve the file format for local-to-global.c.
** difftime is not used everywhere where it should be used. There are
a few places where '-' is still used to get a diff in seconds.
*** Improve the file format for local-to-global.c. Warning: this will
cause an incompatible change in the database format.
*** Use libisc 1.0.
I will do this --ceder
** Add triggers have to have the capability of preventing addition.
This is difficult since we check the validity of addition before
adding the items. The prevention would have to happen in the check
phase, when the triggers are not called. The correct solution is
probably to implement validation functions in addition to
validation strings and let the validation function take care of
checking if the item can be added.
*** Get rid of mux_printf and doc/mux.proto et c.
I am doing this --ceder
** The Info structure should contain statistics about the server
(uptime, other interesting stuff.) (from 1991)
Implement a new call for this.
** Fix proper ctor/dtor semantics of everything in memory.c. _clear
is an abomination.
** Check the FIXME in cached_conf_exists. I am certain that the
necessary changes to cached_delete_conf are done, and almost sure
that no other changes are required (checked where s.exists is set
to zero for existing confs, and that is only in init_cache and
cached_delete_conf. See ChangeLog entry for Sat Sep 13
(simple-cache.c). -- DCB
But: we found problems with this 1999-03-28, which DCB fixed in his
copy of the code. Committed yet?
* High priority, but they can wait until after the next release.
** Fix all bitfield parsers to deal with arbitrary lengths. Maybe...
** Call to s_fcrea_str in prot_a_get_token should be removed. There is
really no reason why we can't us a statically allocated string
instead (I know, this is microoptimization, but this function gets
......@@ -224,7 +122,6 @@ Testfall f
possible that we could let the user specify level and bits in the
aux-items.conf file, but that would mean mucking more with the
parser.
I will do this. --DCB
** Fixa s{kerhetsbuggen vid read_texts et c. Det b|r vara s} att man
inte f}r veta mappningen s} ofta som nu. Vilka texter som {r l{sta
......@@ -735,6 +632,91 @@ Testfall f
doesn't allow more than one file to include version.texi.
DONE.
** Check the FIXME in cached_conf_exists. I am certain that the
necessary changes to cached_delete_conf are done, and almost sure
that no other changes are required (checked where s.exists is set
to zero for existing confs, and that is only in init_cache and
cached_delete_conf. See ChangeLog entry for Sat Sep 13
(simple-cache.c). -- DCB
But: we found problems with this 1999-03-28, which DCB fixed in his
copy of the code. Committed yet?
DONE.
** Stoppa in lyskomdb.texi i lyskomd.texi
DONE.
** Fråga JSK, Zander, mfl vad deras klienter sätter för client version
DONE.
** Check usage of is_supervisor.
DONE.
*** Remove the text "In all likelihood, the implementation of this flag
is screwed up." from lyskomd.texi after checking that
supervisor-only works properly.
DONE.
*** Dump all little doc files into the texinfo manuals.
Remaining:
disc-cache.spec lyskomd.texi översätt, uppdatera
local-to-global.doc lyskomd.texi ceder?
prot-a-tankar *
prot_a *
security-levels.txt Protocol-A.texi DONE
what-is-unread.swe Protocol-A.texi DONE
KLART.
*** Fix the node structure of Protocol-A.texi (3228867).
DONE.
*** In prot_a_get_token, what is an insane token length?
DONE.
*** We have to be able to specify that some aux-items can only be
created by the server. It's possible that admins should be allowed
to create them as well. Perhaps this point and the previous point
can be solved as one.
DONE.
*** When creating an FAQ item create a reverse item on the text. Make
sure that they are always added and removed as a pair. Accomplish
this with the add, delete and undelete triggers.
DONE.
*** The mark text trigger has to cause add failure if the text does
not exist.
DONE.
*** Use libisc 1.0.
I will do this --ceder
DONE.
*** Get rid of mux_printf and doc/mux.proto et c.
I am doing this --ceder
DONE.
** Fix all bitfield parsers to deal with arbitrary lengths. Maybe...
DONE.
*** Send all async messages with async messages turned off
DONE.
*** Send all async messages with a client connected that has not sent
initial "greeting"
DONE.
*** Try sending in negative lengths whenever we can send an array.
DONE for misc-info-list, add-aux delete-aux
*** If we get protocol error while truncating a long list, things
will get messed up. I think.
DONE.
*** Check that we don't leak memory when truncating a long
aux_item_list send from the client.
DONE.
* In progress
** Document aux-items for mail import/export. (3229403)
......
%{
/*
* $Id: aux-item-def-parse.y,v 1.6 1999/05/18 13:06:45 byers Exp $
* $Id: aux-item-def-parse.y,v 1.7 1999/05/21 11:36:37 byers Exp $
* Copyright (C) 1994, 1995, 1996 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -91,6 +91,7 @@
#include "lyskomd.h"
#include "debug.h"
#include "log.h"
#include "string-malloc.h"
BUGDECL;
......@@ -316,10 +317,10 @@ assign : ID '=' value ';'
tmp = s_crea_c_str($1);
aux_item_def_error_line = @1.first_line;
yyerror("invalid field name: %s", tmp);
free(tmp);
string_free(tmp);
}
if ($3.type == STRING)
if ($3.type == STRING || $3.type == ID)
{
s_clear(&($3).val.str);
$3.val.str = EMPTY_STRING;
......@@ -446,7 +447,7 @@ short aux_item_def_check_trigger(const char *check_name,
tmp_string = s_crea_c_str(function_name);
trigger = aux_item_find_trigger(tmp_string);
sfree(tmp_string);
string_free(tmp_string);
if (trigger == NULL)
{
......@@ -555,7 +556,7 @@ short aux_item_def_check_validate(const char *check_name,
{
tmp_string = s_crea_c_str(data);
validator = aux_item_find_validator(tmp_string);
sfree(tmp_string);
string_free(tmp_string);
if (validator == NULL)
{
......
/*
* $Id: aux-items.c,v 1.12 1999/05/18 13:06:46 byers Exp $
* $Id: aux-items.c,v 1.13 1999/05/21 11:36:39 byers Exp $
* Copyright (C) 1994, 1995, 1996 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -57,6 +57,7 @@
#include "admin.h"
#include "param.h"
#include "server-time.h"
#include "string-malloc.h"
#define AUX_ADJUST_FLAG(flg) item->flags.flg = (def->clear_flags.flg)?0:((def->set_flags.flg)?1:item->flags.flg)
......@@ -474,7 +475,10 @@ aux_item_definition_cache_regexp(Aux_item_definition *def,
def->name);
if (def->validators[ix].v.re.cached_re_buf)
sfree(def->validators[ix].v.re.cached_re_buf);
if (def->validators[ix].v.re.regexp)
string_free(def->validators[ix].v.re.regexp);
def->validators[ix].v.re.cached_re_buf = NULL;
def->validators[ix].v.re.regexp = NULL;
return;
}
}
......@@ -483,7 +487,6 @@ void
initialize_aux_items(char *aux_def_file)
{
unsigned long i;
Aux_item_definition *def;
/* Set up precompiled items */
......@@ -497,16 +500,59 @@ initialize_aux_items(char *aux_def_file)
/* Read definitions from configuration file */
parse_aux_item_definitions(aux_def_file);
}
def = aux_item_definition_list;
void
free_aux_item_definitions(void)
{
unsigned long i;
Aux_item_definition *def;
Aux_item_definition *tmp;
def = aux_item_definition_list;
while (def != NULL)
{
/* FIXME: If we have validators, go through and cache their
FIXME: regexps, where appropriate */
def = def->next;
string_free(def->name);
for (i = 0; i < def->num_validators; i++)
{
if (def->validators[i].type == AUX_VALIDATE_REGEXP)
{
if (def->validators[i].v.re.regexp != NULL)
string_free(def->validators[i].v.re.regexp);
if (def->validators[i].v.re.cached_re_buf != NULL)
sfree(def->validators[i].v.re.cached_re_buf);
}
}
if (def->validators != NULL)
{
sfree(def->validators);
def->validators = NULL;
def->num_validators = 0;
}
if (def->add_triggers != NULL)
{
sfree(def->add_triggers);
def->add_triggers = NULL;
def->num_add_triggers = 0;
}
if (def->delete_triggers != NULL)
{
sfree(def->delete_triggers);
def->delete_triggers = NULL;
def->num_delete_triggers = 0;
}
if (def->undelete_triggers != NULL)