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 2011/02/19 11:23:58 UTC
svn commit: r1072299 - in /subversion/trunk: ./ subversion/include/
subversion/libsvn_diff/ subversion/libsvn_fs_fs/ subversion/libsvn_repos/
subversion/libsvn_subr/
Author: stefan2
Date: Sat Feb 19 10:23:57 2011
New Revision: 1072299
URL: http://svn.apache.org/viewvc?rev=1072299&view=rev
Log:
Merge all changes (r1068684, r1072297) from the
integrate-io-improvements branch.
These patches reduce the calling overhead in various I/O-related functions.
Modified:
subversion/trunk/ (props changed)
subversion/trunk/subversion/include/svn_io.h
subversion/trunk/subversion/libsvn_diff/diff_file.c
subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
subversion/trunk/subversion/libsvn_repos/reporter.c
subversion/trunk/subversion/libsvn_subr/deprecated.c
subversion/trunk/subversion/libsvn_subr/hash.c
subversion/trunk/subversion/libsvn_subr/io.c
subversion/trunk/subversion/libsvn_subr/stream.c
Propchange: subversion/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Feb 19 10:23:57 2011
@@ -15,6 +15,7 @@
/subversion/branches/in-memory-cache:869829-871452
/subversion/branches/integrate-cache-membuffer:998649-998852
/subversion/branches/integrate-compression-level:1068651-1072287
+/subversion/branches/integrate-io-improvements:1068684-1072297
/subversion/branches/issue-2779-dev:965496-984198
/subversion/branches/issue-2843-dev:871432-874179
/subversion/branches/issue-3000:871713,871716-871719,871721-871726,871728,871734
@@ -28,7 +29,7 @@
/subversion/branches/log-g-performance:870941-871032
/subversion/branches/merge-skips-obstructions:874525-874615
/subversion/branches/nfc-nfd-aware-client:870276,870376
-/subversion/branches/performance:979193,980118,981087,981287,981684,981827,982043,982355,983764,983766,984927,984973,984984,985014,985037,985046,985472,985477,985482,985500,985606,985669,986453,987888,987893,988319,990541,990568,990572,990600,990759,992899,992911,993127,993141,994956,995478,995507,995603,998858,999098,1001413,1001417,1004291,1022668,1022670,1022676,1022715,1022719,1025660,1025672,1027193,1027203,1027206,1027214,1027227,1028077,1028092,1028094,1028104,1028107,1028111,1028354,1029038,1029042-1029043,1029078,1029080,1029090,1029092-1029093,1029111,1029151,1029158,1029232,1029335,1029339-1029340,1029342,1029344,1030763,1030827,1031203,1031235,1032285,1032333,1033040,1033057,1033294,1035869,1039511,1043705,1053735,1056015,1066452,1067683
+/subversion/branches/performance:979193,980118,981087,981287,981684,981827,982043,982355,983764,983766,984927,984973,984984,985014,985037,985046,985472,985477,985482,985487-985488,985493,985497,985500,985606,985669,986453,986465,986491,986517,987888,987893,988319,990541,990568,990572,990600,990759,992899,992911,993127,993141,994956,995478,995507,995603,998012,998858,999098,1001413,1001417,1004291,1022668,1022670,1022676,1022715,1022719,1025660,1025672,1027193,1027203,1027206,1027214,1027227,1028077,1028092,1028094,1028104,1028107,1028111,1028354,1029038,1029042-1029043,1029062,1029078,1029080,1029090,1029092-1029093,1029111,1029151,1029158,1029232,1029335,1029339-1029340,1029342,1029344,1030763,1030827,1031203,1031235,1032285,1032333,1033040,1033057,1033294,1035869,1039511,1043705,1053735,1056015,1066452,1067683
/subversion/branches/py-tests-as-modules:956579-1033052
/subversion/branches/ra_serf-digest-authn:875693-876404
/subversion/branches/reintegrate-improvements:873853-874164
Modified: subversion/trunk/subversion/include/svn_io.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_io.h?rev=1072299&r1=1072298&r2=1072299&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_io.h (original)
+++ subversion/trunk/subversion/include/svn_io.h Sat Feb 19 10:23:57 2011
@@ -1770,6 +1770,15 @@ svn_io_file_getc(char *ch,
apr_pool_t *pool);
+/** Wrapper for apr_file_putc().
+ * @since New in 1.7
+ */
+svn_error_t *
+svn_io_file_putc(char ch,
+ apr_file_t *file,
+ apr_pool_t *pool);
+
+
/** Wrapper for apr_file_info_get(). */
svn_error_t *
svn_io_file_info_get(apr_finfo_t *finfo,
@@ -1786,7 +1795,28 @@ svn_io_file_read(apr_file_t *file,
apr_pool_t *pool);
-/** Wrapper for apr_file_read_full(). */
+/** Wrapper for apr_file_read_full().
+ *
+ * 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 *
+svn_io_file_read_full2(apr_file_t *file,
+ void *buf,
+ apr_size_t nbytes,
+ apr_size_t *bytes_read,
+ svn_boolean_t *hit_eof,
+ apr_pool_t *pool);
+
+
+/** 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
+ */
+SVN_DEPRECATED
svn_error_t *
svn_io_file_read_full(apr_file_t *file,
void *buf,
Modified: subversion/trunk/subversion/libsvn_diff/diff_file.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/diff_file.c?rev=1072299&r1=1072298&r2=1072299&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/diff_file.c (original)
+++ subversion/trunk/subversion/libsvn_diff/diff_file.c Sat Feb 19 10:23:57 2011
@@ -140,7 +140,8 @@ read_chunk(apr_file_t *file, const char
* XXX: Check.
*/
SVN_ERR(svn_io_file_seek(file, APR_SET, &offset, pool));
- return svn_io_file_read_full(file, buffer, (apr_size_t) length, NULL, pool);
+ return svn_io_file_read_full2(file, buffer, (apr_size_t) length,
+ NULL, NULL, pool);
}
@@ -191,8 +192,8 @@ map_or_read_file(apr_file_t **file,
{
*buffer = apr_palloc(pool, (apr_size_t) finfo.size);
- SVN_ERR(svn_io_file_read_full(*file, *buffer, (apr_size_t) finfo.size,
- NULL, pool));
+ SVN_ERR(svn_io_file_read_full2(*file, *buffer, (apr_size_t) finfo.size,
+ NULL, NULL, pool));
/* Since we have the entire contents of the file we can
* close it now.
Modified: subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c?rev=1072299&r1=1072298&r2=1072299&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c Sat Feb 19 10:23:57 2011
@@ -3049,7 +3049,8 @@ create_rep_state_body(struct rep_state *
return SVN_NO_ERROR;
/* We are dealing with a delta, find out what version. */
- SVN_ERR(svn_io_file_read_full(rs->file, buf, sizeof(buf), NULL, pool));
+ SVN_ERR(svn_io_file_read_full2(rs->file, buf, sizeof(buf),
+ NULL, NULL, pool));
if (! ((buf[0] == 'S') && (buf[1] == 'V') && (buf[2] == 'N')))
return svn_error_create
(SVN_ERR_FS_CORRUPT, NULL,
@@ -3336,8 +3337,8 @@ get_contents(struct rep_read_baton *rb,
rs = rb->src_state;
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_full(rs->file, cur, copy_len, NULL,
- rb->pool));
+ SVN_ERR(svn_io_file_read_full2(rs->file, cur, copy_len, NULL,
+ NULL, rb->pool));
rs->off += copy_len;
*len = copy_len;
return SVN_NO_ERROR;
@@ -3412,9 +3413,9 @@ get_contents(struct rep_read_baton *rb,
SVN_ERR(svn_io_file_seek(rs->file, APR_SET, &rs->off,
rb->pool));
}
- SVN_ERR(svn_io_file_read_full(rs->file, sbuf,
- lwindow->sview_len,
- NULL, rb->pool));
+ SVN_ERR(svn_io_file_read_full2(rs->file, sbuf,
+ lwindow->sview_len,
+ NULL, NULL, rb->pool));
rs->off += lwindow->sview_len;
}
else
@@ -6694,8 +6695,8 @@ read_handler_recover(void *baton, char *
bytes_to_read = b->remaining;
b->remaining -= bytes_to_read;
- return svn_io_file_read_full(b->file, buffer, (apr_size_t) bytes_to_read,
- len, b->pool);
+ return svn_io_file_read_full2(b->file, buffer, (apr_size_t) bytes_to_read,
+ len, NULL, b->pool);
}
/* Part of the recovery procedure. Read the directory noderev at offset
Modified: subversion/trunk/subversion/libsvn_repos/reporter.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/reporter.c?rev=1072299&r1=1072298&r2=1072299&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/reporter.c (original)
+++ subversion/trunk/subversion/libsvn_repos/reporter.c Sat Feb 19 10:23:57 2011
@@ -201,7 +201,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_full(temp, buf, size, NULL, 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/trunk/subversion/libsvn_subr/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/deprecated.c?rev=1072299&r1=1072298&r2=1072299&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_subr/deprecated.c Sat Feb 19 10:23:57 2011
@@ -779,6 +779,13 @@ svn_io_start_cmd(apr_proc_t *cmd_proc,
infile, FALSE, outfile, FALSE, errfile, pool);
}
+svn_error_t *
+svn_io_file_read_full(apr_file_t *file, void *buf,
+ apr_size_t nbytes, apr_size_t *bytes_read,
+ apr_pool_t *pool)
+{
+ return svn_io_file_read_full2(file, buf, nbytes, bytes_read, NULL, pool);
+}
struct walk_func_filter_baton_t
{
Modified: subversion/trunk/subversion/libsvn_subr/hash.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/hash.c?rev=1072299&r1=1072298&r2=1072299&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/hash.c (original)
+++ subversion/trunk/subversion/libsvn_subr/hash.c Sat Feb 19 10:23:57 2011
@@ -354,8 +354,9 @@ svn_hash_read(apr_hash_t *hash,
/* Now read that much into a buffer, + 1 byte for null terminator */
keybuf = apr_palloc(pool, keylen + 1);
- SVN_ERR(svn_io_file_read_full(srcfile,
- keybuf, keylen, &num_read, pool));
+ SVN_ERR(svn_io_file_read_full2(srcfile,
+ keybuf, keylen,
+ &num_read, NULL, pool));
((char *) keybuf)[keylen] = '\0';
/* Suck up extra newline after key data */
@@ -379,9 +380,9 @@ svn_hash_read(apr_hash_t *hash,
/* Again, 1 extra byte for the null termination. */
valbuf = apr_palloc(pool, vallen + 1);
- SVN_ERR(svn_io_file_read_full(srcfile,
- valbuf, vallen,
- &num_read, pool));
+ SVN_ERR(svn_io_file_read_full2(srcfile,
+ valbuf, vallen,
+ &num_read, NULL, pool));
((char *) valbuf)[vallen] = '\0';
/* Suck up extra newline after val data */
Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1072299&r1=1072298&r2=1072299&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Sat Feb 19 10:23:57 2011
@@ -3016,6 +3016,17 @@ svn_io_file_getc(char *ch, apr_file_t *f
svn_error_t *
+svn_io_file_putc(char ch, apr_file_t *file, apr_pool_t *pool)
+{
+ return do_io_file_wrapper_cleanup
+ (file, apr_file_putc(ch, file),
+ N_("Can't write file '%s'"),
+ N_("Can't write stream"),
+ pool);
+}
+
+
+svn_error_t *
svn_io_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted,
apr_file_t *file, apr_pool_t *pool)
{
@@ -3040,12 +3051,23 @@ svn_io_file_read(apr_file_t *file, void
svn_error_t *
-svn_io_file_read_full(apr_file_t *file, void *buf,
- apr_size_t nbytes, apr_size_t *bytes_read,
- apr_pool_t *pool)
+svn_io_file_read_full2(apr_file_t *file, void *buf,
+ apr_size_t nbytes, apr_size_t *bytes_read,
+ svn_boolean_t *hit_eof,
+ apr_pool_t *pool)
{
+ apr_status_t status = apr_file_read_full(file, buf, nbytes, bytes_read);
+ 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, apr_file_read_full(file, buf, nbytes, bytes_read),
+ (file, status,
N_("Can't read file '%s'"),
N_("Can't read stream"),
pool);
@@ -3081,25 +3103,25 @@ svn_io_file_write_full(apr_file_t *file,
apr_size_t nbytes, apr_size_t *bytes_written,
apr_pool_t *pool)
{
- apr_status_t rv = apr_file_write_full(file, buf, nbytes, bytes_written);
-
#ifdef WIN32
#define MAXBUFSIZE 30*1024
- if (rv == APR_FROM_OS_ERROR(ERROR_NOT_ENOUGH_MEMORY)
- && nbytes > MAXBUFSIZE)
- {
- apr_size_t bw = 0;
- *bytes_written = 0;
-
- do {
- rv = apr_file_write_full(file, buf,
- nbytes > MAXBUFSIZE ? MAXBUFSIZE : nbytes, &bw);
- *bytes_written += bw;
- buf = (char *)buf + bw;
- nbytes -= bw;
- } while (rv == APR_SUCCESS && nbytes > 0);
- }
+ apr_status_t rv;
+ apr_size_t bw = 0;
+ apr_size_t to_write = nbytes;
+
+ do {
+ bw = to_write > MAXBUFSIZE ? MAXBUFSIZE : to_write;
+ rv = apr_file_write(file, buf, &bw);
+ buf = (char *)buf + bw;
+ to_write -= bw;
+ } while (rv == APR_SUCCESS && to_write > 0);
+
+ /* bytes_written may actually be NULL */
+ if (bytes_written)
+ *bytes_written = nbytes - to_write;
#undef MAXBUFSIZE
+#else
+ apr_status_t rv = apr_file_write_full(file, buf, nbytes, bytes_written);
#endif
return svn_error_return(do_io_file_wrapper_cleanup(
@@ -3771,8 +3793,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));
@@ -3786,39 +3808,32 @@ 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;
}
}
+ /* Special case: one file being a prefix of the other and the shorter
+ * file's size is a multiple of SVN__STREAM_CHUNK_SIZE. */
+ if (!err && (eof1 != eof2))
+ *identical_p = FALSE;
+
return svn_error_return(
svn_error_compose_create(
err,
Modified: subversion/trunk/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/stream.c?rev=1072299&r1=1072298&r2=1072299&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/stream.c (original)
+++ subversion/trunk/subversion/libsvn_subr/stream.c Sat Feb 19 10:23:57 2011
@@ -567,13 +567,24 @@ read_handler_apr(void *baton, char *buff
{
struct baton_apr *btn = baton;
svn_error_t *err;
+ svn_boolean_t eof;
- err = svn_io_file_read_full(btn->file, buffer, *len, len, btn->pool);
- if (err && APR_STATUS_IS_EOF(err->apr_err))
+ if (*len == 1)
{
- svn_error_clear(err);
- err = SVN_NO_ERROR;
+ err = svn_io_file_getc(buffer, btn->file, btn->pool);
+ if (err)
+ {
+ *len = 0;
+ if (APR_STATUS_IS_EOF(err->apr_err))
+ {
+ svn_error_clear(err);
+ err = SVN_NO_ERROR;
+ }
+ }
}
+ else
+ err = svn_io_file_read_full2(btn->file, buffer, *len, len,
+ &eof, btn->pool);
return err;
}
@@ -582,8 +593,18 @@ static svn_error_t *
write_handler_apr(void *baton, const char *data, apr_size_t *len)
{
struct baton_apr *btn = baton;
+ svn_error_t *err;
- return svn_io_file_write_full(btn->file, data, *len, len, btn->pool);
+ if (*len == 1)
+ {
+ err = svn_io_file_putc(*data, btn->file, btn->pool);
+ if (err)
+ *len = 0;
+ }
+ else
+ err = svn_io_file_write_full(btn->file, data, *len, len, btn->pool);
+
+ return err;
}
static svn_error_t *