~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr/locks/netware/thread_mutex.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * 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_general.h"
 
20
#include "apr_strings.h"
 
21
#include "apr_arch_thread_mutex.h"
 
22
#include "apr_portable.h"
 
23
 
 
24
static apr_status_t thread_mutex_cleanup(void *data)
 
25
{
 
26
    apr_thread_mutex_t *mutex = (apr_thread_mutex_t *)data;
 
27
 
 
28
    NXMutexFree(mutex->mutex);        
 
29
    return APR_SUCCESS;
 
30
}
 
31
 
 
32
APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex,
 
33
                                                  unsigned int flags,
 
34
                                                  apr_pool_t *pool)
 
35
{
 
36
    apr_thread_mutex_t *new_mutex = NULL;
 
37
 
 
38
    /* XXX: Implement _UNNESTED flavor and favor _DEFAULT for performance
 
39
     */
 
40
    if (flags & APR_THREAD_MUTEX_UNNESTED) {
 
41
        return APR_ENOTIMPL;
 
42
    }
 
43
    new_mutex = (apr_thread_mutex_t *)apr_pcalloc(pool, sizeof(apr_thread_mutex_t));
 
44
        
 
45
        if(new_mutex ==NULL) {
 
46
        return APR_ENOMEM;
 
47
    }     
 
48
    new_mutex->pool = pool;
 
49
 
 
50
    new_mutex->mutex = NXMutexAlloc(NX_MUTEX_RECURSIVE, 0, NULL);
 
51
    
 
52
    if(new_mutex->mutex == NULL)
 
53
        return APR_ENOMEM;
 
54
 
 
55
    apr_pool_cleanup_register(new_mutex->pool, new_mutex, 
 
56
                                (void*)thread_mutex_cleanup,
 
57
                                apr_pool_cleanup_null);
 
58
   *mutex = new_mutex;
 
59
    return APR_SUCCESS;
 
60
}
 
61
 
 
62
APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex)
 
63
{
 
64
    NXLock(mutex->mutex);
 
65
    return APR_SUCCESS;
 
66
}
 
67
 
 
68
APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
 
69
{
 
70
    if (!NXTryLock(mutex->mutex))
 
71
        return APR_EBUSY;
 
72
    return APR_SUCCESS;
 
73
}
 
74
 
 
75
APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex)
 
76
{
 
77
    NXUnlock(mutex->mutex);
 
78
    return APR_SUCCESS;
 
79
}
 
80
 
 
81
APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex)
 
82
{
 
83
    apr_status_t stat;
 
84
    if ((stat = thread_mutex_cleanup(mutex)) == APR_SUCCESS) {
 
85
        apr_pool_cleanup_kill(mutex->pool, mutex, thread_mutex_cleanup);
 
86
        return APR_SUCCESS;
 
87
    }
 
88
    return stat;
 
89
}
 
90
 
 
91
APR_POOL_IMPLEMENT_ACCESSOR(thread_mutex)
 
92