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/09/17 09:45:49 UTC

svn commit: r998012 - in /subversion/branches/performance/subversion: include/svn_io.h libsvn_diff/diff_file.c libsvn_fs_fs/fs_fs.c libsvn_repos/reporter.c libsvn_subr/deprecated.c libsvn_subr/hash.c libsvn_subr/io.c libsvn_subr/stream.c

Author: stefan2
Date: Fri Sep 17 07:45:49 2010
New Revision: 998012

URL: http://svn.apache.org/viewvc?rev=998012&view=rev
Log:
Change the svn_io_file_read_full2 API to accept an [out] boolean eof_hit
parameter instead of an [in] boolean eof_hit_ok parameter. That way,
the caller will always be informed of the EOF - either by the boolean being
set or by error return value.

* subversion/include/svn_io.h
  (svn_io_file_read_full2): replace eof_is_ok with hit_eof parameter
* subversion/libsvn_subr/io.c
  (svn_io_file_read_full2): adapt implementation to new API signature
  (contents_identical_p): use new API instead of the deprecated one

* subversion/libsvn_subr/deprecated.c
  (svn_io_file_read_full): adapt to API change
* subversion/libsvn_subr/hash.c
  (svn_hash_read): dito
* subversion/libsvn_subr/stream.c
  (read_handler_apr): dito
* subversion/libsvn_repos/reporter.c
  (read_string): dito
* subversion/libsvn_fs_fs/fs_fs.c
  (create_rep_state_body, get_contents, read_handler_recover): dito
* subversion/libsvn_diff/diff_file.c
  (read_chunk, map_or_read_file): dito

Modified:
    subversion/branches/performance/subversion/include/svn_io.h
    subversion/branches/performance/subversion/libsvn_diff/diff_file.c
    subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.c
    subversion/branches/performance/subversion/libsvn_repos/reporter.c
    subversion/branches/performance/subversion/libsvn_subr/deprecated.c
    subversion/branches/performance/subversion/libsvn_subr/hash.c
    subversion/branches/performance/subversion/libsvn_subr/io.c
    subversion/branches/performance/subversion/libsvn_subr/stream.c

Modified: subversion/branches/performance/subversion/include/svn_io.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/include/svn_io.h?rev=998012&r1=998011&r2=998012&view=diff
==============================================================================
--- subversion/branches/performance/subversion/include/svn_io.h (original)
+++ subversion/branches/performance/subversion/include/svn_io.h Fri Sep 17 07:45:49 2010
@@ -1830,8 +1830,9 @@ svn_io_file_read(apr_file_t *file,
 
 /** Wrapper for apr_file_read_full().
  *
- * If @a eof_is_ok is set, no svn_error_t error object
- * will be created upon EOF.
+ * If @a hit_eof is not NULL, EOF will be indicated there and no
+ * svn_error_t error object will be created upon EOF.
+ *
  * @since New in 1.7
  */
 svn_error_t *
@@ -1839,12 +1840,12 @@ svn_io_file_read_full2(apr_file_t *file,
                         void *buf,
                         apr_size_t nbytes,
                         apr_size_t *bytes_read,
-                        svn_boolean_t eof_is_ok,
+                        svn_boolean_t *hit_eof,
                         apr_pool_t *pool);
 
 
-/** Similar to svn_io_file_read_full2 with eof_is_ok being set
- * to @c FALSE.
+/** Similar to svn_io_file_read_full2 with hit_eof being set
+ * to @c NULL.
  *
  * @deprecated Provided for backward compatibility with the 1.6 API
  */

Modified: subversion/branches/performance/subversion/libsvn_diff/diff_file.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_diff/diff_file.c?rev=998012&r1=998011&r2=998012&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_diff/diff_file.c (original)
+++ subversion/branches/performance/subversion/libsvn_diff/diff_file.c Fri Sep 17 07:45:49 2010
@@ -131,7 +131,7 @@ read_chunk(apr_file_t *file, const char 
    */
   SVN_ERR(svn_io_file_seek(file, APR_SET, &offset, pool));
   return svn_io_file_read_full2(file, buffer, (apr_size_t) length,
-                                NULL, FALSE, pool);
+                                NULL, NULL, pool);
 }
 
 
