[[[ Plug a memory leak by avoiding repeated failing attempts at apr_xlate setup. Suggested by: jerenkrantz dberlin ghudson (WHO ELSE WAS INVOLVED IN DEBUGGING THIS?) * subversion/libsvn_subr/utf.c (xlate_open_returned_enotimpl): New file-static boolean. (get_xlate_handle_node): Use new boolean to determine whether to even bother calling apr_xlate_open again. ]]] Index: subversion/libsvn_subr/utf.c =================================================================== --- subversion/libsvn_subr/utf.c (revision 15373) +++ subversion/libsvn_subr/utf.c (working copy) @@ -68,6 +68,15 @@ memory leak. */ static apr_hash_t *xlate_handle_hash = NULL; +/* Set to TRUE if apr_xlate_open() returns APR_ENOTIMPL. If that + happens, there's no point ever calling apr_xlate_open() again in + this process, and we can save ourself some setup work (including + memory allocations) by remembering that fact. It could return + APR_ENOTIMPL because APR_HAS_XLATE is not defined, or for some + other reason; for our purposes it doesn't matter, we just want to + remember that it is not implemented for this process. */ +static svn_boolean_t xlate_open_returned_enotimpl = FALSE; + /* Clean up the xlate handle cache. */ static apr_status_t xlate_cleanup (void *arg) @@ -199,9 +208,19 @@ if (userdata_key && xlate_handle_hash) pool = apr_hash_pool_get (xlate_handle_hash); + if (xlate_open_returned_enotimpl) + goto notimpl_bailout; + /* Try to create a handle. */ *ret = apr_palloc (pool, sizeof(xlate_handle_node_t)); apr_err = apr_xlate_open (&(*ret)->handle, topage, frompage, pool); + if (apr_err == APR_ENOTIMPL) + { + notimpl_bailout: + *ret = NULL; + return SVN_NO_ERROR; + } + (*ret)->frompage = ((frompage != APR_LOCALE_CHARSET) ? apr_pstrdup (pool, frompage) : frompage); (*ret)->topage = ((topage != APR_LOCALE_CHARSET)