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 2010/01/04 03:11:02 UTC

svn commit: r895534 - in /subversion/trunk/subversion: include/svn_error_codes.h include/svn_io.h libsvn_subr/stream.c

Author: stsp
Date: Mon Jan  4 02:11:01 2010
New Revision: 895534

URL: http://svn.apache.org/viewvc?rev=895534&view=rev
Log:
Follow-up to r895469:
Make sure a mark set on a stream isn't overwritten. A mark has to be
cleared before another mark can be set. We might want to extend this
API later so that streams may support multiple marks at once, but for
current purposes raising an error is good enough.

* subversion/include/svn_error_codes.h
  (SVN_ERR_STREAM_MARK_ALREADY_SET): New error code.

* subversion/include/svn_io.h
  (svn_stream_mark): Document when SVN_ERR_STREAM_MARK_ALREADY_SET is raised.

* subversion/libsvn_subr/stream.c
  (mark_handler_apr, mark_handler_stringbuf): Prevent an existing mark from
   being overwritten by raising SVN_ERR_STREAM_MARK_ALREADY_SET.

Modified:
    subversion/trunk/subversion/include/svn_error_codes.h
    subversion/trunk/subversion/include/svn_io.h
    subversion/trunk/subversion/libsvn_subr/stream.c

Modified: subversion/trunk/subversion/include/svn_error_codes.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_error_codes.h?rev=895534&r1=895533&r2=895534&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_error_codes.h (original)
+++ subversion/trunk/subversion/include/svn_error_codes.h Mon Jan  4 02:11:01 2010
@@ -298,6 +298,11 @@
              SVN_ERR_STREAM_CATEGORY_START + 4,
              "Stream doesn't support marking")
 
+  /** @since New in 1.7. */
+  SVN_ERRDEF(SVN_ERR_STREAM_MARK_ALREADY_SET,
+             SVN_ERR_STREAM_CATEGORY_START + 5,
+             "Mark is already set on this stream")
+
   /* node errors */
 
   SVN_ERRDEF(SVN_ERR_NODE_UNKNOWN_KIND,

Modified: subversion/trunk/subversion/include/svn_io.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_io.h?rev=895534&r1=895533&r2=895534&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_io.h (original)
+++ subversion/trunk/subversion/include/svn_io.h Mon Jan  4 02:11:01 2010
@@ -1059,6 +1059,8 @@
  * the stream. If @a set is FALSE, the mark is cleared.
  * This function returns the #SVN_ERR_STREAM_MARK_NOT_SUPPORTED error
  * when the stream doesn't implement marking.
+ * The error #SVN_ERR_STREAM_MARK_ALREADY_SET is returned if there was
+ * an attempt to set a mark without clearing an existing mark beforehand.
  *
  * @see svn_stream_reset()
  * @since New in 1.7.

Modified: subversion/trunk/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/stream.c?rev=895534&r1=895533&r2=895534&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/stream.c (original)
+++ subversion/trunk/subversion/libsvn_subr/stream.c Mon Jan  4 02:11:01 2010
@@ -716,6 +716,8 @@
 
   if (set)
     {
+      if (btn->mark != -1)
+        return svn_error_create(SVN_ERR_STREAM_MARK_ALREADY_SET, NULL, NULL);
       btn->mark = 0;
       SVN_ERR(svn_io_file_seek(btn->file, APR_CUR, &btn->mark, btn->pool));
     }
@@ -1382,7 +1384,11 @@
 {
   struct stringbuf_stream_baton *btn = baton;
   if (set)
-    btn->mark = btn->amt_read;
+    {
+      if (btn->mark != (apr_size_t)-1)
+        return svn_error_create(SVN_ERR_STREAM_MARK_ALREADY_SET, NULL, NULL);
+      btn->mark = btn->amt_read;
+    }
   else
     btn->mark = (apr_size_t)-1;
   return SVN_NO_ERROR;