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

« back to all changes in this revision

Viewing changes to srclib/apr/locks/netware/thread_cond.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 <nks/errno.h>
 
18
 
 
19
#include "apr.h"
 
20
#include "apr_private.h"
 
21
#include "apr_general.h"
 
22
#include "apr_strings.h"
 
23
#include "apr_arch_thread_mutex.h"
 
24
#include "apr_arch_thread_cond.h"
 
25
#include "apr_portable.h"
 
26
 
 
27
static apr_status_t thread_cond_cleanup(void *data)
 
28
{
 
29
    apr_thread_cond_t *cond = (apr_thread_cond_t *)data;
 
30
 
 
31
    NXCondFree(cond->cond);        
 
32
    return APR_SUCCESS;
 
33
 
34
 
 
35
APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
 
36
                                                 apr_pool_t *pool)
 
37
{
 
38
    apr_thread_cond_t *new_cond = NULL;
 
39
 
 
40
    new_cond = (apr_thread_cond_t *)apr_pcalloc(pool, sizeof(apr_thread_cond_t));
 
41
        
 
42
        if(new_cond ==NULL) {
 
43
        return APR_ENOMEM;
 
44
    }     
 
45
    new_cond->pool = pool;
 
46
 
 
47
    new_cond->cond = NXCondAlloc(NULL);
 
48
    
 
49
    if(new_cond->cond == NULL)
 
50
        return APR_ENOMEM;
 
51
 
 
52
    apr_pool_cleanup_register(new_cond->pool, new_cond, 
 
53
                                (void*)thread_cond_cleanup,
 
54
                                apr_pool_cleanup_null);
 
55
   *cond = new_cond;
 
56
    return APR_SUCCESS;
 
57
}
 
58
 
 
59
APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
 
60
                                               apr_thread_mutex_t *mutex)
 
61
{
 
62
    if (NXCondWait(cond->cond, mutex->mutex) != 0)
 
63
        return APR_EINTR;
 
64
    return APR_SUCCESS;
 
65
}
 
66
 
 
67
APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond,
 
68
                                                    apr_thread_mutex_t *mutex,
 
69
                                                    apr_interval_time_t timeout){
 
70
    if (NXCondTimedWait(cond->cond, mutex->mutex, 
 
71
        (timeout*1000)/NXGetSystemTick()) == NX_ETIMEDOUT) {
 
72
        return APR_TIMEUP;
 
73
    }
 
74
    return APR_SUCCESS;
 
75
}
 
76
 
 
77
APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond)
 
78
{
 
79
    NXCondSignal(cond->cond);
 
80
    return APR_SUCCESS;
 
81
}
 
82
 
 
83
APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond)
 
84
{
 
85
    NXCondBroadcast(cond->cond);
 
86
    return APR_SUCCESS;
 
87
}
 
88
 
 
89
APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond)
 
90
{
 
91
    apr_status_t stat;
 
92
    if ((stat = thread_cond_cleanup(cond)) == APR_SUCCESS) {
 
93
        apr_pool_cleanup_kill(cond->pool, cond, thread_cond_cleanup);
 
94
        return APR_SUCCESS;
 
95
    }
 
96
    return stat;
 
97
}
 
98
 
 
99
APR_POOL_IMPLEMENT_ACCESSOR(thread_cond)
 
100