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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 64EFF7ED26 for ; Wed, 6 Jun 2012 15:17:04 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EAEBXz0+wCYo3/2dsb2JhbABFtDWBB4IYAQEEAUABATYBAQ8LGAkWDwkDAgECAUUTAQUCAogCCaNYhC4BBY8cBosUJIJfgxaIPYxihVGDUIZXgmM X-IronPort-AV: E=Sophos;i="4.75,724,1330902000"; d="scan'208";a="161593753" Received: from mail.etorok.net ([176.9.138.55]) by mail1-smtp-roc.national.inria.fr with ESMTP; 06 Jun 2012 15:17:04 +0200 Received: from [192.168.1.101] (unknown [86.125.229.82]) by mail.etorok.net (Postfix) with ESMTPSA id 4808346B0; Wed, 6 Jun 2012 15:17:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=etorok.net; s=MAILOUT; t=1338988623; bh=d2byofRRbftTw16+wdE0r3gxtb91GgM6zrySGtQTeVU=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=NgXBc6zArEbK2VMV2bkvqmb8tVS7fcDXXxhL7NCimHHpZTTj1T+SZrbYO90d1WxjG jV6JiCEpbDT0meAs42cxTqQ7wLE8UOUwovZqZF+KbXlrDrdNF6hsDoc/gaBFGCOTn3 qrj2XxD+vf5NAihZ2ZqeqAVmdb+RLUN1jwI/b2X0= Message-ID: <4FCF584E.2000309@etorok.net> Date: Wed, 06 Jun 2012 16:17:02 +0300 From: =?ISO-8859-1?Q?T=F6r=F6k_Edwin?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4 MIME-Version: 1.0 To: rixed@happyleptic.org CC: caml-list@inria.fr References: <20120606130646.GA23115@securactive.lan> In-Reply-To: <20120606130646.GA23115@securactive.lan> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.97.3 at mail X-Virus-Status: Clean Subject: Re: [Caml-list] Unix.single_write, doc and atomicity 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