apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apr/misc/unix start.c
Date Mon, 27 Nov 2000 21:32:33 GMT
rbb         00/11/27 13:32:25

  Modified:    misc/unix start.c
  Log:
  apr_initialize should only setup apr if this is the first call, and
  apr_terminate should only tear the locks down if this is the final call.
  This allows multiple stand-alone programs that all use APR to be combined
  cleanly without requiring a lot of if statements.  Each program just calls
  apr_initialize and apr_terminate, but only the first and last calls
  respectively do anything.
  Submitted by:	Doug MacEachern <dougm@covalent.net>
  
  Revision  Changes    Path
  1.39      +16 -3     apr/misc/unix/start.c
  
  Index: start.c
  ===================================================================
  RCS file: /home/cvs/apr/misc/unix/start.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- start.c	2000/08/02 05:26:22	1.38
  +++ start.c	2000/11/27 21:32:14	1.39
  @@ -56,6 +56,8 @@
   #include "locks.h"
   #include "apr_strings.h"
   
  +static int initialized=0;
  +
   apr_status_t apr_create_pool(apr_pool_t **newcont, apr_pool_t *cont)
   {
       apr_pool_t *newpool;
  @@ -138,13 +140,20 @@
   apr_status_t apr_initialize(void)
   {
       apr_status_t status;
  -#if !defined(BEOS) && !defined(OS2) && !defined(WIN32)
  -    apr_unix_setup_lock();
  -#elif defined WIN32
  +#if defined WIN32
       int iVersionRequested;
       WSADATA wsaData;
       int err;
  +#endif
   
  +    if (initialized) {
  +        return APR_SUCCESS;
  +    }
  +    initialized++;
  +
  +#if !defined(BEOS) && !defined(OS2) && !defined(WIN32)
  +    apr_unix_setup_lock();
  +#elif defined WIN32
       iVersionRequested = MAKEWORD(WSAHighByte, WSALowByte);
       err = WSAStartup((WORD) iVersionRequested, &wsaData);
       if (err) {
  @@ -162,6 +171,10 @@
   
   void apr_terminate(void)
   {
  +    initialized--;
  +    if (initialized) {
  +        return;
  +    }
       apr_term_alloc();
   }
   
  
  
  

Mime
View raw message