You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2014/05/24 00:33:53 UTC

svn commit: r1597203 - /subversion/trunk/subversion/libsvn_fs_x/transaction.c

Author: stefan2
Date: Fri May 23 22:33:53 2014
New Revision: 1597203

URL: http://svn.apache.org/r1597203
Log:
Some FSX code cleanup and stream handling fixes.

The stream handling issue lies in the difference between the delta
stream being created and the raw output stream. We checksum the input
into the delta stream and close it once the delta is complete. After
that, we add the "ENDREP" sequence to the raw stream.  This did not
surface as an error before since writing to a closed file stream is
not being prevented.

* subversion/libsvn_fs_x/transaction.c
  (rep_write_contents): Get rid of FSFS remnants as we always write
                        deltififed data.
  (rep_write_get_baton): Don't close the output stream automatically
                         because we need to add the footer after the
                         plaintext has already been fully deltified.
  (rep_write_contents_close): Again, we always deltify in FSX.  Also,
                       we now need to close the raw stream explicitly.
  (write_container_delta_rep): Close the raw rep stream explicitly.
  (write_final_changed_path_info): Update function docstring.

Modified:
    subversion/trunk/subversion/libsvn_fs_x/transaction.c

Modified: subversion/trunk/subversion/libsvn_fs_x/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/transaction.c?rev=1597203&r1=1597202&r2=1597203&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/transaction.c Fri May 23 22:33:53 2014
@@ -1917,11 +1917,7 @@ rep_write_contents(void *baton,
   SVN_ERR(svn_checksum_update(b->sha1_checksum_ctx, data, *len));
   b->rep_size += *len;
 
-  /* If we are writing a delta, use that stream. */
-  if (b->delta_stream)
-    return svn_stream_write(b->delta_stream, data, len);
-  else
-    return svn_stream_write(b->rep_stream, data, len);
+  return svn_stream_write(b->delta_stream, data, len);
 }
 
 /* Set *SPANNED to the number of shards touched when walking WALK steps on
@@ -2103,7 +2099,6 @@ rep_write_cleanup(void *data)
   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
@@ -2172,7 +2167,7 @@ rep_write_get_baton(struct rep_write_bat
   /* Prepare to write the svndiff data. */
   svn_txdelta_to_svndiff3(&wh,
                           &whb,
-                          b->rep_stream,
+                          svn_stream_disown(b->rep_stream, b->pool),
                           diff_version,
                           SVN_DELTA_COMPRESSION_LEVEL_DEFAULT,
                           pool);
@@ -2323,8 +2318,7 @@ rep_write_contents_close(void *baton)
 
   /* Close our delta stream so the last bits of svndiff are written
      out. */
-  if (b->delta_stream)
-    SVN_ERR(svn_stream_close(b->delta_stream));
+  SVN_ERR(svn_stream_close(b->delta_stream));
 
   /* Determine the length of the svndiff data. */
   SVN_ERR(svn_fs_x__get_file_offset(&offset, b->file, b->pool));
@@ -2362,6 +2356,8 @@ rep_write_contents_close(void *baton)
       b->noderev->data_rep = rep;
     }
 
+  SVN_ERR(svn_stream_close(b->rep_stream));
+
   /* Remove cleanup callback. */
   apr_pool_cleanup_kill(b->pool, b, rep_write_cleanup);
 
@@ -2637,7 +2633,7 @@ write_container_delta_rep(representation
   /* Prepare to write the svndiff data. */
   svn_txdelta_to_svndiff3(&diff_wh,
                           &diff_whb,
-                          file_stream,
+                          svn_stream_disown(file_stream, pool),
                           diff_version,
                           SVN_DELTA_COMPRESSION_LEVEL_DEFAULT,
                           pool);
@@ -2664,6 +2660,8 @@ write_container_delta_rep(representation
 
   if (old_rep)
     {
+      SVN_ERR(svn_stream_close(file_stream));
+
       /* We need to erase from the protorev the data we just wrote. */
       SVN_ERR(svn_io_file_trunc(file, offset, pool));
 
@@ -2678,6 +2676,7 @@ write_container_delta_rep(representation
       /* Write out our cosmetic end marker. */
       SVN_ERR(svn_fs_x__get_file_offset(&rep_end, file, pool));
       SVN_ERR(svn_stream_puts(file_stream, "ENDREP\n"));
+      SVN_ERR(svn_stream_close(file_stream));
 
       SVN_ERR(allocate_item_index(&rep->id.number, fs, txn_id, pool));
       SVN_ERR(store_l2p_index_entry(fs, txn_id, offset, rep->id.number, pool));
@@ -2981,9 +2980,10 @@ write_final_rev(const svn_fs_id_t **new_
   return SVN_NO_ERROR;
 }
 
-/* Write the changed path info CHANGED_PATHS of transaction TXN_ID to the
+/* Write the changed path info CHANGED_PATHS from transaction TXN_ID to the
    permanent rev-file FILE representing NEW_REV in filesystem FS.  *OFFSET_P
    is set the to offset in the file of the beginning of this information.
+   NEW_REV is the revision currently being committed.
    Perform temporary allocations in POOL. */
 static svn_error_t *
 write_final_changed_path_info(apr_off_t *offset_p,