apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aa...@apache.org
Subject cvs commit: apr/locks/win32 global_mutex.c
Date Mon, 18 Feb 2002 01:16:04 GMT
aaron       02/02/17 17:16:04

  Modified:    test     Makefile.in
               locks/beos Makefile.in
               locks/os2 Makefile.in
               locks/unix Makefile.in
  Added:       include  apr_global_mutex.h
               include/arch/unix global_mutex.h
               test     testglobalmutex.c
               locks/beos global_mutex.c
               locks/netware global_mutex.c
               locks/os2 global_mutex.c
               locks/unix global_mutex.c
               locks/win32 global_mutex.c
  Log:
  Add a new lock API: apr_global_mutex_t
  This is analog to the APR_LOCKALL method of apr_lock_t, and provides
  cross-process AND cross-thread mutual exclusion.
  
  I have provided a simple test (based on testprocmutex.c) and stubs
  for non-Unix platforms.
  
  Revision  Changes    Path
  1.1                  apr/include/apr_global_mutex.h
  
  Index: apr_global_mutex.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef APR_GLOBAL_MUTEX_H
  #define APR_GLOBAL_MUTEX_H
  
  #include "apr.h"
  #include "apr_lock.h"    /* only for apr_lockmech_e_np */
  #include "apr_pools.h"
  #include "apr_errno.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif /* __cplusplus */
  
  /**
   * @file apr_global_mutex.h
   * @brief APR Global Locking Routines
   */
  
  /**
   * @defgroup APR_GlobalMutex Global Locking Routines
   * @ingroup APR
   * @{
   */
  
  typedef struct apr_global_mutex_t apr_global_mutex_t;
  
  /*   Function definitions */
  
  /**
   * Create and initialize a mutex that can be used to synchronize both
   * processes and threads. Note: There is considerable overhead in using
   * this API if only cross-process or cross-thread mutual exclusion is
   * required. See apr_proc_mutex.h and apr_thread_mutex.h for more
   * specialized lock routines.
   * @param mutex the memory address where the newly created mutex will be
   *        stored.
   * @param fname A file name to use if the lock mechanism requires one.  This
   *        argument should always be provided.  The lock code itself will
   *        determine if it should be used.
   * @param mech The mechanism to use for the interprocess lock, if any; one of
   * <PRE>
   *            APR_LOCK_FCNTL
   *            APR_LOCK_FLOCK
   *            APR_LOCK_SYSVSEM
   *            APR_LOCK_PROC_PTHREAD
   *            APR_LOCK_DEFAULT     pick the default mechanism for the platform
   * </PRE>
   * @param pool the pool from which to allocate the mutex.
   * @warning Check APR_HAS_foo_SERIALIZE defines to see if the platform supports
   *          APR_LOCK_foo.  Only APR_LOCK_DEFAULT is portable.
   */
  APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex,
                                                    const char *fname,
                                                    apr_lockmech_e mech,
                                                    apr_pool_t *pool);
  
  /**
   * Re-open a mutex in a child process.
   * @param mutex The newly re-opened mutex structure.
   * @param fname A file name to use if the mutex mechanism requires one.  This
   *              argument should always be provided.  The mutex code itself will
   *              determine if it should be used.  This filename should be the 
   *              same one that was passed to apr_global_mutex_create().
   * @param pool The pool to operate on.
   * @remark This function must be called to maintain portability, even
   *         if the underlying lock mechanism does not require it.
   */
  APR_DECLARE(apr_status_t) apr_global_mutex_child_init(
                                apr_global_mutex_t **mutex,
                                const char *fname,
                                apr_pool_t *pool);
  
  /**
   * Acquire the lock for the given mutex. If the mutex is already locked,
   * the current thread will be put to sleep until the lock becomes available.
   * @param mutex the mutex on which to acquire the lock.
   */
  APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex);
  
  /**
   * Attempt to acquire the lock for the given mutex. If the mutex has already
   * been acquired, the call returns immediately with APR_EBUSY. Note: it
   * is important that the APR_STATUS_IS_EBUSY(s) macro be used to determine
   * if the return value was APR_EBUSY, for portability reasons.
   * @param mutex the mutex on which to attempt the lock acquiring.
   */
  APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex);
  
  /**
   * Release the lock for the given mutex.
   * @param mutex the mutex from which to release the lock.
   */
  APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex);
  
  /**
   * Destroy the mutex and free the memory associated with the lock.
   * @param mutex the mutex to destroy.
   */
  APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex);
  
  /**
   * Get the pool used by this global_mutex.
   * @return apr_pool_t the pool
   */
  APR_POOL_DECLARE_ACCESSOR(global_mutex);
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif  /* ndef APR_GLOBAL_MUTEX_H */
  
  
  
  1.1                  apr/include/arch/unix/global_mutex.h
  
  Index: global_mutex.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef GLOBAL_MUTEX_H
  #define GLOBAL_MUTEX_H
  
  #include "apr.h"
  #include "apr_private.h"
  #include "apr_general.h"
  #include "apr_lib.h"
  #include "apr_global_mutex.h"
  #include "proc_mutex.h"
  #include "thread_mutex.h"
  
  struct apr_global_mutex_t {
      apr_pool_t *pool;
      apr_proc_mutex_t *proc_mutex;
      apr_thread_mutex_t *thread_mutex;
  };
  
  #endif  /* GLOBAL_MUTEX_H */
  
  
  
  
  1.79      +4 -0      apr/test/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/test/Makefile.in,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- Makefile.in	12 Feb 2002 21:49:32 -0000	1.78
  +++ Makefile.in	18 Feb 2002 01:16:03 -0000	1.79
  @@ -33,6 +33,7 @@
   	testuser@EXEEXT@ \
   	testsockets@EXEEXT@ \
   	testprocmutex@EXEEXT@ \
  +	testglobalmutex@EXEEXT@ \
   	testvsn@EXEEXT@ \
   	testsleep@EXEEXT@ \
   	testrand@EXEEXT@ \
  @@ -159,6 +160,9 @@
   
   testprocmutex@EXEEXT@: testprocmutex.lo $(LOCAL_LIBS)
   	$(LINK) testprocmutex.lo $(LOCAL_LIBS) $(ALL_LIBS)
  +
  +testglobalmutex@EXEEXT@: testglobalmutex.lo $(LOCAL_LIBS)
  +	$(LINK) testglobalmutex.lo $(LOCAL_LIBS) $(ALL_LIBS)
   
   testvsn@EXEEXT@: testvsn.lo $(LOCAL_LIBS)
   	$(LINK) testvsn.lo $(LOCAL_LIBS) $(ALL_LIBS)
  
  
  
  1.1                  apr/test/testglobalmutex.c
  
  Index: testglobalmutex.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr_shm.h"
  #include "apr_thread_proc.h"
  #include "apr_file_io.h"
  #include "apr_lock.h"
  #include "apr_global_mutex.h"
  #include "apr_errno.h"
  #include "apr_general.h"
  #include "apr_getopt.h"
  #include "errno.h"
  #include <stdio.h>
  #include <stdlib.h>
  #include "test_apr.h"
  
  
  #define MAX_ITER 4000
  #define MAX_COUNTER (MAX_ITER * 4)
  
  apr_global_mutex_t *global_lock;
  apr_pool_t *pool;
  int *x;
  
  static int make_child(apr_proc_t **proc, apr_pool_t *p)
  {
      int i = 0;
      *proc = apr_pcalloc(p, sizeof(**proc));
  
      /* slight delay to allow things to settle */
      apr_sleep (1);
  
      if (apr_proc_fork(*proc, p) == APR_INCHILD) {
          while (1) {
              apr_global_mutex_lock(global_lock); 
              if (i == MAX_ITER) {
                  apr_global_mutex_unlock(global_lock); 
                  exit(1);
              }
              i++;
              (*x)++;
              apr_global_mutex_unlock(global_lock); 
          }
          exit(1);
      }
      return APR_SUCCESS;
  }
  
  static apr_status_t test_exclusive(const char *lockname)
  {
      apr_proc_t *p1, *p2, *p3, *p4;
      apr_status_t s1, s2, s3, s4;
   
      printf("Exclusive lock test\n");
      printf("%-60s", "    Initializing the lock");
      s1 = apr_global_mutex_create(&global_lock, lockname, APR_LOCK_DEFAULT, pool);
   
      if (s1 != APR_SUCCESS) {
          printf("Failed!\n");
          return s1;
      }
      printf("OK\n");
   
      printf("%-60s", "    Starting all of the processes");
      fflush(stdout);
      s1 = make_child(&p1, pool);
      s2 = make_child(&p2, pool);
      s3 = make_child(&p3, pool);
      s4 = make_child(&p4, pool);
      if (s1 != APR_SUCCESS || s2 != APR_SUCCESS ||
          s3 != APR_SUCCESS || s4 != APR_SUCCESS) {
          printf("Failed!\n");
          return s1;
      }
      printf("OK\n");
   
      printf("%-60s", "    Waiting for processes to exit");
      s1 = apr_proc_wait(p1, NULL, NULL, APR_WAIT);
      s2 = apr_proc_wait(p2, NULL, NULL, APR_WAIT);
      s3 = apr_proc_wait(p3, NULL, NULL, APR_WAIT);
      s4 = apr_proc_wait(p4, NULL, NULL, APR_WAIT);
      printf("OK\n");
   
      if ((*x) != MAX_COUNTER) {
          fprintf(stderr, "Locks don't appear to work!  x = %d instead of %d\n",
                  (*x), MAX_COUNTER);
      }
      else {
          printf("Test passed\n");
      }
      return APR_SUCCESS;
  }
  
  int main(int argc, const char * const *argv)
  {
      apr_status_t rv;
      char errmsg[200];
      const char *lockname = NULL;
      const char *shmname = "shm.file";
      apr_getopt_t *opt;
      char optchar;
      const char *optarg;
      apr_shm_t *shm;
  
      printf("APR Proc Mutex Test\n==============\n\n");
          
      apr_initialize();
      atexit(apr_terminate);
  
      if (apr_pool_create(&pool, NULL) != APR_SUCCESS)
          exit(-1);
  
      if ((rv = apr_getopt_init(&opt, pool, argc, argv)) != APR_SUCCESS) {
          fprintf(stderr, "Could not set up to parse options: [%d] %s\n",
                  rv, apr_strerror(rv, errmsg, sizeof errmsg));
          exit(-1);
      }
          
      while ((rv = apr_getopt(opt, "f:", &optchar, &optarg)) == APR_SUCCESS) {
          if (optchar == 'f') {
              lockname = optarg;
          }
      }
  
      if (rv != APR_SUCCESS && rv != APR_EOF) {
          fprintf(stderr, "Could not parse options: [%d] %s\n",
                  rv, apr_strerror(rv, errmsg, sizeof errmsg));
          exit(-1);
      }
  
      apr_shm_create(&shm, sizeof(int), shmname, pool);
      x = apr_shm_baseaddr_get(shm);
  
      if ((rv = test_exclusive(lockname)) != APR_SUCCESS) {
          fprintf(stderr,"Exclusive Lock test failed : [%d] %s\n",
                  rv, apr_strerror(rv, (char*)errmsg, 200));
          exit(-2);
      }
      
      return 0;
  }
  
  
  
  
  1.17      +2 -1      apr/locks/beos/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/locks/beos/Makefile.in,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Makefile.in	19 Sep 2001 20:06:43 -0000	1.16
  +++ Makefile.in	18 Feb 2002 01:16:03 -0000	1.17
  @@ -3,7 +3,8 @@
   	thread_mutex.lo \
   	thread_rwlock.lo \
   	thread_cond.lo \
  -	proc_mutex.lo
  +	proc_mutex.lo \
  +	global_mutex.lo
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  
  
  
  1.1                  apr/locks/beos/global_mutex.c
  
  Index: global_mutex.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr.h"
  #include "apr_strings.h"
  
  APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex,
                                                    const char *fname,
                                                    apr_lockmech_e mech,
                                                    apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_child_init(
                                apr_global_mutex_t **mutex,
                                const char *fname,
                                apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_POOL_IMPLEMENT_ACCESSOR(global_mutex);
  
  
  
  
  1.1                  apr/locks/netware/global_mutex.c
  
  Index: global_mutex.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr.h"
  #include "apr_strings.h"
  
  APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex,
                                                    const char *fname,
                                                    apr_lockmech_e mech,
                                                    apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_child_init(
                                apr_global_mutex_t **mutex,
                                const char *fname,
                                apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_POOL_IMPLEMENT_ACCESSOR(global_mutex);
  
  
  
  
  1.17      +2 -1      apr/locks/os2/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/locks/os2/Makefile.in,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Makefile.in	19 Sep 2001 20:06:44 -0000	1.16
  +++ Makefile.in	18 Feb 2002 01:16:04 -0000	1.17
  @@ -3,7 +3,8 @@
   	thread_mutex.lo \
   	thread_rwlock.lo \
   	thread_cond.lo \
  -    proc_mutex.lo
  +	proc_mutex.lo \
  +	global_mutex.lo
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  
  
  
  1.1                  apr/locks/os2/global_mutex.c
  
  Index: global_mutex.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr.h"
  #include "apr_strings.h"
  
  APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex,
                                                    const char *fname,
                                                    apr_lockmech_e mech,
                                                    apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_child_init(
                                apr_global_mutex_t **mutex,
                                const char *fname,
                                apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_POOL_IMPLEMENT_ACCESSOR(global_mutex);
  
  
  
  
  1.23      +2 -1      apr/locks/unix/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/Makefile.in,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Makefile.in	19 Sep 2001 20:06:44 -0000	1.22
  +++ Makefile.in	18 Feb 2002 01:16:04 -0000	1.23
  @@ -6,7 +6,8 @@
   	thread_mutex.lo \
   	thread_rwlock.lo \
   	thread_cond.lo \
  -	proc_mutex.lo
  +	proc_mutex.lo \
  +	global_mutex.lo
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  
  
  
  1.1                  apr/locks/unix/global_mutex.c
  
  Index: global_mutex.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr.h"
  #include "apr_strings.h"
  #include "global_mutex.h"
  #include "apr_proc_mutex.h"
  #include "apr_thread_mutex.h"
  
  
  static apr_status_t global_mutex_cleanup(void *data)
  {
      apr_global_mutex_t *m = (apr_global_mutex_t *)data;
      apr_status_t rv;
  
      if (m->thread_mutex) {
          rv = apr_thread_mutex_destroy(m->thread_mutex);
          if (rv != APR_SUCCESS) {
              return rv;
          }
      }
      rv = apr_proc_mutex_destroy(m->proc_mutex);
      if (rv != APR_SUCCESS) {
         return rv;
      }
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex,
                                                    const char *fname,
                                                    apr_lockmech_e mech,
                                                    apr_pool_t *pool)
  {
      apr_status_t rv;
      apr_global_mutex_t *m;
  
      m = (apr_global_mutex_t *)apr_palloc(pool, sizeof(*m));
      m->pool = pool;
  
      rv = apr_proc_mutex_create(&m->proc_mutex, fname, mech, m->pool);
      if (rv != APR_SUCCESS) {
          return rv;
      }
  
      if (m->proc_mutex->inter_meth->flags & APR_PROCESS_LOCK_MECH_IS_GLOBAL)
{
          m->thread_mutex = NULL; /* We don't need a thread lock. */
      }
      else {
          rv = apr_thread_mutex_create(&m->thread_mutex,
                                       APR_THREAD_MUTEX_DEFAULT, m->pool);
          if (rv != APR_SUCCESS) {
              return rv;
          }
      }
  
      apr_pool_cleanup_register(m->pool, (void *)m,
                                global_mutex_cleanup, apr_pool_cleanup_null);
      *mutex = m;
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_child_init(
                                apr_global_mutex_t **mutex,
                                const char *fname,
                                apr_pool_t *pool)
  {
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex)
  {
      apr_status_t rv;
  
      if (mutex->thread_mutex) {
          rv = apr_thread_mutex_lock(mutex->thread_mutex);
          if (rv != APR_SUCCESS) {
              return rv;
          }
      }
      rv = apr_proc_mutex_lock(mutex->proc_mutex);
      if (rv != APR_SUCCESS) {
          return rv;
      }
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex)
  {
      apr_status_t rv;
  
      if (mutex->thread_mutex) {
          rv = apr_thread_mutex_trylock(mutex->thread_mutex);
          if (rv != APR_SUCCESS) {
              return rv;
          }
      }
      rv = apr_proc_mutex_trylock(mutex->proc_mutex);
      if (rv != APR_SUCCESS) {
          return rv;
      }
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex)
  {
      apr_status_t rv;
  
      rv = apr_proc_mutex_unlock(mutex->proc_mutex);
      if (rv != APR_SUCCESS) {
          return rv;
      }
      if (mutex->thread_mutex) {
          rv = apr_thread_mutex_unlock(mutex->thread_mutex);
          if (rv != APR_SUCCESS) {
              return rv;
          }
      }
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex)
  {
      return apr_pool_cleanup_run(mutex->pool, mutex, global_mutex_cleanup);
  }
  
  APR_POOL_IMPLEMENT_ACCESSOR(global_mutex);
  
  
  
  
  1.1                  apr/locks/win32/global_mutex.c
  
  Index: global_mutex.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr.h"
  #include "apr_strings.h"
  
  APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex,
                                                    const char *fname,
                                                    apr_lockmech_e mech,
                                                    apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_child_init(
                                apr_global_mutex_t **mutex,
                                const char *fname,
                                apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_POOL_IMPLEMENT_ACCESSOR(global_mutex);
  
  
  
  

Mime
View raw message