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

(check_membership): Handle range-based representation of memberships.

parent 2064df08
/*
* $Id: dbck.c,v 0.70 2002/10/31 09:31:06 ceder Exp $
* $Id: dbck.c,v 0.71 2002/11/06 18:40:20 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -805,9 +805,12 @@ check_membership(Pers_no pno,
{
int errors=0;
Conference *conf;
int i;
Local_text_no last=0;
Member *mem;
struct read_range *begin;
struct read_range *end;
struct read_range *ptr;
conf = cached_get_conf_stat(mship->conf_no);
if ( conf == NULL )
......@@ -819,30 +822,56 @@ check_membership(Pers_no pno,
else
{
/* Check read texts */
if (mship->last_text_read >= l2g_first_appendable_key(&conf->texts))
{
kom_log("Person %lu %s %lu in conf %lu, which only has %lu texts.\n",
(unsigned long)pno,
"has read text",
(unsigned long)mship->last_text_read,
(unsigned long)mship->conf_no,
(unsigned long)(l2g_first_appendable_key(&conf->texts) -1));
errors++;
}
for ( last = i = 0; i < mship->no_of_read; i++)
last = 0;
if (mship->no_of_read_ranges > 0)
{
if ( mship->read_texts[i] <= last )
begin = &mship->read_ranges[0];
end = begin + mship->no_of_read_ranges;
for (ptr = begin; ptr < end; ptr++)
{
kom_log("Person %lu's membership in %lu %s %lu<%lu> <= %lu.\n",
(unsigned long)pno, (unsigned long)mship->conf_no,
"is corrupt: read text number",
(unsigned long)mship->read_texts[i], (unsigned long)i,
(unsigned long)last);
errors++;
if (ptr->first_read > ptr->last_read)
{
kom_log("Person %lu's membership in %lu is corrupt: "
"bad range: %lu-%lu.\n",
(unsigned long)pno, (unsigned long)mship->conf_no,
(unsigned long)ptr->first_read,
(unsigned long)ptr->last_read);
errors++;
}
if (ptr != begin && last + 1 == ptr->first_read)
{
kom_log("Person %lu's membership in %lu is corrupt: "
"adjoining ranges not joined at around %lu.\n",
(unsigned long)pno, (unsigned long)mship->conf_no,
(unsigned long)ptr->first_read);
errors++;
}
if (ptr != begin && last >= ptr->first_read)
{
kom_log("Person %lu's membership in %lu is corrupt: "
"overlapping ranges: %lu-%lu, %lu-%lu.\n",
(unsigned long)pno, (unsigned long)mship->conf_no,
(unsigned long)(ptr-1)->first_read,
(unsigned long)(ptr-1)->last_read,
(unsigned long)ptr->first_read,
(unsigned long)ptr->last_read);
errors++;
}
last = ptr->last_read;
}
last = mship->read_texts[i];
}
if (last >= l2g_first_appendable_key(&conf->texts))
{
kom_log("Person %lu has read text %lu in conf %lu, "
"which only has %lu texts.\n",
(unsigned long)pno,
(unsigned long)last,
(unsigned long)mship->conf_no,
(unsigned long)(l2g_first_appendable_key(&conf->texts)-1));
errors++;
}
/* Check that he is a member */
......
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