From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 7B3B37ED26 for ; Wed, 6 Jun 2012 15:29:45 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuQCABFaz0/AbSoIe2dsb2JhbABFhQBOngmQXiIBAQsLJgQjghgBAQUMFw8BOwsQCQIJDwICCR0CAhQYGRgTEodrAwsEB6RFiQoDiVgUgQ+JcSSEYzJgA41Uh0eBEYgRiTk X-IronPort-AV: E=Sophos;i="4.75,724,1330902000"; d="scan'208";a="146773941" Received: from einhorn.in-berlin.de ([192.109.42.8]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Jun 2012 15:29:44 +0200 X-Envelope-From: oliver@first.in-berlin.de Received: from first (e178043142.adsl.alicedsl.de [85.178.43.142]) (authenticated bits=0) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id q56DTeeM032642 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 6 Jun 2012 15:29:40 +0200 Received: by first (Postfix, from userid 1000) id 2044A154051D; Wed, 6 Jun 2012 15:29:40 +0200 (CEST) Date: Wed, 6 Jun 2012 15:29:39 +0200 From: oliver To: =?utf-8?B?VMO2csO2aw==?= Edwin Cc: rixed@happyleptic.org, caml-list@inria.fr Message-ID: <20120606132939.GE1854@siouxsie> References: <20120606130646.GA23115@securactive.lan> <4FCF584E.2000309@etorok.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4FCF584E.2000309@etorok.net> User-Agent: Mutt/1.5.20 (2009-06-14) X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 Subject: Re: [Caml-list] Unix.single_write, doc and atomicity Hello, single_write-docs say: "Same as write, but attempts to write only once. Thus, if an error occurs, single_write guarantees that no data has been written." Attempts does not mean guarantee. If it fails, it will give an error. But I wonder if "Thus, if an error occurs, single_write guarantees that no data has been written." is correct for all devices and situations. It may also be possible to write less bytes than one wants. In this case "guarantees that no data has been written" seems to be violated. For these cases, the docs need to be corrected. More precise IMHO would be: "If no error occured, all data has been written sucessfully in one attempt." Ciao, Oliver On Wed, Jun 06, 2012 at 04:17:02PM +0300, Török Edwin wrote: > 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 > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >