unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Kevin Ryde <user42@zip.com.au>
To: Guile-Devel <guile-devel@gnu.org>
Subject: Re: Unbuffered socket I/O
Date: Thu, 01 Mar 2007 07:59:39 +1100	[thread overview]
Message-ID: <874pp69ex0.fsf@zip.com.au> (raw)
In-Reply-To: <87fy8qlik1.fsf@laas.fr> (Ludovic Courtès's message of "Wed, 28 Feb 2007 10:47:58 +0100")

ludovic.courtes@laas.fr (Ludovic Courtès) writes:
>
> Below is a tentative patch (I chose more meaningful names since they
> don't relate to `setvbuf(3)').

Call them setvbuf.  Two names for the same thing is more confusing
than one (slightly obscure) name.

> Besides, how about applying the change I originally proposed to HEAD?

No, principally because unbuffered is an advertised feature.  Even if
it was year zero you'd probably still choose them to start unbuffered,
since there's various ways to do comms and it can be up to an
application how much might be desirable.  For block operations for
instance it's certainly not wanted.

> That would require changing `recv!', `send', etc. so that they are
> somehow "buffering-aware".

That could be ok.  I doubt it makes much sense, because buffering is
more or less stream oriented yet those funcs are about packets.  But
they could still look at the buffers in the interests of keeping data
in sequence.

> Afflicted by what?

Blocking in one thread prevents gc in any other thread, bringing
everything to a screeching halt, before long.


> +	    "Use a @var{size}-octet

Say "byte" not "octet".  Octet sounds like one of those dreadful CCITT
standards.

> +  size_t c_size;
> +  c_size = scm_to_uint (size);

There's an scm_to_size_t for that.

+      if (c_offset > c_size)
+	scm_wrong_type_arg_msg (FUNC_NAME, 1, port,
+				"Input buffer must be flushed before it "
+				"can be shrunk");

The current code silently discards, I think that's probably enough.
If it was up to me I might move it to the putback buffer though.

> +      if (c_size == 0)
> +	new_buf = &pt->shortbuf, c_size = 1;

I suppose an explicit request for size==1 could use the shortbuf too,
though I see the existing code doesn't do that.  (Maybe there's a
reason it doesn't.)

I expect there's a memory leak there if you don't free the old buf
when becoming unbuffered.

> +      if ((pt->read_buf_size == 0) && (pt->write_buf_size == 0))
> +	SCM_SET_CELL_WORD_0 (port, SCM_CELL_WORD_0 (port) | SCM_BUF0);

That'd need to turn the flag off too, if it's become non-zero.

> +      if (c_offset > c_size)
> +	scm_wrong_type_arg_msg (FUNC_NAME, 1, port,
> +				"Output buffer must be flushed before it "
> +				"can be shrunk");

That doesn't need to be an error does it?  Can't it be flushed there
and then?

Otherwise looks ok as long as it actually works! :)


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2007-02-28 20:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-23 17:09 Unbuffered socket I/O Ludovic Courtès
2007-02-23 22:36 ` Neil Jerram
2007-02-25 22:57 ` Kevin Ryde
2007-02-26 14:07   ` Ludovic Courtès
2007-02-26 20:32     ` Neil Jerram
2007-02-26 23:35       ` Kevin Ryde
2007-02-27  9:11       ` Ludovic Courtès
2007-02-28 21:24         ` Kevin Ryde
2007-03-01  9:10           ` Ludovic Courtès
2007-03-04 23:48             ` Kevin Ryde
2007-03-07  0:20             ` Kevin Ryde
2007-03-07  0:30             ` Kevin Ryde
2007-03-07  4:45               ` Kevin Ryde
2007-03-07  9:40               ` Ludovic Courtès
2007-02-26 23:27     ` Kevin Ryde
2007-02-28  9:47       ` Ludovic Courtès
2007-02-28 20:59         ` Kevin Ryde [this message]
2007-03-01 10:44           ` Ludovic Courtès
2007-03-05 23:15             ` Kevin Ryde
2007-08-07 16:01               ` Ludovic Courtès
2007-05-13 17:13       ` `scm_std_select ()' call in `fport_wait_for_input ()' Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874pp69ex0.fsf@zip.com.au \
    --to=user42@zip.com.au \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).