Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 16171 invoked from network); 27 Sep 2010 15:40:57 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 27 Sep 2010 15:40:57 -0000 Received: (qmail 10125 invoked by uid 500); 27 Sep 2010 15:40:56 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 9800 invoked by uid 500); 27 Sep 2010 15:40:55 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 9648 invoked by uid 99); 27 Sep 2010 15:40:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Sep 2010 15:40:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Sep 2010 15:40:53 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o8RFeXRK004903 for ; Mon, 27 Sep 2010 15:40:33 GMT Message-ID: <4704036.421781285602033230.JavaMail.jira@thor> Date: Mon, 27 Sep 2010 11:40:33 -0400 (EDT) From: "Paul Joseph Davis (JIRA)" To: dev@couchdb.apache.org Subject: [jira] Commented: (COUCHDB-800) Problem when writing larger than 4kb file headers In-Reply-To: <11038246.13211276628003443.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COUCHDB-800?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12915336#action_12915336 ] Paul Joseph Davis commented on COUCHDB-800: ------------------------------------------- I do believe you're correct. Think you could make a failing test case and/or patch to show the behaviour? > Problem when writing larger than 4kb file headers > ------------------------------------------------- > > Key: COUCHDB-800 > URL: https://issues.apache.org/jira/browse/COUCHDB-800 > Project: CouchDB > Issue Type: Bug > Components: Database Core > Affects Versions: 0.11 > Reporter: Damien Katz > Assignee: Damien Katz > Fix For: 0.11.1, 0.12 > > > From Andrey Somov: > Hi, > while reading the CouchDB source I found a question in couch_file.erl, > I am not sure whether it is a bug or not. > Lines 297-311: > handle_call({write_header, Bin}, _From, #file{fd=Fd, eof=Pos}=File) -> > BinSize = size(Bin), > case Pos rem ?SIZE_BLOCK of > 0 -> > Padding = <<>>; > BlockOffset -> > Padding = <<0:(8*(?SIZE_BLOCK-BlockOffset))>> > end, > FinalBin = [Padding, <<1, BinSize:32/integer>> | make_blocks(1, [Bin])], > case file:write(Fd, FinalBin) of > ok -> > {reply, ok, File#file{eof=Pos+iolist_size(FinalBin)}}; > Error -> > {reply, Error, File} > end; > Because <<1, BinSize:32/integer>> occupies 5 bytes make_blocks() shall > use offset=5, but the offset is only 1. > (it should be make_blocks(5, [Bin])) > Since the header is smaller then 4k there is no difference and it > works (the tests succeed with both 1 and 5). But it makes it more > difficult to understand the code for those who study the source to > understand how it works. > - > Thank you, > Andrey -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.