subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject svn commit: r1350475 - /subversion/trunk/subversion/libsvn_ra_serf/util.c
Date Fri, 15 Jun 2012 06:57:00 GMT
Author: jerenkrantz
Date: Fri Jun 15 06:57:00 2012
New Revision: 1350475

URL: http://svn.apache.org/viewvc?rev=1350475&view=rev
Log:
Relieve some memory pressure by delaying XML parser creation until we start
to receive a response.  Otherwise, we'd create the parser as soon as we
queue the request meaning we could have up to 1,000 parsers created at a
time sitting around waiting for serf to give us data.

* subversion/libsvn_ra_serf/util.c
  (expat_response_handler): Create parser when needed on first one.
  (svn_ra_serf__create_expat_handler): Delay parser and actually use
  cleanup_pool.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/util.c

Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1350475&r1=1350474&r2=1350475&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Fri Jun 15 06:57:00 2012
@@ -2370,7 +2370,15 @@ expat_response_handler(serf_request_t *r
 {
   struct expat_ctx_t *ectx = baton;
 
-  SVN_ERR_ASSERT(ectx->parser != NULL);
+  if (!ectx->parser)
+    {
+      ectx->parser = XML_ParserCreate(NULL);
+      apr_pool_cleanup_register(ectx->cleanup_pool, &ectx->parser,
+                                xml_parser_cleanup, apr_pool_cleanup_null);
+      XML_SetUserData(ectx->parser, ectx);
+      XML_SetElementHandler(ectx->parser, expat_start, expat_end);
+      XML_SetCharacterDataHandler(ectx->parser, expat_cdata);
+    }
 
   /* ### should we bail on anything < 200 or >= 300 ??
      ### actually: < 200 should really be handled by the core.  */
@@ -2457,12 +2465,8 @@ svn_ra_serf__create_expat_handler(svn_ra
 
   ectx = apr_pcalloc(result_pool, sizeof(*ectx));
   ectx->xmlctx = xmlctx;
-  ectx->parser = XML_ParserCreate(NULL);
-  apr_pool_cleanup_register(result_pool, &ectx->parser,
-                            xml_parser_cleanup, apr_pool_cleanup_null);
-  XML_SetUserData(ectx->parser, ectx);
-  XML_SetElementHandler(ectx->parser, expat_start, expat_end);
-  XML_SetCharacterDataHandler(ectx->parser, expat_cdata);
+  ectx->parser = NULL;
+  ectx->cleanup_pool = result_pool;
 
 
   handler = apr_pcalloc(result_pool, sizeof(*handler));



Mime
View raw message