@@ -183,7 +183,7 @@ map_or_read_file(apr_file_t **file,
       *buffer = apr_palloc(pool, (apr_size_t) finfo.size);
 
       SVN_ERR(svn_io_file_read_full2(*file, *buffer, (apr_size_t) finfo.size,
-                                     NULL, FALSE, pool));
+                                     NULL, NULL, pool));
 
       /* Since we have the entire contents of the file we can
        * close it now.

Modified: subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.c?rev=998012&r1=998011&r2=998012&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.c Fri Sep 17 07:45:49 2010
@@ -3161,7 +3161,7 @@ create_rep_state_body(struct rep_state *
 
   /* We are dealing with a delta, find out what version. */
   SVN_ERR(svn_io_file_read_full2(rs->apr_file, buf, sizeof(buf),
-                                 NULL, FALSE, pool));
+                                 NULL, NULL, pool));
   if (! ((buf[0] == 'S') && (buf[1] == 'V') && (buf[2] == 'N')))
     return svn_error_create
       (SVN_ERR_FS_CORRUPT, NULL,
@@ -3606,7 +3606,7 @@ get_contents(struct rep_read_baton *rb,
       if (((apr_off_t) copy_len) > rs->end - rs->off)
         copy_len = (apr_size_t) (rs->end - rs->off);
       SVN_ERR(svn_io_file_read_full2(rs->apr_file, cur, copy_len, NULL,
-                                     FALSE, rb->pool));
+                                     NULL, rb->pool));
       rs->off += copy_len;
       *len = copy_len;
       return SVN_NO_ERROR;
@@ -3683,7 +3683,7 @@ get_contents(struct rep_read_baton *rb,
                     }
                   SVN_ERR(svn_io_file_read_full2(rs->apr_file, sbuf,
                                                  lwindow->sview_len,
-                                                 NULL, FALSE, rb->pool));
+                                                 NULL, NULL, rb->pool));
                   rs->off += lwindow->sview_len;
                 }
               else
@@ -6992,7 +6992,7 @@ read_handler_recover(void *baton, char *
   b->remaining -= bytes_to_read;
 
   return svn_io_file_read_full2(b->file, buffer, (apr_size_t) bytes_to_read,
-                                len, FALSE, b->pool);
+                                len, NULL, b->pool);
 }
 
 /* Part of the recovery procedure.  Read the directory noderev at offset

Modified: subversion/branches/performance/subversion/libsvn_repos/reporter.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_repos/reporter.c?rev=998012&r1=998011&r2=998012&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_repos/reporter.c (original)
+++ subversion/branches/performance/subversion/libsvn_repos/reporter.c Fri Sep 17 07:45:49 2010
@@ -200,7 +200,7 @@ read_string(const char **str, apr_file_t
 
   size = (apr_size_t)len;
   buf = apr_palloc(pool, size+1);
-  SVN_ERR(svn_io_file_read_full2(temp, buf, size, NULL, FALSE, pool));
+  SVN_ERR(svn_io_file_read_full2(temp, buf, size, NULL, NULL, pool));
   buf[len] = 0;
   *str = buf;
   return SVN_NO_ERROR;

Modified: subversion/branches/performance/subversion/libsvn_subr/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_subr/deprecated.c?rev=998012&r1=998011&r2=998012&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_subr/deprecated.c (original)
+++ subversion/branches/performance/subversion/libsvn_subr/deprecated.c Fri Sep 17 07:45:49 2010
@@ -793,7 +793,7 @@ svn_io_file_read_full(apr_file_t *file, 
                       apr_size_t nbytes, apr_size_t *bytes_read,
                       apr_pool_t *pool)
 {
-  return svn_io_file_read_full2(file, buf, nbytes, bytes_read, FALSE, pool);
+  return svn_io_file_read_full2(file, buf, nbytes, bytes_read, NULL, pool);
 }
 
 /*** From constructors.c ***/

Modified: subversion/branches/performance/subversion/libsvn_subr/hash.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_subr/hash.c?rev=998012&r1=998011&r2=998012&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_subr/hash.c (original)
+++ subversion/branches/performance/subversion/libsvn_subr/hash.c Fri Sep 17 07:45:49 2010
@@ -347,7 +347,7 @@ svn_hash_read(apr_hash_t *hash,
           size_t keylen;
           int parsed_len;
           void *keybuf;
-          
+
           /* Get the length of the key */
           SVN_ERR(svn_cstring_atoi(&parsed_len, buf + 2));
           keylen = parsed_len;
@@ -356,7 +356,7 @@ svn_hash_read(apr_hash_t *hash,
           keybuf = apr_palloc(pool, keylen + 1);
           SVN_ERR(svn_io_file_read_full2(srcfile,
                                          keybuf, keylen,
-                                         &num_read, FALSE, pool));
+                                         &num_read, NULL, pool));
           ((char *) keybuf)[keylen] = '\0';
 
           /* Suck up extra newline after key data */
