[Monetdb-developers] [Monetdb-checkins] MonetDB/src/common stream.mx, 1.133.2.2, 1.133.2.3

Ying Zhang Y.Zhang at cwi.nl
Mon Feb 19 00:46:12 CET 2007


On Fri, Feb 16, 2007 at 07:07:00PM +0000, Niels Nes wrote:
> Update of /cvsroot/monetdb/MonetDB/src/common
> In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv11260/src/common
> 
> Modified Files:
>       Tag: MonetDB_1-16
> 	stream.mx 
> Log Message:
> removed stream_r/wstream_byteorder
> replaced with stream_set_byteorder
> 
> the block_stream now always sends the blocksize/lastblock short in little
> endian format (ie this is now fully controlled in streams).
> The stream_set_byteorder only stores if the other end has little or bigendian
> byte orders (this can later be use when we send/receive binary data)
> 
> 
> 
> Index: stream.mx
> ===================================================================
> RCS file: /cvsroot/monetdb/MonetDB/src/common/stream.mx,v
> retrieving revision 1.133.2.2
> retrieving revision 1.133.2.3
> diff -u -d -r1.133.2.2 -r1.133.2.3
> --- stream.mx	16 Feb 2007 15:27:20 -0000	1.133.2.2
> +++ stream.mx	16 Feb 2007 19:06:57 -0000	1.133.2.3
> @@ -555,6 +554,22 @@
>  	return s->byteorder;
>  }
>  
> +void 
> +stream_set_byteorder(stream *s, char bigendian)
> +{
> +#ifdef STREAM_DEBUG
> +	printf("stream_set_byteorder %s, %d\n", s->name ? s->name : "<unnamed>");
> +#endif
> +	assert(s->access == ST_READ);

Hi Niels,

Won't this assert kill all write streams, since their access is set to
ST_WRITE?

If I use MapiClient, I get the following:

(in shell 1)
$ Mserver
# Monet Database Server V4.16.1
# Copyright (c) 1993-2007, CWI. All rights reserved.
# Compiled for x86_64-redhat-linux-gnu/64bit with 64bit OIDs;
# dynamically linked.
# Visit http://monetdb.cwi.nl/ for further information.
MonetDB>module(mapi);
MonetDB>

(in shell 2)
$ MapiClient
MapiClient: ../../../src/common/stream.mx:563: stream_set_byteorder:
Assertion `s->access == 0' failed.
Aborted


In 'connect_to_server', mid->to->access is set to ST_WRITE.


Jennie




> +	s->type = ST_BIN;
> +#ifdef WORDS_BIGENDIAN
> +	s->byteorder = bigendian ? 1234 : 3412;
> +#else
> +	s->byteorder = bigendian ? 3412 : 1234;
> +#endif
> +}
> +
> +
>  void
>  close_stream(stream *s)
>  {
> @@ -576,22 +591,6 @@
>  }
>  
>  stream *
> -stream_rstream_byteorder(stream *s, char bigendian)
> -{
> -#ifdef STREAM_DEBUG
> -	printf("stream_rstream_byteorder %s, %d\n", s->name ? s->name : "<unnamed>", bigendian);
> -#endif
> -	assert(s->access == ST_READ);
> -	s->type = ST_BIN;
> -#ifdef WORDS_BIGENDIAN
> -	s->byteorder = bigendian ? 1234 : 3412;
> -#else
> -	s->byteorder = bigendian ? 3412 : 1234;
> -#endif
> -	return s;
> -}
> -
> -stream *
>  stream_wstream(stream *s)
>  {
>  #ifdef STREAM_DEBUG
> @@ -604,22 +603,6 @@
>  	return s;
>  }
>  
> -stream *
> -stream_wstream_byteorder(stream *s, char bigendian)
> -{
> -#ifdef STREAM_DEBUG
> -	printf("stream_wstream_byteorder %s, %d\n", s->name ? s->name : "<unnamed>");
> -#endif
> -	assert(s->access == ST_WRITE);
> -	s->type = ST_BIN;
> -#ifdef WORDS_BIGENDIAN
> -	s->byteorder = bigendian ? 1234 : 3412;
> -#else
> -	s->byteorder = bigendian ? 3412 : 1234;
> -#endif
> -	return s;
> -}
> -
>  #define EXT_LEN 4
>  static const char *
>  get_extention(const char *file)
> @@ -2222,6 +2205,9 @@
>  			/* the last bit tells whether a flush is in there, it's not
>  			 * at this moment, so shift it to the left */
>  			blksize <<= 1;
> +#ifdef WORDS_BIGENDIAN
> +			blksize = short_int_SWAP(blksize);
> +#endif
>  			if (!stream_writeSht(s->s, blksize) || s->s->write(s->s, s->buf, 1, s->nr) != (ssize_t) s->nr) {
>  				ss->errnr = WRITE_ERROR;
>  				return -1;
> @@ -2451,6 +2437,10 @@
>  		return NULL;
>  	if ((b = bs_create(s)) == NULL)
>  		ns->errnr = OPEN_ERROR;
> +	/* blocksizes have a fixed little endian byteorder */ 
> +#ifdef WORDS_BIGENDIAN
> +	s->byteorder = 3412; /* simply != 1234 */
> +#endif
>  	ns->type = s->type;
>  	ns->access = s->access;
>  	ns->read = bs_read;
> 
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Monetdb-checkins mailing list
> Monetdb-checkins at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/monetdb-checkins




More information about the developers-list mailing list