"Fossies" - the Fresh Open Source Software Archive

Member "apr-1.7.0/locks/netware/proc_mutex.c" (2 Jun 2017, 5984 Bytes) of package /linux/www/apr-1.7.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "proc_mutex.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.6.5_vs_1.7.0.

    1 /* Licensed to the Apache Software Foundation (ASF) under one or more
    2  * contributor license agreements.  See the NOTICE file distributed with
    3  * this work for additional information regarding copyright ownership.
    4  * The ASF licenses this file to You under the Apache License, Version 2.0
    5  * (the "License"); you may not use this file except in compliance with
    6  * the License.  You may obtain a copy of the License at
    7  *
    8  *     http://www.apache.org/licenses/LICENSE-2.0
    9  *
   10  * Unless required by applicable law or agreed to in writing, software
   11  * distributed under the License is distributed on an "AS IS" BASIS,
   12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13  * See the License for the specific language governing permissions and
   14  * limitations under the License.
   15  */
   16 
   17 #include "apr.h"
   18 #include "apr_private.h"
   19 #include "apr_portable.h"
   20 #include "apr_arch_proc_mutex.h"
   21 #include "apr_arch_thread_mutex.h"
   22 
   23 APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex,
   24                                                 const char *fname,
   25                                                 apr_lockmech_e mech,
   26                                                 apr_pool_t *pool)
   27 {
   28     apr_status_t ret;
   29     apr_proc_mutex_t *new_mutex;
   30     unsigned int flags = APR_THREAD_MUTEX_DEFAULT;
   31 
   32     *mutex = NULL;
   33     if (mech == APR_LOCK_DEFAULT_TIMED) {
   34         flags |= APR_THREAD_MUTEX_TIMED;
   35     }
   36     else if (mech != APR_LOCK_DEFAULT) {
   37         return APR_ENOTIMPL;
   38     }
   39 
   40     new_mutex = (apr_proc_mutex_t *)apr_pcalloc(pool, sizeof(apr_proc_mutex_t));
   41     if (new_mutex == NULL) {
   42         return APR_ENOMEM;
   43     }     
   44     
   45     new_mutex->pool = pool;
   46     ret = apr_thread_mutex_create(&(new_mutex->mutex), flags, pool);
   47 
   48     if (ret == APR_SUCCESS)
   49         *mutex = new_mutex;
   50 
   51     return ret;
   52 }
   53 
   54 APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex,
   55                                                     const char *fname,
   56                                                     apr_pool_t *pool)
   57 {
   58     return APR_SUCCESS;
   59 }
   60     
   61 APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex)
   62 {
   63     if (mutex)
   64         return apr_thread_mutex_lock(mutex->mutex);
   65     return APR_ENOLOCK;
   66 }
   67 
   68 APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
   69 {
   70     if (mutex)
   71         return apr_thread_mutex_trylock(mutex->mutex);
   72     return APR_ENOLOCK;
   73 }
   74 
   75 APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex,
   76                                                apr_interval_time_t timeout)
   77 {
   78     if (mutex)
   79         return apr_thread_mutex_timedlock(mutex->mutex, timeout);
   80     return APR_ENOLOCK;
   81 }
   82 
   83 APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex)
   84 {
   85     if (mutex)
   86         return apr_thread_mutex_unlock(mutex->mutex);
   87     return APR_ENOLOCK;
   88 }
   89 
   90 APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex)
   91 {
   92     return apr_proc_mutex_destroy(mutex);
   93 }
   94 
   95 APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex)
   96 {
   97     if (mutex)
   98         return apr_thread_mutex_destroy(mutex->mutex);
   99     return APR_ENOLOCK;
  100 }
  101 
  102 APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex)
  103 {
  104     return NULL;
  105 }
  106 
  107 APR_DECLARE(apr_lockmech_e) apr_proc_mutex_mech(apr_proc_mutex_t *mutex)
  108 {
  109     return APR_LOCK_DEFAULT;
  110 }
  111 
  112 APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex)
  113 {
  114     return "netwarethread";
  115 }
  116 
  117 APR_DECLARE(const char *) apr_proc_mutex_defname(void)
  118 {
  119     return "netwarethread";
  120 }
  121 
  122 APR_PERMS_SET_ENOTIMPL(proc_mutex)
  123 
  124 APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
  125 
  126 /* Implement OS-specific accessors defined in apr_portable.h */
  127 
  128 APR_DECLARE(apr_status_t) apr_os_proc_mutex_get_ex(apr_os_proc_mutex_t *ospmutex, 
  129                                                    apr_proc_mutex_t *pmutex,
  130                                                    apr_lockmech_e *mech)
  131 {
  132     if (pmutex && pmutex->mutex)
  133         ospmutex = pmutex->mutex->mutex;
  134     return APR_ENOLOCK;
  135 #if 0
  136     /* We need to change apr_os_proc_mutex_t to a pointer type
  137      * to be able to implement this function.
  138      */
  139     *ospmutex = pmutex->mutex->mutex;
  140     if (mech) {
  141         *mech = APR_LOCK_DEFAULT;
  142     }
  143     return APR_SUCCESS;
  144 #endif
  145 }
  146 
  147 APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
  148                                                 apr_proc_mutex_t *pmutex)
  149 {
  150     return apr_os_proc_mutex_get_ex(ospmutex, pmutex, NULL);
  151 }
  152 
  153 APR_DECLARE(apr_status_t) apr_os_proc_mutex_put_ex(apr_proc_mutex_t **pmutex,
  154                                                 apr_os_proc_mutex_t *ospmutex,
  155                                                 apr_lockmech_e mech,
  156                                                 int register_cleanup,
  157                                                 apr_pool_t *pool)
  158 {
  159     if (pool == NULL) {
  160         return APR_ENOPOOL;
  161     }
  162     if (mech != APR_LOCK_DEFAULT && mech != APR_LOCK_DEFAULT_TIMED) {
  163         return APR_ENOTIMPL;
  164     }
  165 #if 0
  166     /* We need to change apr_os_proc_mutex_t to a pointer type
  167      * to be able to implement this function.
  168      */
  169     if ((*pmutex) == NULL) {
  170         (*pmutex) = apr_pcalloc(pool, sizeof(apr_proc_mutex_t));
  171         (*pmutex)->pool = pool;
  172     }
  173     (*pmutex)->mutex = apr_pcalloc(pool, sizeof(apr_thread_mutex_t));
  174     (*pmutex)->mutex->mutex = *ospmutex;
  175     (*pmutex)->mutex->pool = pool;
  176 
  177     if (register_cleanup) {
  178         apr_pool_cleanup_register(pool, *pmutex, apr_proc_mutex_cleanup,
  179                                   apr_pool_cleanup_null);
  180     }
  181     return APR_SUCCESS;
  182 #else
  183     return APR_ENOTIMPL;
  184 #endif
  185 }
  186 
  187 APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
  188                                                 apr_os_proc_mutex_t *ospmutex,
  189                                                 apr_pool_t *pool)
  190 {
  191     return apr_os_proc_mutex_put_ex(pmutex, ospmutex, APR_LOCK_DEFAULT,
  192                                     0, pool);
  193 }
  194