@@ -382,7 +382,7 @@ svn_hash_read(apr_hash_t *hash,
               valbuf = apr_palloc(pool, vallen + 1);
               SVN_ERR(svn_io_file_read_full2(srcfile,
                                              valbuf, vallen,
-                                             &num_read, FALSE, pool));
+                                             &num_read, NULL, pool));
               ((char *) valbuf)[vallen] = '\0';
 
               /* Suck up extra newline after val data */

Modified: subversion/branches/performance/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_subr/io.c?rev=998012&r1=998011&r2=998012&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/performance/subversion/libsvn_subr/io.c Fri Sep 17 07:45:49 2010
@@ -2875,12 +2875,18 @@ svn_io_file_read(apr_file_t *file, void 
 svn_error_t *
 svn_io_file_read_full2(apr_file_t *file, void *buf,
                         apr_size_t nbytes, apr_size_t *bytes_read,
-                        svn_boolean_t eof_is_ok,
+                        svn_boolean_t *hit_eof,
                         apr_pool_t *pool)
 {
   apr_status_t status = apr_file_read_full(file, buf, nbytes, bytes_read);
-  if (APR_STATUS_IS_EOF(status) && eof_is_ok)
-    return SVN_NO_ERROR;
+  if (hit_eof)
+    if (APR_STATUS_IS_EOF(status))
+      {
+        *hit_eof = TRUE;
+        return SVN_NO_ERROR;
+      }
+    else
+      *hit_eof = FALSE;
 
   return do_io_file_wrapper_cleanup
     (file, status,
@@ -3590,8 +3596,8 @@ contents_identical_p(svn_boolean_t *iden
   char *buf2 = apr_palloc(pool, SVN__STREAM_CHUNK_SIZE);
   apr_file_t *file1_h = NULL;
   apr_file_t *file2_h = NULL;
-  svn_boolean_t done1 = FALSE;
-  svn_boolean_t done2 = FALSE;
+  svn_boolean_t eof1 = FALSE;
+  svn_boolean_t eof2 = FALSE;
 
   SVN_ERR(svn_io_file_open(&file1_h, file1, APR_READ, APR_OS_DEFAULT,
                            pool));
@@ -3605,33 +3611,21 @@ contents_identical_p(svn_boolean_t *iden
                                         svn_io_file_close(file1_h, pool)));
 
   *identical_p = TRUE;  /* assume TRUE, until disproved below */
-  while (! (done1 || done2))
+  while (!err && !eof1 && !eof2)
     {
-      err = svn_io_file_read_full(file1_h, buf1,
-                                  SVN__STREAM_CHUNK_SIZE, &bytes_read1, pool);
-      if (err && APR_STATUS_IS_EOF(err->apr_err))
-        {
-          svn_error_clear(err);
-          err = NULL;
-          done1 = TRUE;
-        }
-      else if (err)
-        break;
+      err = svn_io_file_read_full2(file1_h, buf1,
+                                   SVN__STREAM_CHUNK_SIZE, &bytes_read1,
+                                   &eof1, pool);
+      if (err)
+          break;
 
-      err = svn_io_file_read_full(file2_h, buf2,
-                                  SVN__STREAM_CHUNK_SIZE, &bytes_read2, pool);
-      if (err && APR_STATUS_IS_EOF(err->apr_err))
-        {
-          svn_error_clear(err);
-          err = NULL;
-          done2 = TRUE;
-        }
-      else if (err)
-        break;
+      err = svn_io_file_read_full2(file2_h, buf2,
+                                   SVN__STREAM_CHUNK_SIZE, &bytes_read2,
+                                   &eof2, pool);
+      if (err)
+          break;
 
-      if ((bytes_read1 != bytes_read2)
-          || (done1 != done2)
-          || (memcmp(buf1, buf2, bytes_read1)))
+      if ((bytes_read1 != bytes_read2) || memcmp(buf1, buf2, bytes_read1))
         {
           *identical_p = FALSE;
           break;

Modified: subversion/branches/performance/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_subr/stream.c?rev=998012&r1=998011&r2=998012&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_subr/stream.c (original)
+++ subversion/branches/performance/subversion/libsvn_subr/stream.c Fri Sep 17 07:45:49 2010
@@ -832,6 +832,7 @@ read_handler_apr(void *baton, char *buff
 {
   struct baton_apr *btn = baton;
   svn_error_t *err;
+  svn_boolean_t eof;
 
   if (*len == 1)
     {
@@ -847,8 +848,8 @@ read_handler_apr(void *baton, char *buff
         }
     }
   else
-    err = svn_io_file_read_full2(btn->file, buffer, *len, len, 
-                                 TRUE, btn->pool);
+    err = svn_io_file_read_full2(btn->file, buffer, *len, len,
+                                 &eof, btn->pool);
 
   return err;
 }