[DGD] 1.2.83

Felix A. Croes felix at dworkin.nl
Fri Mar 5 00:50:12 CET 2004


"Colin Ross" <c.ross at cantab.net> wrote:

> > +  - Added IPv6 support for unix.
>
> Since this makes set_mode() in /kernel/lib/connection atomic,
> and thereby prevents me from quitting (since I am currently
> logging just about everything to disc), I was wondering if 
> there is a way for a given function to discover whether it
> has been called atomically, so that it can act appropriately?
> Something in the call_trace() perhaps?

This is an oversight.  The kernel library should not force design
decisions in this manner.  The function could have been safely made
atomic had nothing else been called by it.

I thought I had found the first case in which the kernel library could
genuinely use an atomic function as an alternative for the more heavy-
handed rlimits (-1; -1).  I should have known better.  On as low a level
as the kernel library, everything has repercussions... oh well.

You may apply the following patch, which will also be part of the next
release.

Regards,
Dworkin

--- snip ---
diff -c -r1.34 dgd/mud/kernel/lib/connection.c
*** dgd/mud/kernel/lib/connection.c	3 Mar 2004 22:47:03 -0000	1.34
--- dgd/mud/kernel/lib/connection.c	4 Mar 2004 23:42:42 -0000
***************
*** 25,44 ****
   * NAME:	set_mode()
   * DESCRIPTION:	set the current connection mode
   */
! static atomic void set_mode(int newmode)
  {
      if (newmode != mode && newmode != MODE_NOCHANGE) {
  	if (newmode == MODE_DISCONNECT) {
  	    destruct_object(this_object());
- 	} else if (newmode >= MODE_UNBLOCK) {
- 	    if (newmode - MODE_UNBLOCK != blocked) {
- 		block_input(blocked = newmode - MODE_UNBLOCK);
- 	    }
  	} else {
! 	    if (blocked) {
! 		block_input(blocked = FALSE);
  	    }
- 	    mode = newmode;
  	}
      }
  }
--- 25,48 ----
   * NAME:	set_mode()
   * DESCRIPTION:	set the current connection mode
   */
! static void set_mode(int newmode)
  {
      if (newmode != mode && newmode != MODE_NOCHANGE) {
  	if (newmode == MODE_DISCONNECT) {
  	    destruct_object(this_object());
  	} else {
! 	    rlimits (-1; -1) {
! 		if (newmode >= MODE_UNBLOCK) {
! 		    if (newmode - MODE_UNBLOCK != blocked) {
! 			block_input(blocked = newmode - MODE_UNBLOCK);
! 		    }
! 		} else {
! 		    if (blocked) {
! 			block_input(blocked = FALSE);
! 		    }
! 		    mode = newmode;
! 		}
  	    }
  	}
      }
  }
***************
*** 201,221 ****
   * NAME:	message()
   * DESCRIPTION:	send a message across the connection
   */
! atomic int message(string str)
  {
      if (previous_object() == user) {
! 	int len;
  
! 	buffer = nil;
! 	len = send_message(str);
! 	if (len != strlen(str)) {
! 	    /*
! 	     * string couldn't be sent completely; buffer the remainder
! 	     */
! 	    buffer = str[len ..];
! 	    return FALSE;
! 	} else {
! 	    return TRUE;
  	}
      }
  }
--- 205,227 ----
   * NAME:	message()
   * DESCRIPTION:	send a message across the connection
   */
! int message(string str)
  {
      if (previous_object() == user) {
! 	rlimits (-1; -1) {
! 	    int len;
  
! 	    buffer = nil;
! 	    len = send_message(str);
! 	    if (len != strlen(str)) {
! 		/*
! 		 * string couldn't be sent completely; buffer the remainder
! 		 */
! 		buffer = str[len ..];
! 		return FALSE;
! 	    } else {
! 		return TRUE;
! 	    }
  	}
      }
  }
--- snip ---
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list