Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CB36010EA9 for ; Thu, 1 Aug 2013 05:21:00 +0000 (UTC) Received: (qmail 87144 invoked by uid 500); 1 Aug 2013 05:21:00 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 87007 invoked by uid 500); 1 Aug 2013 05:20:50 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 87000 invoked by uid 99); 1 Aug 2013 05:20:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Aug 2013 05:20:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Aug 2013 05:20:43 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8BA0A23888E7; Thu, 1 Aug 2013 05:20:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1509080 - /subversion/trunk/subversion/libsvn_subr/spillbuf.c Date: Thu, 01 Aug 2013 05:20:21 -0000 To: commits@subversion.apache.org From: brane@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130801052021.8BA0A23888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: brane Date: Thu Aug 1 05:20:21 2013 New Revision: 1509080 URL: http://svn.apache.org/r1509080 Log: Begin extending spillbufs so that we can use them for compressed pristines. * subversion/libsvn_subr/spillbuf.c (svn_spillbuf_t): Add new fields delete_on_close, spill_all_contents, dirpath and temp_path. (init_spillbuf_extended): New. Initializes a spillbuf. (init_spillbuf): New. Initializes a spillbuf, defaulting the new fields. (svn_spillbuf__create): Use init_spillbuf. (svn_spillbuf__reader_create): Likewise; do away with the cut-and-paste initialization silliness. (svn_spillbuf__write): Use the new svn_spillbuf_t fields when creating the temporary spill file. Modified: subversion/trunk/subversion/libsvn_subr/spillbuf.c Modified: subversion/trunk/subversion/libsvn_subr/spillbuf.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/spillbuf.c?rev=1509080&r1=1509079&r2=1509080&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_subr/spillbuf.c (original) +++ subversion/trunk/subversion/libsvn_subr/spillbuf.c Thu Aug 1 05:20:21 2013 @@ -73,6 +73,20 @@ struct svn_spillbuf_t { /* How much content remains in SPILL. */ svn_filesize_t spill_size; + + /* When false, do not delete the spill file when it is closed. */ + svn_boolean_t delete_on_close; + + /* When true, the spill file will contain all the data written to + the spillbuf, including those that would normally be held only in + memory. */ + svn_boolean_t spill_all_contents; + + /* The directory in which the spill file is created. */ + const char *dirpath; + + /* The name of the temporary spill file. */ + const char *temp_path; }; @@ -99,18 +113,46 @@ struct svn_spillbuf_reader_t { }; +/* Extended spillbuf initialization. */ +static void +init_spillbuf_extended(svn_spillbuf_t *buf, + apr_size_t blocksize, + apr_size_t maxsize, + svn_boolean_t delete_on_close, + svn_boolean_t spill_all_contents, + const char* dirpath, + const char* temp_path, + apr_pool_t *result_pool) +{ + buf->pool = result_pool; + buf->blocksize = blocksize; + buf->maxsize = maxsize; + buf->delete_on_close = delete_on_close; + buf->spill_all_contents = spill_all_contents; + buf->dirpath = dirpath; + buf->temp_path = temp_path; +} + +/* Common constructor for initializing spillbufs. + Used by svn_spillbuf__create, svn_spilbuff__reader_create. */ +static void +init_spillbuf(svn_spillbuf_t *buf, + apr_size_t blocksize, + apr_size_t maxsize, + apr_pool_t *result_pool) +{ + init_spillbuf_extended(buf, blocksize, maxsize, + TRUE, FALSE, NULL, NULL, + result_pool); +} + svn_spillbuf_t * svn_spillbuf__create(apr_size_t blocksize, apr_size_t maxsize, apr_pool_t *result_pool) { svn_spillbuf_t *buf = apr_pcalloc(result_pool, sizeof(*buf)); - - buf->pool = result_pool; - buf->blocksize = blocksize; - buf->maxsize = maxsize; - /* Note: changes here should also go into svn_spillbuf__reader_create() */ - + init_spillbuf(buf, blocksize, maxsize, result_pool); return buf; } @@ -173,9 +215,11 @@ svn_spillbuf__write(svn_spillbuf_t *buf, && (buf->memory_size + len) > buf->maxsize) { SVN_ERR(svn_io_open_unique_file3(&buf->spill, - NULL /* temp_path */, - NULL /* dirpath */, - svn_io_file_del_on_close, + &buf->temp_path, + buf->dirpath, + (buf->delete_on_close + ? svn_io_file_del_on_close + : svn_io_file_del_none), buf->pool, scratch_pool)); } @@ -440,12 +484,7 @@ svn_spillbuf__reader_create(apr_size_t b apr_pool_t *result_pool) { svn_spillbuf_reader_t *sbr = apr_pcalloc(result_pool, sizeof(*sbr)); - - /* See svn_spillbuf__create() */ - sbr->buf.pool = result_pool; - sbr->buf.blocksize = blocksize; - sbr->buf.maxsize = maxsize; - + init_spillbuf(&sbr->buf, blocksize, maxsize, result_pool); return sbr; }