You can't just write an error to stderr and exit *in a library*. That function is (like SVN_INT) only for command line applications.
On Windows your application will just disappear if this code is reached. Please use the standard malfunction handling in this case, as then applications have at least the option of showing what happened. They could crash while showing the error, but at least it is not by default not showing anything.
Bert
Sent from Windows Mail
From: Stefan Fuhrmann
Sent: Thursday, November 21, 2013 4:57 AM
To: commits_at_subversion.apache.org
Author: stefan2
Date: Thu Nov 21 03:57:12 2013
New Revision: 1544027
URL: http://svn.apache.org/r1544027
Log:
If we cannot synchronize data access in an APR pool cleanup function,
there is not much we can do except to log the error and to terminate.
Do that in the object pool code.
* subversion/libsvn_subr/object_pool.c
(exit_on_error): new error checking function
(object_ref_cleanup): terminate upon sync failure
Modified:
subversion/trunk/subversion/libsvn_subr/object_pool.c
Modified: subversion/trunk/subversion/libsvn_subr/object_pool.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/object_pool.c?rev=1544027&r1=1544026&r2=1544027&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/object_pool.c (original)
+++ subversion/trunk/subversion/libsvn_subr/object_pool.c Thu Nov 21 03:57:12 2013
@@ -229,6 +229,15 @@ remove_unused_objects(svn_object_pool__t
object_pool->objects_hash_pool = new_pool;
}
+/* If ERR is not 0, handle it and terminate the application.
+ */
+static void
+exit_on_error(svn_error_t *err)
+{
+ if (err)
+ svn_handle_error2(err, stderr, TRUE, "svn: ");
+}
+
/* Cleanup function called when an object_ref_t gets released.
*/
static apr_status_t
@@ -256,7 +265,8 @@ object_ref_cleanup(void *baton)
return APR_SUCCESS;
}
- SVN_INT_ERR(svn_mutex__lock(object_pool->mutex));
+ /* begin critical section */
+ exit_on_error(svn_error_trace(svn_mutex__lock(object_pool->mutex)));
/* put back into "available" container */
if (!object_pool->share_objects)
@@ -275,7 +285,8 @@ object_ref_cleanup(void *baton)
remove_unused_objects(object_pool);
}
- SVN_INT_ERR(svn_mutex__unlock(object_pool->mutex, NULL));
+ /* end critical section */
+ exit_on_error(svn_error_trace(svn_mutex__unlock(object_pool->mutex, NULL)));
/* Maintain reference counters and handle object cleanup */
if (svn_atomic_dec(&object->ref_count) == 0)
Received on 2013-11-21 10:50:26 CET