caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Török Edwin" <edwin+ml-ocaml@etorok.net>
To: rixed@happyleptic.org
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Unix.single_write, doc and atomicity
Date: Wed, 06 Jun 2012 16:17:02 +0300	[thread overview]
Message-ID: <4FCF584E.2000309@etorok.net> (raw)
In-Reply-To: <20120606130646.GA23115@securactive.lan>

On 06/06/2012 04:06 PM, rixed@happyleptic.org wrote:
> I was reading the code for unix_single_write recently, and noticed two strange
> things that I prefer to discuss here before filling the bug tracker with
> dubious tickets.
> 
> First, the doc of Unix.single_write claims that this function "attemps to write
> only once", although the underlying unix_single_write C function clearly loops
> around a write if the buffer being written is larger than the internal buffer
> (16K).

Are we looking at the same file / function?
The one that loops is unix_write, I don't see any loops in unix_single_write:

CAMLprim value unix_single_write(value fd, value buf, value vofs, value vlen)
{
  long ofs, len;
  int numbytes, ret;
  char iobuf[UNIX_BUFFER_SIZE];

  Begin_root (buf);
    ofs = Long_val(vofs);
    len = Long_val(vlen);
    ret = 0;
    if (len > 0) {
      numbytes = len > UNIX_BUFFER_SIZE ? UNIX_BUFFER_SIZE : len;
      memmove (iobuf, &Byte(buf, ofs), numbytes);
      enter_blocking_section();
      ret = write(Int_val(fd), iobuf, numbytes);
      leave_blocking_section();
      if (ret == -1) uerror("single_write", Nothing);
    }
  End_roots();
  return Val_int(ret);


> 
> So this boils down to : unix_single_write really should perform a single write!

AFAICT it does only a single write.

Best regards,
--Edwin

  reply	other threads:[~2012-06-06 13:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-06 13:06 rixed
2012-06-06 13:17 ` Török Edwin [this message]
2012-06-06 13:29   ` oliver
2012-06-06 13:34   ` rixed
2012-06-16 23:11 ` Goswin von Brederlow

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

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

  git send-email \
    --in-reply-to=4FCF584E.2000309@etorok.net \
    --to=edwin+ml-ocaml@etorok.net \
    --cc=caml-list@inria.fr \
    --cc=rixed@happyleptic.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 NNTP newsgroup(s).