Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: c/lock.c

Issue 2842333002: Updated netty-tcnative to version 2.0.0.Final (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « c/jnilib.c ('k') | c/misc.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 /*
18 *
19 * @author Mladen Turk
20 * @version $Id: lock.c 1442587 2013-02-05 13:49:48Z rjung $
21 */
22
23 #include "tcn.h"
24 #include "apr_proc_mutex.h"
25 #include "apr_global_mutex.h"
26
27 TCN_IMPLEMENT_CALL(jlong, Lock, create)(TCN_STDARGS,
28 jstring fname,
29 jint mech, jlong pool)
30 {
31 apr_pool_t *p = J2P(pool, apr_pool_t *);
32 apr_proc_mutex_t *mutex;
33 TCN_ALLOC_CSTRING(fname);
34
35
36 UNREFERENCED(o);
37 TCN_THROW_IF_ERR(apr_proc_mutex_create(&mutex, J2S(fname),
38 (apr_lockmech_e)mech, p), mutex);
39
40 cleanup:
41 TCN_FREE_CSTRING(fname);
42 return P2J(mutex);
43 }
44
45 TCN_IMPLEMENT_CALL(jlong, Lock, childInit)(TCN_STDARGS,
46 jstring fname,
47 jlong pool)
48 {
49 apr_pool_t *p = J2P(pool, apr_pool_t *);
50 apr_proc_mutex_t *mutex;
51 TCN_ALLOC_CSTRING(fname);
52
53
54 UNREFERENCED(o);
55 TCN_THROW_IF_ERR(apr_proc_mutex_child_init(&mutex,
56 J2S(fname), p), mutex);
57
58 cleanup:
59 TCN_FREE_CSTRING(fname);
60 return P2J(mutex);
61 }
62
63 TCN_IMPLEMENT_CALL(jint, Lock, lock)(TCN_STDARGS, jlong mutex)
64 {
65 apr_proc_mutex_t *m = J2P(mutex, apr_proc_mutex_t *);
66
67 UNREFERENCED_STDARGS;
68 return (jint)apr_proc_mutex_lock(m);
69 }
70
71 TCN_IMPLEMENT_CALL(jint, Lock, trylock)(TCN_STDARGS, jlong mutex)
72 {
73 apr_proc_mutex_t *m = J2P(mutex, apr_proc_mutex_t *);
74
75 UNREFERENCED_STDARGS;
76 return (jint)apr_proc_mutex_trylock(m);
77 }
78
79 TCN_IMPLEMENT_CALL(jint, Lock, unlock)(TCN_STDARGS, jlong mutex)
80 {
81 apr_proc_mutex_t *m = J2P(mutex, apr_proc_mutex_t *);
82
83 UNREFERENCED_STDARGS;
84 return (jint)apr_proc_mutex_unlock(m);
85 }
86
87 TCN_IMPLEMENT_CALL(jint, Lock, destroy)(TCN_STDARGS, jlong mutex)
88 {
89 apr_proc_mutex_t *m = J2P(mutex, apr_proc_mutex_t *);
90
91 UNREFERENCED_STDARGS;
92 return (jint)apr_proc_mutex_destroy(m);
93 }
94
95 #if 0
96 /* There is bug in APR implementing that function */
97 TCN_IMPLEMENT_CALL(jint, Lock, cleanup)(TCN_STDARGS, jlong mutex)
98 {
99 void *m = J2P(mutex, void *);
100
101 UNREFERENCED_STDARGS;
102 return (jint)apr_proc_mutex_cleanup(m);
103 }
104 #endif
105
106 TCN_IMPLEMENT_CALL(jstring, Lock, lockfile)(TCN_STDARGS, jlong mutex)
107 {
108 apr_proc_mutex_t *m = J2P(mutex, apr_proc_mutex_t *);
109 const char *s = apr_proc_mutex_lockfile(m);
110
111 UNREFERENCED_STDARGS;
112 if (s)
113 return AJP_TO_JSTRING(s);
114 else
115 return NULL;
116 }
117
118 TCN_IMPLEMENT_CALL(jstring, Lock, name)(TCN_STDARGS, jlong mutex)
119 {
120 apr_proc_mutex_t *m = J2P(mutex, apr_proc_mutex_t *);
121
122 UNREFERENCED(o);
123 return AJP_TO_JSTRING(apr_proc_mutex_name(m));
124 }
125
126 TCN_IMPLEMENT_CALL(jstring, Lock, defname)(TCN_STDARGS)
127 {
128
129 UNREFERENCED(o);
130 return AJP_TO_JSTRING(apr_proc_mutex_defname());
131 }
132
133
134
135 TCN_IMPLEMENT_CALL(jlong, Global, create)(TCN_STDARGS,
136 jstring fname,
137 jint mech, jlong pool)
138 {
139 apr_pool_t *p = J2P(pool, apr_pool_t *);
140 apr_global_mutex_t *mutex;
141 TCN_ALLOC_CSTRING(fname);
142
143
144 UNREFERENCED(o);
145 TCN_THROW_IF_ERR(apr_global_mutex_create(&mutex, J2S(fname),
146 (apr_lockmech_e)mech, p), mutex);
147
148 cleanup:
149 TCN_FREE_CSTRING(fname);
150 return P2J(mutex);
151 }
152
153 TCN_IMPLEMENT_CALL(jlong, Global, childInit)(TCN_STDARGS,
154 jstring fname,
155 jlong pool)
156 {
157 apr_pool_t *p = J2P(pool, apr_pool_t *);
158 apr_global_mutex_t *mutex;
159 TCN_ALLOC_CSTRING(fname);
160
161
162 UNREFERENCED(o);
163 TCN_THROW_IF_ERR(apr_global_mutex_child_init(&mutex,
164 J2S(fname), p), mutex);
165
166 cleanup:
167 TCN_FREE_CSTRING(fname);
168 return P2J(mutex);
169 }
170
171 TCN_IMPLEMENT_CALL(jint, Global, lock)(TCN_STDARGS, jlong mutex)
172 {
173 apr_global_mutex_t *m = J2P(mutex, apr_global_mutex_t *);
174
175 UNREFERENCED_STDARGS;
176 return (jint)apr_global_mutex_lock(m);
177 }
178
179 TCN_IMPLEMENT_CALL(jint, Global, trylock)(TCN_STDARGS, jlong mutex)
180 {
181 apr_global_mutex_t *m = J2P(mutex, apr_global_mutex_t *);
182
183 UNREFERENCED_STDARGS;
184 return (jint)apr_global_mutex_trylock(m);
185 }
186
187 TCN_IMPLEMENT_CALL(jint, Global, unlock)(TCN_STDARGS, jlong mutex)
188 {
189 apr_global_mutex_t *m = J2P(mutex, apr_global_mutex_t*);
190
191 UNREFERENCED_STDARGS;
192 return (jint)apr_global_mutex_unlock(m);
193 }
194
195 TCN_IMPLEMENT_CALL(jint, Global, destroy)(TCN_STDARGS, jlong mutex)
196 {
197 apr_global_mutex_t *m = J2P(mutex, apr_global_mutex_t *);
198
199 UNREFERENCED_STDARGS;
200 return (jint)apr_global_mutex_destroy(m);
201 }
202
OLDNEW
« no previous file with comments | « c/jnilib.c ('k') | c/misc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698