You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2012/11/01 20:54:35 UTC
svn commit: r1404735 - in /subversion/branches/1.6.x-rep_write_cleanup: ./
subversion/libsvn_fs_fs/fs_fs.c
Author: breser
Date: Thu Nov 1 19:54:34 2012
New Revision: 1404735
URL: http://svn.apache.org/viewvc?rev=1404735&view=rev
Log:
On the 1.6.x-rep_write_cleanup branch, merge r1403964 & r1403982 from trunk.
No conflicts, clean merge.
Modified:
subversion/branches/1.6.x-rep_write_cleanup/ (props changed)
subversion/branches/1.6.x-rep_write_cleanup/subversion/libsvn_fs_fs/fs_fs.c
Propchange: subversion/branches/1.6.x-rep_write_cleanup/
------------------------------------------------------------------------------
Merged /subversion/trunk:r1403964,1403982
Modified: subversion/branches/1.6.x-rep_write_cleanup/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.6.x-rep_write_cleanup/subversion/libsvn_fs_fs/fs_fs.c?rev=1404735&r1=1404734&r2=1404735&view=diff
==============================================================================
--- subversion/branches/1.6.x-rep_write_cleanup/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/1.6.x-rep_write_cleanup/subversion/libsvn_fs_fs/fs_fs.c Thu Nov 1 19:54:34 2012
@@ -4995,6 +4995,46 @@ choose_delta_base(representation_t **rep
return SVN_NO_ERROR;
}
+/* Something went wrong and the pool for the rep write is being
+ cleared before we've finished writing the rep. So we need
+ to remove the rep from the protorevfile and we need to unlock
+ the protorevfile. */
+static apr_status_t
+rep_write_cleanup(void *data)
+{
+ struct rep_write_baton *b = data;
+ const char *txn_id = svn_fs_fs__id_txn_id(b->noderev->id);
+ svn_error_t *err;
+
+ /* Truncate and close the protorevfile. */
+ err = svn_io_file_trunc(b->file, b->rep_offset, b->pool);
+ if (err)
+ {
+ apr_status_t rc = err->apr_err;
+ svn_error_clear(err);
+ return rc;
+ }
+ err = svn_io_file_close(b->file, b->pool);
+ if (err)
+ {
+ apr_status_t rc = err->apr_err;
+ svn_error_clear(err);
+ return rc;
+ }
+
+ /* Remove our lock */
+ err = unlock_proto_rev(b->fs, txn_id, b->lockcookie, b->pool);
+ if (err)
+ {
+ apr_status_t rc = err->apr_err;
+ svn_error_clear(err);
+ return rc;
+ }
+
+ return APR_SUCCESS;
+}
+
+
/* Get a rep_write_baton and store it in *WB_P for the representation
indicated by NODEREV in filesystem FS. Perform allocations in
POOL. Only appropriate for file contents, not for props or
@@ -5057,6 +5097,10 @@ rep_write_get_baton(struct rep_write_bat
/* Now determine the offset of the actual svndiff data. */
SVN_ERR(get_file_offset(&b->delta_start, file, b->pool));
+ /* Cleanup in case something goes wrong. */
+ apr_pool_cleanup_register(b->pool, b, rep_write_cleanup,
+ apr_pool_cleanup_null);
+
/* Prepare to write the svndiff data. */
if (ffd->format >= SVN_FS_FS__MIN_SVNDIFF1_FORMAT)
svn_txdelta_to_svndiff2(&wh, &whb, b->rep_stream, 1, pool);
@@ -5136,6 +5180,9 @@ rep_write_contents_close(void *baton)
b->noderev->data_rep = rep;
}
+ /* Remove cleanup callback. */
+ apr_pool_cleanup_kill(b->pool, b, rep_write_cleanup);
+
/* Write out the new node-rev information. */
SVN_ERR(svn_fs_fs__put_node_revision(b->fs, b->noderev->id, b->noderev, FALSE,
b->pool));