[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Question on proper pool usage - libsvn_ra_svn

From: Mark Phippard <MarkP_at_softlanding.com>
Date: 2004-05-28 16:28:11 CEST

I am working on porting Subversion to OS/400. I will probably be posting
some patches as I get further along (no point in posting them until it
actually works). I have a question about one of the changes I need to
make.

For background, IBM provides Apache 2.0.x and APR as part of OS/400. They
did not commit their changes to APR back to Apache.org, so I need to use
the version they provide. They have recently issued me a fix for APR to
expose some function exports that were missing. They told me that they
were only exporting the ones they needed in the HTTP server itself so
there were a handful of functions that they had ported but not made
available as exports in the library.

A small number of the APR functions have been modified in OS/400 for the
HTTP server. One of these is apr_poll(). Specifically, the IBM header
file looks like this:

 #ifdef AS400
 APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t
numsock
                                    apr_int32_t *nsds,
                                    apr_interval_time_t timeout,
        apr_pool_t *p);
 
 #else
 APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t
numsock
                                    apr_int32_t *nsds,
                                    apr_interval_time_t timeout);
 #endif

As you can see they added an extra apr_pool_t to the function parameters.
I asked IBM for an explanation as to why they added this, and this is what
they told me:

" As for the pool parameter, the apr_poll() function on the
iSeries has been enhanced to allow for more descriptors than the
normal default of 200 defined with FD_SET size. In order to
support this, the readset, writeset, and exceptset passed to the
sockets select() function need to be allocated before calling
select(). The best way to get the space allocated is to allocate
it from a pool. Using malloc() is a performance problem.
   This pool should be a pool that is unique to the thread calling
the function, since the pool support in Apache is not threadsafe
when using the same pool for different threads. The pool in the
structure passed as the first parameter may or may not be unique
to the thread, so we could not plan on using that pool. In our
code, when we use the function, we pass the pool from the request
rec structure. Since subversion probably doesn't have a request
object to do that with, this solution probably won't work for you. "

The only place that this function is used within Subversion is in file
marshal.c in libsvn_ra_svn. Here is my current patch, but I think clearly
based on IBM's description this is not the correct pool to be passing:

Index: subversion/libsvn_ra_svn/marshal.c
===================================================================
--- subversion/libsvn_ra_svn/marshal.c (revision 9884)
+++ subversion/libsvn_ra_svn/marshal.c (working copy)
@@ -120,7 +120,11 @@
     }
   pfd.p = pool;
   pfd.reqevents = APR_POLLIN;
+#ifdef AS400
+ return (APR_STATUS_IS_SUCCESS(apr_poll(&pfd, 1, &n, 0, pool)) && n);
+#else
   return (APR_STATUS_IS_SUCCESS(apr_poll(&pfd, 1, &n, 0)) && n);
+#endif
 }
 
 /* --- WRITE BUFFER MANAGEMENT --- */

Could someone possibly give me some direction as to a more appropriate way
to allocate and pass a pool to this function? I am barely C literate and
am just getting started on this, so a full code snippet would be great.

Thanks

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri May 28 16:28:28 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.