From 3c4ae27f45db8968d57b9871145fd117d4632d4a Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 28 Nov 2005 15:46:55 +0000 Subject: [PATCH] * control.c: fixed a potential concurrency/race condition in the get_new_[message|room|user]_number() functions. --- citadel/ChangeLog | 4 ++++ citadel/control.c | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index bdf12479e..377fcc5be 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,5 +1,9 @@ $Id$ +Mon Nov 28 10:45:21 EST 2005 ajc +* control.c: fixed a potential concurrency/race condition in + the get_new_[message|room|user]_number() functions. + Sun Nov 27 21:20:27 EST 2005 ajc * Eliminated the use of tmpnam() to shut up the compiler warnings. diff --git a/citadel/control.c b/citadel/control.c index da9603aba..cb3b3f190 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -117,12 +117,13 @@ void put_control(void) */ long get_new_message_number(void) { + long retval = 0L; begin_critical_section(S_CONTROL); get_control(); - ++CitControl.MMhighest; + retval = ++CitControl.MMhighest; put_control(); end_critical_section(S_CONTROL); - return (CitControl.MMhighest); + return(retval); } @@ -131,12 +132,13 @@ long get_new_message_number(void) */ long get_new_user_number(void) { + long retval = 0L; begin_critical_section(S_CONTROL); get_control(); - ++CitControl.MMnextuser; + retval = ++CitControl.MMnextuser; put_control(); end_critical_section(S_CONTROL); - return (CitControl.MMnextuser); + return(retval); } @@ -146,12 +148,13 @@ long get_new_user_number(void) */ long get_new_room_number(void) { + long retval = 0L; begin_critical_section(S_CONTROL); get_control(); - ++CitControl.MMnextroom; + retval = ++CitControl.MMnextroom; put_control(); end_critical_section(S_CONTROL); - return (CitControl.MMnextroom); + return(retval); } -- 2.39.2