* control.c: fixed a potential concurrency/race condition in
authorArt Cancro <ajc@citadel.org>
Mon, 28 Nov 2005 15:46:55 +0000 (15:46 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 28 Nov 2005 15:46:55 +0000 (15:46 +0000)
  the get_new_[message|room|user]_number() functions.

citadel/ChangeLog
citadel/control.c

index bdf12479e4c2866f2ba50f03c8cbe20fea081ede..377fcc5be46634ce5cb18ad7b02e3794be55777c 100644 (file)
@@ -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.
 
index da9603abaf4de41fec2c9e8a3bc00a8f8432d64f..cb3b3f190471b1b723333bfa01f1d52a4f50fb89 100644 (file)
@@ -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);
 }