Author: rhuijben
Date: Fri Jun 25 09:25:54 2010
New Revision: 957860
URL: http://svn.apache.org/viewvc?rev=957860&view=rev
Log:
Minor optimization in svn_io_file_lock2(). Move deprecated function.
* subversion/libsvn_subr/deprecated.c
(svn_io_file_lock): Move file from io.c to here.
* subversion/libsvn_subr/io.c
(svn_io__file_clear_and_close): Rename to ...
(file_clear_locks): ... this as this function is not shared between files
and apr will take care of closing the file anyway. And comment on
Windows and OS/2, because closing a file takes care of clearing the
locks on these systems.
(svn_io_file_lock): Move to deprecated.c.
(svn_io_file_lock2): Don't register a cleanup handler on Windows and
OS/2, as the locks will be freed by just closing the handle from the
file cleanup.
Modified:
subversion/trunk/subversion/libsvn_subr/deprecated.c
subversion/trunk/subversion/libsvn_subr/io.c
Modified: subversion/trunk/subversion/libsvn_subr/deprecated.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/deprecated.c?rev=957860&r1=957859&r2=957860&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_subr/deprecated.c Fri Jun 25 09:25:54
2010
@@ -722,6 +722,14 @@ svn_io_remove_file(const char *path,
return svn_error_return(svn_io_remove_file2(path, FALSE, scratch_pool));
}
+svn_error_t *svn_io_file_lock(const char *lock_file,
+ svn_boolean_t exclusive,
+ apr_pool_t *pool)
+{
+ return svn_io_file_lock2(lock_file, exclusive, FALSE, pool);
+}
+
+
/*** From constructors.c ***/
svn_log_changed_path_t *
svn_log_changed_path_dup(const svn_log_changed_path_t *changed_path,
Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=957860&r1=957859&r2=957860&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Fri Jun 25 09:25:54 2010
@@ -1589,9 +1589,10 @@ svn_io_is_file_executable(svn_boolean_t
/*** File locking. ***/
+#if !defined(WIN32) && !defined(__OS2__)
/* Clear all outstanding locks on ARG, an open apr_file_t *. */
static apr_status_t
-svn_io__file_clear_and_close(void *arg)
+file_clear_locks(void *arg)
{
apr_status_t apr_err;
apr_file_t *f = arg;
@@ -1601,26 +1602,15 @@ svn_io__file_clear_and_close(void *arg)
if (apr_err)
return apr_err;
- /* Close the file. */
- apr_err = apr_file_close(f);
- if (apr_err)
- return apr_err;
-
return 0;
}
+#endif
-
-svn_error_t *svn_io_file_lock(const char *lock_file,
- svn_boolean_t exclusive,
- apr_pool_t *pool)
-{
- return svn_io_file_lock2(lock_file, exclusive, FALSE, pool);
-}
-
-svn_error_t *svn_io_file_lock2(const char *lock_file,
- svn_boolean_t exclusive,
- svn_boolean_t nonblocking,
- apr_pool_t *pool)
+svn_error_t *
+svn_io_file_lock2(const char *lock_file,
+ svn_boolean_t exclusive,
+ svn_boolean_t nonblocking,
+ apr_pool_t *pool)
{
int locktype = APR_FLOCK_SHARED;
apr_file_t *lockfile_handle;
@@ -1660,9 +1650,13 @@ svn_error_t *svn_io_file_lock2(const cha
}
}
+/* On Windows and OS/2 file locks are automatically released when
+ the file handle closes */
+#if !defined(WIN32) && !defined(__OS2__)
apr_pool_cleanup_register(pool, lockfile_handle,
- svn_io__file_clear_and_close,
+ file_clear,
apr_pool_cleanup_null);
+#endif
return SVN_NO_ERROR;
}