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 2015/03/02 12:48:42 UTC

svn commit: r1663272 - /subversion/branches/ra-svn-tuning/subversion/libsvn_ra_svn/editorp.c

Author: stefan2
Date: Mon Mar  2 11:48:41 2015
New Revision: 1663272

URL: http://svn.apache.org/r1663272
Log:
On the ra-svn-tuning branch:
Prevent ra_svn editor token counter from overflowing.

Because a repository usually contains vastly more paths than nodes,
extremely large reports with in excess of 2^31 nodes are at least
conceivable.  Assuming the integer overflow does not lead to undefined
behavior, we will reuse tokens after 2^32 nodes.  Since the root node
will probably remain open for the whole editor drive, those tokens
would actually clash on the receiver side.

* subversion/libsvn_ra_svn/editorp.c
  (ra_svn_edit_baton_t): A 64 bit counter should last for a million
                         years or so.
  (make_token): Update string token constructor.

Modified:
    subversion/branches/ra-svn-tuning/subversion/libsvn_ra_svn/editorp.c

Modified: subversion/branches/ra-svn-tuning/subversion/libsvn_ra_svn/editorp.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-svn-tuning/subversion/libsvn_ra_svn/editorp.c?rev=1663272&r1=1663271&r2=1663272&view=diff
==============================================================================
--- subversion/branches/ra-svn-tuning/subversion/libsvn_ra_svn/editorp.c (original)
+++ subversion/branches/ra-svn-tuning/subversion/libsvn_ra_svn/editorp.c Mon Mar  2 11:48:41 2015
@@ -42,6 +42,7 @@
 #include "private/svn_atomic.h"
 #include "private/svn_fspath.h"
 #include "private/svn_editor.h"
+#include "private/svn_string_private.h"
 #include "private/svn_subr_private.h"
 
 #include "ra_svn.h"
@@ -59,7 +60,7 @@ typedef struct ra_svn_edit_baton_t {
   svn_ra_svn_conn_t *conn;
   svn_ra_svn_edit_callback callback;    /* Called on successful completion. */
   void *callback_baton;
-  int next_token;
+  apr_uint64_t next_token;
   svn_boolean_t got_status;
 } ra_svn_edit_baton_t;
 
@@ -108,10 +109,17 @@ struct ra_svn_token_entry_t {
 
 /* --- CONSUMING AN EDITOR BY PASSING EDIT OPERATIONS OVER THE NET --- */
 
-static const char *make_token(char type, ra_svn_edit_baton_t *eb,
-                              apr_pool_t *pool)
+static const char *
+make_token(char type,
+           ra_svn_edit_baton_t *eb,
+           apr_pool_t *pool)
 {
-  return apr_psprintf(pool, "%c%d", type, eb->next_token++);
+  apr_size_t len;
+  char buffer[1 + SVN_INT64_BUFFER_SIZE];
+  buffer[0] = type;
+  len = 1 + svn__ui64toa(&buffer[1], eb->next_token++);
+  
+  return apr_pstrmemdup(pool, buffer, len);
 }
 
 static ra_svn_baton_t *ra_svn_make_baton(svn_ra_svn_conn_t *conn,