slyphon-zookeeper 0.8.4-java → 0.9.0-java

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,8 +1,18 @@
1
- v0.8.4 fix NameError, require 'forwardable'
2
-
3
- * Really not sure why this didn't come up in tests
1
+ v0.9.0 RELEASE THE KRAK..er, GIL!!
2
+
3
+ * In >= 1.9.2 the ruby interpreter allows you to release the GIL when
4
+ calling into native code, sounds like a good idea.
5
+
6
+ This release makes use of that code by parsing the zookeeper.h header file
7
+ and extracting the method signatures of all relevant zoo_* functions, then
8
+ generating boilerplate that allows us to call those functions via the
9
+ rb_thread_blocking_region function.
10
+
11
+ 1.8.7 compatibility is maintained by stubbing out that functionality if built
12
+ under 1.8.7.
4
13
 
5
- * issue here https://github.com/slyphon/zk/issues/22
14
+ * 1.8.7 is deprecated! I will continue to support 1.8.7 for the near future
15
+ but sometime soon, you're gonna have to upgrade.
6
16
 
7
17
  v0.8.3 fix NonLocalJump exception in event delivery thread shutdown code
8
18
 
data/Rakefile CHANGED
@@ -50,7 +50,7 @@ gemset_name = 'zookeeper'
50
50
  sh "rvm #{ruby_with_gemset} do bundle exec rspec spec --fail-fast"
51
51
  end
52
52
 
53
- task "mb:test_all_rubies" => rspec_task_name
53
+ task "mb:test_all" => rspec_task_name
54
54
  end
55
55
 
56
56
  namespace :build do
data/ext/Rakefile CHANGED
@@ -7,6 +7,28 @@ task :clean do
7
7
  end
8
8
  end
9
9
 
10
+ GENERATE_GVL_CODE_RB = 'generate_gvl_code.rb'
11
+
12
+ file 'c' do
13
+ if tarball = Dir['zkc-*.tar.gz'].first
14
+ sh "tar -zxf #{tarball}"
15
+ else
16
+ raise "couldn't find the tarball! wtf?!"
17
+ end
18
+ end
19
+
20
+ file GENERATE_GVL_CODE_RB => 'c'
21
+
22
+ file 'zkrb_wrapper.c' => GENERATE_GVL_CODE_RB do
23
+ sh "ruby generate_gvl_code.rb code"
24
+ end
25
+
26
+ file 'zkrb_wrapper.h' => GENERATE_GVL_CODE_RB do
27
+ sh "ruby generate_gvl_code.rb headers"
28
+ end
29
+
30
+ ZKRB_WRAPPER = %w[zkrb_wrapper.c zkrb_wrapper.h]
31
+
10
32
  task :clobber => :clean do
11
33
  rm_rf %w[Makefile c lib bin include]
12
34
  end
@@ -17,7 +39,7 @@ end
17
39
 
18
40
  file 'Makefile' => :build_zkc
19
41
 
20
- task :build => 'Makefile' do
42
+ task :build => [ZKRB_WRAPPER, 'Makefile'].flatten do
21
43
  sh 'make'
22
44
  end
23
45
 
data/ext/depend CHANGED
@@ -1,3 +1,5 @@
1
1
  zookeeper_lib.c: zookeeper_lib.h
2
- zookeeper_c.c: zookeeper_lib.c zookeeper_lib.h dbg.h
2
+ zkrb_wrapper_compat.c: zkrb_wrapper_compat.h
3
+ zkrb_wrapper.c: zkrb_wrapper_compat.c zkrb_wrapper.h
4
+ zookeeper_c.c: zookeeper_lib.c zookeeper_lib.h zkrb_wrapper.c zkrb_wrapper.h dbg.h
3
5
 
data/ext/extconf.rb CHANGED
@@ -19,6 +19,10 @@ $LDFLAGS = "#{$LDFLAGS}".gsub("$(ldflags)", "").gsub("-arch ppc", "")
19
19
  $CXXFLAGS = " -std=gnu++98 #{$CFLAGS}"
20
20
  $CPPFLAGS = $ARCH_FLAG = $DLDFLAGS = ""
21
21
 
22
+ if RUBY_VERSION == '1.8.7'
23
+ $CFLAGS << ' -DZKRB_RUBY_187'
24
+ end
25
+
22
26
  ZK_DEBUG = (ENV['DEBUG'] or ARGV.any? { |arg| arg == '--debug' })
23
27
  DEBUG_CFLAGS = " -O0 -ggdb3 -DHAVE_DEBUG"
24
28
 
@@ -0,0 +1,332 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ =begin
4
+ the idea here is to take each zoo_* function declaration in the header file, and turn it into
5
+ a calling arguments struct, a wrapper function and a macro for packing the values.
6
+
7
+ so for:
8
+
9
+ ZOOAPI int zoo_acreate(zhandle_t *zh, const char *path, const char *value,
10
+ int valuelen, const struct ACL_vector *acl, int flags,
11
+ string_completion_t completion, const void *data);
12
+
13
+ we want
14
+
15
+ typedef struct {
16
+ zhandle_t *zh;
17
+ const char *path;
18
+ const char *value;
19
+ int valuelen;
20
+ const struct ACL_vector *acl;
21
+ int flags;
22
+ string_completion_t completion;
23
+ const void *data;
24
+ } zkrb_zoo_acreate_args_t;
25
+
26
+ static VALUE zkrb_gvl_zoo_acreate(void *data) {
27
+ zkrb_zoo_acreate_args_t *a = (zkrb_zoo_acreate_args_t *)data;
28
+
29
+ a->rc = zoo_acreate(a->zh, a->path, a->value, a->valuelen, a->acl, a->flags, a->completion, a->data);
30
+
31
+ return Qnil;
32
+ }
33
+
34
+ static int zkrb_call_zoo_acreate(zhandle_t *zh, const char *path, const char *value,
35
+ int valuelen, const struct ACL_vector *acl, int flags,
36
+ string_completion_t completion, const void *data) {
37
+
38
+ int rc;
39
+ zkrb_zoo_acreate_args_t *ptr = malloc(sizeof(zkrb_zoo_acreate_args_t));
40
+ check_mem(ptr);
41
+
42
+ ptr->rc = 0;
43
+ ptr->zh = zh;
44
+ ptr->path = path;
45
+ ptr->value = value;
46
+ ptr->valuelen = valuelen;
47
+ ptr->acl = acl;
48
+ ptr->flags = flags;
49
+ ptr->completion = completion;
50
+ ptr->data = data;
51
+
52
+ rb_thread_blocking_region(zkrb_gvl_zoo_acreate, (void *)ptr, RUBY_UBF_IO, 0);
53
+
54
+ rc = ptr->rc;
55
+ free(ptr);
56
+ return rc;
57
+
58
+ error:
59
+ free(ptr);
60
+ return -1;
61
+ }
62
+
63
+ =end
64
+
65
+ REGEXP = /^ZOOAPI int (zoo_[^(]+)\(([^)]+)\);$/m
66
+
67
+ require 'forwardable'
68
+ require 'stringio'
69
+
70
+ ZKRB_WRAPPER_H_PATH = File.expand_path('../zkrb_wrapper.h', __FILE__)
71
+ ZKRB_WRAPPER_C_PATH = File.expand_path('../zkrb_wrapper.c', __FILE__)
72
+
73
+ # the struct that holds the call args for zoo_fn_name
74
+ class CallStruct
75
+ attr_reader :zoo_fn_name, :typed_args, :name
76
+
77
+ def initialize(zoo_fn_name, typed_args)
78
+ @zoo_fn_name, @typed_args = zoo_fn_name, typed_args
79
+ @name = "zkrb_#{zoo_fn_name}_args_t"
80
+ end
81
+
82
+ def body
83
+ @body ||= (
84
+ lines = ["typedef struct {"]
85
+ lines += typed_args.map{|n| " #{n};"}
86
+ lines << " int rc;"
87
+ lines << "} #{name};"
88
+ lines.join("\n")
89
+ )
90
+ end
91
+ end
92
+
93
+ module MemberNames
94
+ def member_names
95
+ @member_names ||= typed_args.map { |n| n.split(/[ *]/).last }
96
+ end
97
+ end
98
+
99
+ # the zkrb_gvl_zoo_* function
100
+ class WrapperFunction
101
+ extend Forwardable
102
+ include MemberNames
103
+
104
+ PREFIX = 'zkrb_gvl'
105
+
106
+ def_delegators :struct, :typed_args
107
+
108
+ attr_reader :struct, :name, :zoo_fn_name
109
+
110
+ def initialize(zoo_fn_name, struct)
111
+ @zoo_fn_name = zoo_fn_name
112
+ @struct = struct
113
+ @name = "#{PREFIX}_#{zoo_fn_name}"
114
+ end
115
+
116
+ def fn_signature
117
+ @fn_signature ||= "static VALUE #{name}(void *data)"
118
+ end
119
+
120
+ def body
121
+ @body ||= (
122
+ lines = ["#{fn_signature} {"]
123
+ lines << " #{struct.name} *a = (#{struct.name} *)data;"
124
+
125
+ funcall = " a->rc = #{zoo_fn_name}("
126
+ funcall << member_names.map { |m| "a->#{m}" }.join(', ')
127
+ funcall << ');'
128
+
129
+ lines << funcall
130
+
131
+ lines << " return Qnil;"
132
+ lines << "}"
133
+ lines.join("\n")
134
+ )
135
+ end
136
+ end
137
+
138
+ # the zkrb_call_zoo_* function
139
+ class CallingFunction
140
+ extend Forwardable
141
+ include MemberNames
142
+
143
+ PREFIX = 'zkrb_call'
144
+
145
+ def_delegators :struct, :typed_args
146
+
147
+ attr_reader :struct, :wrapper_fn, :zoo_fn_name, :name
148
+
149
+ def initialize(zoo_fn_name, struct, wrapper_fn)
150
+ @zoo_fn_name, @struct, @wrapper_fn = zoo_fn_name, struct, wrapper_fn
151
+
152
+ @name = "#{PREFIX}_#{zoo_fn_name}"
153
+ end
154
+
155
+ def fn_signature
156
+ @fn_signature ||= "int #{name}(#{typed_args.join(', ')})"
157
+ end
158
+
159
+ def ptr_lines
160
+ @ptr_lines = (
161
+ lines = ["ptr->rc = rc;"]
162
+ lines += member_names.map { |n| "ptr->#{n} = #{n};" }
163
+ lines.map! { |n| " #{n}" }
164
+ lines.join("\n")
165
+ )
166
+ end
167
+
168
+ def top
169
+ <<-EOS
170
+ // wrapper that calls #{zoo_fn_name} via #{wrapper_fn.name} inside rb_thread_blocking_region
171
+ #{fn_signature} {
172
+ int rc = ZKRB_FAIL;
173
+ #{struct.name} *ptr = malloc(sizeof(#{struct.name}));
174
+ check_mem(ptr);
175
+ EOS
176
+ end
177
+
178
+ def rb_thread_blocking_region_call
179
+ " zkrb_thread_blocking_region(#{wrapper_fn.name}, (void *)ptr);"
180
+ end
181
+
182
+ def bottom
183
+ <<-EOS
184
+
185
+ rc = ptr->rc;
186
+
187
+ error:
188
+ free(ptr);
189
+ return rc;
190
+ }
191
+ EOS
192
+ end
193
+
194
+ def body
195
+ @body ||= [top, ptr_lines, nil, rb_thread_blocking_region_call, bottom].join("\n")
196
+ end
197
+ end
198
+
199
+ class GeneratedCode < Struct.new(:structs, :wrapper_fns, :calling_fns)
200
+ def initialize(*a)
201
+ super
202
+
203
+ self.structs ||= []
204
+ self.wrapper_fns ||= []
205
+ self.calling_fns ||= []
206
+ end
207
+
208
+ def self.from_zookeeper_h(text)
209
+ new.tap do |code|
210
+ while true
211
+ break unless text =~ REGEXP
212
+ zoo_fn_name, argstr = $1
213
+ argstr = $2
214
+
215
+ typed_args = argstr.split(',').map(&:strip)
216
+
217
+ # gah, fix up zoo_aset_acl which has a void_completion_t with no name assigned
218
+ if zoo_fn_name == 'zoo_aset_acl'
219
+ if idx = typed_args.index('void_completion_t')
220
+ typed_args[idx] = 'void_completion_t completion'
221
+ end
222
+ end
223
+
224
+ struct = CallStruct.new(zoo_fn_name, typed_args)
225
+ wrapper_fn = WrapperFunction.new(zoo_fn_name, struct)
226
+ calling_fn = CallingFunction.new(zoo_fn_name, struct, wrapper_fn)
227
+
228
+ code.structs << struct
229
+ code.wrapper_fns << wrapper_fn
230
+ code.calling_fns << calling_fn
231
+
232
+ text = $~.post_match
233
+ end
234
+ end
235
+ end
236
+ end
237
+
238
+ def render_header_file(code)
239
+ StringIO.new('zkrb_wrapper.h', 'w').tap do |fp|
240
+ fp.puts <<-EOS
241
+ #ifndef ZKRB_WRAPPER_H
242
+ #define ZKRB_WRAPPER_H
243
+ #if 0
244
+
245
+ AUTOGENERATED BY #{File.basename(__FILE__)}
246
+
247
+ #endif
248
+
249
+ #include "ruby.h"
250
+ #include "c-client-src/zookeeper.h"
251
+ #include "zkrb_wrapper_compat.h"
252
+ #include "dbg.h"
253
+
254
+ #define ZKRB_FAIL -1
255
+
256
+ EOS
257
+
258
+ code.structs.each do |struct|
259
+ fp.puts(struct.body)
260
+ fp.puts
261
+ end
262
+
263
+ code.calling_fns.each do |cf|
264
+ fp.puts "#{cf.fn_signature};"
265
+ end
266
+
267
+ fp.puts <<-EOS
268
+
269
+ #endif /* ZKRB_WRAPPER_H */
270
+ EOS
271
+
272
+ end.string
273
+ end
274
+
275
+ def render_c_file(code)
276
+ StringIO.new('zkrb_wrapper.c', 'w').tap do |fp|
277
+ fp.puts <<-EOS
278
+ /*
279
+
280
+ Autogenerated boilerplate wrappers around zoo_* function calls necessary for using
281
+ rb_thread_blocking_region to release the GIL when calling native code.
282
+
283
+ generated by ext/#{File.basename(__FILE__)}
284
+
285
+ */
286
+
287
+ #include "ruby.h"
288
+ #include "zkrb_wrapper.h"
289
+ #include <errno.h>
290
+ #include <stdio.h>
291
+ #include <stdlib.h>
292
+
293
+ EOS
294
+
295
+ code.wrapper_fns.zip(code.calling_fns) do |wrap_fn, call_fn|
296
+ fp.puts "#{wrap_fn.body}\n\n"
297
+ fp.puts "#{call_fn.body}\n\n"
298
+ end
299
+
300
+ end.string
301
+ end
302
+
303
+
304
+ def help!
305
+ $stderr.puts "usage: #{File.basename(__FILE__)} {all|headers|code}"
306
+ exit 1
307
+ end
308
+
309
+ def main
310
+ help! if ARGV.empty?
311
+
312
+ text = File.read('c/include/zookeeper.h')
313
+ code = GeneratedCode.from_zookeeper_h(text)
314
+
315
+ cmd = ARGV.first
316
+
317
+ help! unless %w[headers all code].include?(cmd)
318
+
319
+ if %w[headers all].include?(cmd)
320
+ $stderr.puts "writing #{ZKRB_WRAPPER_H_PATH}"
321
+ File.open(ZKRB_WRAPPER_H_PATH, 'w') { |fp| fp.write(render_header_file(code)) }
322
+ end
323
+
324
+ if %w[code all].include?(cmd)
325
+ $stderr.puts "writing #{ZKRB_WRAPPER_C_PATH}"
326
+ File.open(ZKRB_WRAPPER_C_PATH, 'w') { |fp| fp.write(render_c_file(code)) }
327
+ end
328
+
329
+ end
330
+
331
+ main
332
+
@@ -0,0 +1,917 @@
1
+ /*
2
+
3
+ Autogenerated boilerplate wrappers around zoo_* function calls necessary for using
4
+ rb_thread_blocking_region to release the GIL when calling native code.
5
+
6
+ generated by ext/generate_gvl_code.rb
7
+
8
+ */
9
+
10
+ #include "ruby.h"
11
+ #include "zkrb_wrapper.h"
12
+ #include <errno.h>
13
+ #include <stdio.h>
14
+ #include <stdlib.h>
15
+
16
+ static VALUE zkrb_gvl_zoo_recv_timeout(void *data) {
17
+ zkrb_zoo_recv_timeout_args_t *a = (zkrb_zoo_recv_timeout_args_t *)data;
18
+ a->rc = zoo_recv_timeout(a->zh);
19
+ return Qnil;
20
+ }
21
+
22
+ // wrapper that calls zoo_recv_timeout via zkrb_gvl_zoo_recv_timeout inside rb_thread_blocking_region
23
+ int zkrb_call_zoo_recv_timeout(zhandle_t *zh) {
24
+ int rc = ZKRB_FAIL;
25
+ zkrb_zoo_recv_timeout_args_t *ptr = malloc(sizeof(zkrb_zoo_recv_timeout_args_t));
26
+ check_mem(ptr);
27
+
28
+ ptr->rc = rc;
29
+ ptr->zh = zh;
30
+
31
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_recv_timeout, (void *)ptr);
32
+
33
+ rc = ptr->rc;
34
+
35
+ error:
36
+ free(ptr);
37
+ return rc;
38
+ }
39
+
40
+
41
+ static VALUE zkrb_gvl_zoo_state(void *data) {
42
+ zkrb_zoo_state_args_t *a = (zkrb_zoo_state_args_t *)data;
43
+ a->rc = zoo_state(a->zh);
44
+ return Qnil;
45
+ }
46
+
47
+ // wrapper that calls zoo_state via zkrb_gvl_zoo_state inside rb_thread_blocking_region
48
+ int zkrb_call_zoo_state(zhandle_t *zh) {
49
+ int rc = ZKRB_FAIL;
50
+ zkrb_zoo_state_args_t *ptr = malloc(sizeof(zkrb_zoo_state_args_t));
51
+ check_mem(ptr);
52
+
53
+ ptr->rc = rc;
54
+ ptr->zh = zh;
55
+
56
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_state, (void *)ptr);
57
+
58
+ rc = ptr->rc;
59
+
60
+ error:
61
+ free(ptr);
62
+ return rc;
63
+ }
64
+
65
+
66
+ static VALUE zkrb_gvl_zoo_acreate(void *data) {
67
+ zkrb_zoo_acreate_args_t *a = (zkrb_zoo_acreate_args_t *)data;
68
+ a->rc = zoo_acreate(a->zh, a->path, a->value, a->valuelen, a->acl, a->flags, a->completion, a->data);
69
+ return Qnil;
70
+ }
71
+
72
+ // wrapper that calls zoo_acreate via zkrb_gvl_zoo_acreate inside rb_thread_blocking_region
73
+ int zkrb_call_zoo_acreate(zhandle_t *zh, const char *path, const char *value, int valuelen, const struct ACL_vector *acl, int flags, string_completion_t completion, const void *data) {
74
+ int rc = ZKRB_FAIL;
75
+ zkrb_zoo_acreate_args_t *ptr = malloc(sizeof(zkrb_zoo_acreate_args_t));
76
+ check_mem(ptr);
77
+
78
+ ptr->rc = rc;
79
+ ptr->zh = zh;
80
+ ptr->path = path;
81
+ ptr->value = value;
82
+ ptr->valuelen = valuelen;
83
+ ptr->acl = acl;
84
+ ptr->flags = flags;
85
+ ptr->completion = completion;
86
+ ptr->data = data;
87
+
88
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_acreate, (void *)ptr);
89
+
90
+ rc = ptr->rc;
91
+
92
+ error:
93
+ free(ptr);
94
+ return rc;
95
+ }
96
+
97
+
98
+ static VALUE zkrb_gvl_zoo_adelete(void *data) {
99
+ zkrb_zoo_adelete_args_t *a = (zkrb_zoo_adelete_args_t *)data;
100
+ a->rc = zoo_adelete(a->zh, a->path, a->version, a->completion, a->data);
101
+ return Qnil;
102
+ }
103
+
104
+ // wrapper that calls zoo_adelete via zkrb_gvl_zoo_adelete inside rb_thread_blocking_region
105
+ int zkrb_call_zoo_adelete(zhandle_t *zh, const char *path, int version, void_completion_t completion, const void *data) {
106
+ int rc = ZKRB_FAIL;
107
+ zkrb_zoo_adelete_args_t *ptr = malloc(sizeof(zkrb_zoo_adelete_args_t));
108
+ check_mem(ptr);
109
+
110
+ ptr->rc = rc;
111
+ ptr->zh = zh;
112
+ ptr->path = path;
113
+ ptr->version = version;
114
+ ptr->completion = completion;
115
+ ptr->data = data;
116
+
117
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_adelete, (void *)ptr);
118
+
119
+ rc = ptr->rc;
120
+
121
+ error:
122
+ free(ptr);
123
+ return rc;
124
+ }
125
+
126
+
127
+ static VALUE zkrb_gvl_zoo_aexists(void *data) {
128
+ zkrb_zoo_aexists_args_t *a = (zkrb_zoo_aexists_args_t *)data;
129
+ a->rc = zoo_aexists(a->zh, a->path, a->watch, a->completion, a->data);
130
+ return Qnil;
131
+ }
132
+
133
+ // wrapper that calls zoo_aexists via zkrb_gvl_zoo_aexists inside rb_thread_blocking_region
134
+ int zkrb_call_zoo_aexists(zhandle_t *zh, const char *path, int watch, stat_completion_t completion, const void *data) {
135
+ int rc = ZKRB_FAIL;
136
+ zkrb_zoo_aexists_args_t *ptr = malloc(sizeof(zkrb_zoo_aexists_args_t));
137
+ check_mem(ptr);
138
+
139
+ ptr->rc = rc;
140
+ ptr->zh = zh;
141
+ ptr->path = path;
142
+ ptr->watch = watch;
143
+ ptr->completion = completion;
144
+ ptr->data = data;
145
+
146
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aexists, (void *)ptr);
147
+
148
+ rc = ptr->rc;
149
+
150
+ error:
151
+ free(ptr);
152
+ return rc;
153
+ }
154
+
155
+
156
+ static VALUE zkrb_gvl_zoo_awexists(void *data) {
157
+ zkrb_zoo_awexists_args_t *a = (zkrb_zoo_awexists_args_t *)data;
158
+ a->rc = zoo_awexists(a->zh, a->path, a->watcher, a->watcherCtx, a->completion, a->data);
159
+ return Qnil;
160
+ }
161
+
162
+ // wrapper that calls zoo_awexists via zkrb_gvl_zoo_awexists inside rb_thread_blocking_region
163
+ int zkrb_call_zoo_awexists(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, stat_completion_t completion, const void *data) {
164
+ int rc = ZKRB_FAIL;
165
+ zkrb_zoo_awexists_args_t *ptr = malloc(sizeof(zkrb_zoo_awexists_args_t));
166
+ check_mem(ptr);
167
+
168
+ ptr->rc = rc;
169
+ ptr->zh = zh;
170
+ ptr->path = path;
171
+ ptr->watcher = watcher;
172
+ ptr->watcherCtx = watcherCtx;
173
+ ptr->completion = completion;
174
+ ptr->data = data;
175
+
176
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_awexists, (void *)ptr);
177
+
178
+ rc = ptr->rc;
179
+
180
+ error:
181
+ free(ptr);
182
+ return rc;
183
+ }
184
+
185
+
186
+ static VALUE zkrb_gvl_zoo_aget(void *data) {
187
+ zkrb_zoo_aget_args_t *a = (zkrb_zoo_aget_args_t *)data;
188
+ a->rc = zoo_aget(a->zh, a->path, a->watch, a->completion, a->data);
189
+ return Qnil;
190
+ }
191
+
192
+ // wrapper that calls zoo_aget via zkrb_gvl_zoo_aget inside rb_thread_blocking_region
193
+ int zkrb_call_zoo_aget(zhandle_t *zh, const char *path, int watch, data_completion_t completion, const void *data) {
194
+ int rc = ZKRB_FAIL;
195
+ zkrb_zoo_aget_args_t *ptr = malloc(sizeof(zkrb_zoo_aget_args_t));
196
+ check_mem(ptr);
197
+
198
+ ptr->rc = rc;
199
+ ptr->zh = zh;
200
+ ptr->path = path;
201
+ ptr->watch = watch;
202
+ ptr->completion = completion;
203
+ ptr->data = data;
204
+
205
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aget, (void *)ptr);
206
+
207
+ rc = ptr->rc;
208
+
209
+ error:
210
+ free(ptr);
211
+ return rc;
212
+ }
213
+
214
+
215
+ static VALUE zkrb_gvl_zoo_awget(void *data) {
216
+ zkrb_zoo_awget_args_t *a = (zkrb_zoo_awget_args_t *)data;
217
+ a->rc = zoo_awget(a->zh, a->path, a->watcher, a->watcherCtx, a->completion, a->data);
218
+ return Qnil;
219
+ }
220
+
221
+ // wrapper that calls zoo_awget via zkrb_gvl_zoo_awget inside rb_thread_blocking_region
222
+ int zkrb_call_zoo_awget(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, data_completion_t completion, const void *data) {
223
+ int rc = ZKRB_FAIL;
224
+ zkrb_zoo_awget_args_t *ptr = malloc(sizeof(zkrb_zoo_awget_args_t));
225
+ check_mem(ptr);
226
+
227
+ ptr->rc = rc;
228
+ ptr->zh = zh;
229
+ ptr->path = path;
230
+ ptr->watcher = watcher;
231
+ ptr->watcherCtx = watcherCtx;
232
+ ptr->completion = completion;
233
+ ptr->data = data;
234
+
235
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_awget, (void *)ptr);
236
+
237
+ rc = ptr->rc;
238
+
239
+ error:
240
+ free(ptr);
241
+ return rc;
242
+ }
243
+
244
+
245
+ static VALUE zkrb_gvl_zoo_aset(void *data) {
246
+ zkrb_zoo_aset_args_t *a = (zkrb_zoo_aset_args_t *)data;
247
+ a->rc = zoo_aset(a->zh, a->path, a->buffer, a->buflen, a->version, a->completion, a->data);
248
+ return Qnil;
249
+ }
250
+
251
+ // wrapper that calls zoo_aset via zkrb_gvl_zoo_aset inside rb_thread_blocking_region
252
+ int zkrb_call_zoo_aset(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version, stat_completion_t completion, const void *data) {
253
+ int rc = ZKRB_FAIL;
254
+ zkrb_zoo_aset_args_t *ptr = malloc(sizeof(zkrb_zoo_aset_args_t));
255
+ check_mem(ptr);
256
+
257
+ ptr->rc = rc;
258
+ ptr->zh = zh;
259
+ ptr->path = path;
260
+ ptr->buffer = buffer;
261
+ ptr->buflen = buflen;
262
+ ptr->version = version;
263
+ ptr->completion = completion;
264
+ ptr->data = data;
265
+
266
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aset, (void *)ptr);
267
+
268
+ rc = ptr->rc;
269
+
270
+ error:
271
+ free(ptr);
272
+ return rc;
273
+ }
274
+
275
+
276
+ static VALUE zkrb_gvl_zoo_aget_children(void *data) {
277
+ zkrb_zoo_aget_children_args_t *a = (zkrb_zoo_aget_children_args_t *)data;
278
+ a->rc = zoo_aget_children(a->zh, a->path, a->watch, a->completion, a->data);
279
+ return Qnil;
280
+ }
281
+
282
+ // wrapper that calls zoo_aget_children via zkrb_gvl_zoo_aget_children inside rb_thread_blocking_region
283
+ int zkrb_call_zoo_aget_children(zhandle_t *zh, const char *path, int watch, strings_completion_t completion, const void *data) {
284
+ int rc = ZKRB_FAIL;
285
+ zkrb_zoo_aget_children_args_t *ptr = malloc(sizeof(zkrb_zoo_aget_children_args_t));
286
+ check_mem(ptr);
287
+
288
+ ptr->rc = rc;
289
+ ptr->zh = zh;
290
+ ptr->path = path;
291
+ ptr->watch = watch;
292
+ ptr->completion = completion;
293
+ ptr->data = data;
294
+
295
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aget_children, (void *)ptr);
296
+
297
+ rc = ptr->rc;
298
+
299
+ error:
300
+ free(ptr);
301
+ return rc;
302
+ }
303
+
304
+
305
+ static VALUE zkrb_gvl_zoo_awget_children(void *data) {
306
+ zkrb_zoo_awget_children_args_t *a = (zkrb_zoo_awget_children_args_t *)data;
307
+ a->rc = zoo_awget_children(a->zh, a->path, a->watcher, a->watcherCtx, a->completion, a->data);
308
+ return Qnil;
309
+ }
310
+
311
+ // wrapper that calls zoo_awget_children via zkrb_gvl_zoo_awget_children inside rb_thread_blocking_region
312
+ int zkrb_call_zoo_awget_children(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, strings_completion_t completion, const void *data) {
313
+ int rc = ZKRB_FAIL;
314
+ zkrb_zoo_awget_children_args_t *ptr = malloc(sizeof(zkrb_zoo_awget_children_args_t));
315
+ check_mem(ptr);
316
+
317
+ ptr->rc = rc;
318
+ ptr->zh = zh;
319
+ ptr->path = path;
320
+ ptr->watcher = watcher;
321
+ ptr->watcherCtx = watcherCtx;
322
+ ptr->completion = completion;
323
+ ptr->data = data;
324
+
325
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_awget_children, (void *)ptr);
326
+
327
+ rc = ptr->rc;
328
+
329
+ error:
330
+ free(ptr);
331
+ return rc;
332
+ }
333
+
334
+
335
+ static VALUE zkrb_gvl_zoo_aget_children2(void *data) {
336
+ zkrb_zoo_aget_children2_args_t *a = (zkrb_zoo_aget_children2_args_t *)data;
337
+ a->rc = zoo_aget_children2(a->zh, a->path, a->watch, a->completion, a->data);
338
+ return Qnil;
339
+ }
340
+
341
+ // wrapper that calls zoo_aget_children2 via zkrb_gvl_zoo_aget_children2 inside rb_thread_blocking_region
342
+ int zkrb_call_zoo_aget_children2(zhandle_t *zh, const char *path, int watch, strings_stat_completion_t completion, const void *data) {
343
+ int rc = ZKRB_FAIL;
344
+ zkrb_zoo_aget_children2_args_t *ptr = malloc(sizeof(zkrb_zoo_aget_children2_args_t));
345
+ check_mem(ptr);
346
+
347
+ ptr->rc = rc;
348
+ ptr->zh = zh;
349
+ ptr->path = path;
350
+ ptr->watch = watch;
351
+ ptr->completion = completion;
352
+ ptr->data = data;
353
+
354
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aget_children2, (void *)ptr);
355
+
356
+ rc = ptr->rc;
357
+
358
+ error:
359
+ free(ptr);
360
+ return rc;
361
+ }
362
+
363
+
364
+ static VALUE zkrb_gvl_zoo_awget_children2(void *data) {
365
+ zkrb_zoo_awget_children2_args_t *a = (zkrb_zoo_awget_children2_args_t *)data;
366
+ a->rc = zoo_awget_children2(a->zh, a->path, a->watcher, a->watcherCtx, a->completion, a->data);
367
+ return Qnil;
368
+ }
369
+
370
+ // wrapper that calls zoo_awget_children2 via zkrb_gvl_zoo_awget_children2 inside rb_thread_blocking_region
371
+ int zkrb_call_zoo_awget_children2(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, strings_stat_completion_t completion, const void *data) {
372
+ int rc = ZKRB_FAIL;
373
+ zkrb_zoo_awget_children2_args_t *ptr = malloc(sizeof(zkrb_zoo_awget_children2_args_t));
374
+ check_mem(ptr);
375
+
376
+ ptr->rc = rc;
377
+ ptr->zh = zh;
378
+ ptr->path = path;
379
+ ptr->watcher = watcher;
380
+ ptr->watcherCtx = watcherCtx;
381
+ ptr->completion = completion;
382
+ ptr->data = data;
383
+
384
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_awget_children2, (void *)ptr);
385
+
386
+ rc = ptr->rc;
387
+
388
+ error:
389
+ free(ptr);
390
+ return rc;
391
+ }
392
+
393
+
394
+ static VALUE zkrb_gvl_zoo_async(void *data) {
395
+ zkrb_zoo_async_args_t *a = (zkrb_zoo_async_args_t *)data;
396
+ a->rc = zoo_async(a->zh, a->path, a->completion, a->data);
397
+ return Qnil;
398
+ }
399
+
400
+ // wrapper that calls zoo_async via zkrb_gvl_zoo_async inside rb_thread_blocking_region
401
+ int zkrb_call_zoo_async(zhandle_t *zh, const char *path, string_completion_t completion, const void *data) {
402
+ int rc = ZKRB_FAIL;
403
+ zkrb_zoo_async_args_t *ptr = malloc(sizeof(zkrb_zoo_async_args_t));
404
+ check_mem(ptr);
405
+
406
+ ptr->rc = rc;
407
+ ptr->zh = zh;
408
+ ptr->path = path;
409
+ ptr->completion = completion;
410
+ ptr->data = data;
411
+
412
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_async, (void *)ptr);
413
+
414
+ rc = ptr->rc;
415
+
416
+ error:
417
+ free(ptr);
418
+ return rc;
419
+ }
420
+
421
+
422
+ static VALUE zkrb_gvl_zoo_aget_acl(void *data) {
423
+ zkrb_zoo_aget_acl_args_t *a = (zkrb_zoo_aget_acl_args_t *)data;
424
+ a->rc = zoo_aget_acl(a->zh, a->path, a->completion, a->data);
425
+ return Qnil;
426
+ }
427
+
428
+ // wrapper that calls zoo_aget_acl via zkrb_gvl_zoo_aget_acl inside rb_thread_blocking_region
429
+ int zkrb_call_zoo_aget_acl(zhandle_t *zh, const char *path, acl_completion_t completion, const void *data) {
430
+ int rc = ZKRB_FAIL;
431
+ zkrb_zoo_aget_acl_args_t *ptr = malloc(sizeof(zkrb_zoo_aget_acl_args_t));
432
+ check_mem(ptr);
433
+
434
+ ptr->rc = rc;
435
+ ptr->zh = zh;
436
+ ptr->path = path;
437
+ ptr->completion = completion;
438
+ ptr->data = data;
439
+
440
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aget_acl, (void *)ptr);
441
+
442
+ rc = ptr->rc;
443
+
444
+ error:
445
+ free(ptr);
446
+ return rc;
447
+ }
448
+
449
+
450
+ static VALUE zkrb_gvl_zoo_aset_acl(void *data) {
451
+ zkrb_zoo_aset_acl_args_t *a = (zkrb_zoo_aset_acl_args_t *)data;
452
+ a->rc = zoo_aset_acl(a->zh, a->path, a->version, a->acl, a->completion, a->data);
453
+ return Qnil;
454
+ }
455
+
456
+ // wrapper that calls zoo_aset_acl via zkrb_gvl_zoo_aset_acl inside rb_thread_blocking_region
457
+ int zkrb_call_zoo_aset_acl(zhandle_t *zh, const char *path, int version, struct ACL_vector *acl, void_completion_t completion, const void *data) {
458
+ int rc = ZKRB_FAIL;
459
+ zkrb_zoo_aset_acl_args_t *ptr = malloc(sizeof(zkrb_zoo_aset_acl_args_t));
460
+ check_mem(ptr);
461
+
462
+ ptr->rc = rc;
463
+ ptr->zh = zh;
464
+ ptr->path = path;
465
+ ptr->version = version;
466
+ ptr->acl = acl;
467
+ ptr->completion = completion;
468
+ ptr->data = data;
469
+
470
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aset_acl, (void *)ptr);
471
+
472
+ rc = ptr->rc;
473
+
474
+ error:
475
+ free(ptr);
476
+ return rc;
477
+ }
478
+
479
+
480
+ static VALUE zkrb_gvl_zoo_add_auth(void *data) {
481
+ zkrb_zoo_add_auth_args_t *a = (zkrb_zoo_add_auth_args_t *)data;
482
+ a->rc = zoo_add_auth(a->zh, a->scheme, a->cert, a->certLen, a->completion, a->data);
483
+ return Qnil;
484
+ }
485
+
486
+ // wrapper that calls zoo_add_auth via zkrb_gvl_zoo_add_auth inside rb_thread_blocking_region
487
+ int zkrb_call_zoo_add_auth(zhandle_t *zh, const char* scheme, const char* cert, int certLen, void_completion_t completion, const void *data) {
488
+ int rc = ZKRB_FAIL;
489
+ zkrb_zoo_add_auth_args_t *ptr = malloc(sizeof(zkrb_zoo_add_auth_args_t));
490
+ check_mem(ptr);
491
+
492
+ ptr->rc = rc;
493
+ ptr->zh = zh;
494
+ ptr->scheme = scheme;
495
+ ptr->cert = cert;
496
+ ptr->certLen = certLen;
497
+ ptr->completion = completion;
498
+ ptr->data = data;
499
+
500
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_add_auth, (void *)ptr);
501
+
502
+ rc = ptr->rc;
503
+
504
+ error:
505
+ free(ptr);
506
+ return rc;
507
+ }
508
+
509
+
510
+ static VALUE zkrb_gvl_zoo_create(void *data) {
511
+ zkrb_zoo_create_args_t *a = (zkrb_zoo_create_args_t *)data;
512
+ a->rc = zoo_create(a->zh, a->path, a->value, a->valuelen, a->acl, a->flags, a->path_buffer, a->path_buffer_len);
513
+ return Qnil;
514
+ }
515
+
516
+ // wrapper that calls zoo_create via zkrb_gvl_zoo_create inside rb_thread_blocking_region
517
+ int zkrb_call_zoo_create(zhandle_t *zh, const char *path, const char *value, int valuelen, const struct ACL_vector *acl, int flags, char *path_buffer, int path_buffer_len) {
518
+ int rc = ZKRB_FAIL;
519
+ zkrb_zoo_create_args_t *ptr = malloc(sizeof(zkrb_zoo_create_args_t));
520
+ check_mem(ptr);
521
+
522
+ ptr->rc = rc;
523
+ ptr->zh = zh;
524
+ ptr->path = path;
525
+ ptr->value = value;
526
+ ptr->valuelen = valuelen;
527
+ ptr->acl = acl;
528
+ ptr->flags = flags;
529
+ ptr->path_buffer = path_buffer;
530
+ ptr->path_buffer_len = path_buffer_len;
531
+
532
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_create, (void *)ptr);
533
+
534
+ rc = ptr->rc;
535
+
536
+ error:
537
+ free(ptr);
538
+ return rc;
539
+ }
540
+
541
+
542
+ static VALUE zkrb_gvl_zoo_delete(void *data) {
543
+ zkrb_zoo_delete_args_t *a = (zkrb_zoo_delete_args_t *)data;
544
+ a->rc = zoo_delete(a->zh, a->path, a->version);
545
+ return Qnil;
546
+ }
547
+
548
+ // wrapper that calls zoo_delete via zkrb_gvl_zoo_delete inside rb_thread_blocking_region
549
+ int zkrb_call_zoo_delete(zhandle_t *zh, const char *path, int version) {
550
+ int rc = ZKRB_FAIL;
551
+ zkrb_zoo_delete_args_t *ptr = malloc(sizeof(zkrb_zoo_delete_args_t));
552
+ check_mem(ptr);
553
+
554
+ ptr->rc = rc;
555
+ ptr->zh = zh;
556
+ ptr->path = path;
557
+ ptr->version = version;
558
+
559
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_delete, (void *)ptr);
560
+
561
+ rc = ptr->rc;
562
+
563
+ error:
564
+ free(ptr);
565
+ return rc;
566
+ }
567
+
568
+
569
+ static VALUE zkrb_gvl_zoo_exists(void *data) {
570
+ zkrb_zoo_exists_args_t *a = (zkrb_zoo_exists_args_t *)data;
571
+ a->rc = zoo_exists(a->zh, a->path, a->watch, a->stat);
572
+ return Qnil;
573
+ }
574
+
575
+ // wrapper that calls zoo_exists via zkrb_gvl_zoo_exists inside rb_thread_blocking_region
576
+ int zkrb_call_zoo_exists(zhandle_t *zh, const char *path, int watch, struct Stat *stat) {
577
+ int rc = ZKRB_FAIL;
578
+ zkrb_zoo_exists_args_t *ptr = malloc(sizeof(zkrb_zoo_exists_args_t));
579
+ check_mem(ptr);
580
+
581
+ ptr->rc = rc;
582
+ ptr->zh = zh;
583
+ ptr->path = path;
584
+ ptr->watch = watch;
585
+ ptr->stat = stat;
586
+
587
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_exists, (void *)ptr);
588
+
589
+ rc = ptr->rc;
590
+
591
+ error:
592
+ free(ptr);
593
+ return rc;
594
+ }
595
+
596
+
597
+ static VALUE zkrb_gvl_zoo_wexists(void *data) {
598
+ zkrb_zoo_wexists_args_t *a = (zkrb_zoo_wexists_args_t *)data;
599
+ a->rc = zoo_wexists(a->zh, a->path, a->watcher, a->watcherCtx, a->stat);
600
+ return Qnil;
601
+ }
602
+
603
+ // wrapper that calls zoo_wexists via zkrb_gvl_zoo_wexists inside rb_thread_blocking_region
604
+ int zkrb_call_zoo_wexists(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, struct Stat *stat) {
605
+ int rc = ZKRB_FAIL;
606
+ zkrb_zoo_wexists_args_t *ptr = malloc(sizeof(zkrb_zoo_wexists_args_t));
607
+ check_mem(ptr);
608
+
609
+ ptr->rc = rc;
610
+ ptr->zh = zh;
611
+ ptr->path = path;
612
+ ptr->watcher = watcher;
613
+ ptr->watcherCtx = watcherCtx;
614
+ ptr->stat = stat;
615
+
616
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_wexists, (void *)ptr);
617
+
618
+ rc = ptr->rc;
619
+
620
+ error:
621
+ free(ptr);
622
+ return rc;
623
+ }
624
+
625
+
626
+ static VALUE zkrb_gvl_zoo_get(void *data) {
627
+ zkrb_zoo_get_args_t *a = (zkrb_zoo_get_args_t *)data;
628
+ a->rc = zoo_get(a->zh, a->path, a->watch, a->buffer, a->buffer_len, a->stat);
629
+ return Qnil;
630
+ }
631
+
632
+ // wrapper that calls zoo_get via zkrb_gvl_zoo_get inside rb_thread_blocking_region
633
+ int zkrb_call_zoo_get(zhandle_t *zh, const char *path, int watch, char *buffer, int* buffer_len, struct Stat *stat) {
634
+ int rc = ZKRB_FAIL;
635
+ zkrb_zoo_get_args_t *ptr = malloc(sizeof(zkrb_zoo_get_args_t));
636
+ check_mem(ptr);
637
+
638
+ ptr->rc = rc;
639
+ ptr->zh = zh;
640
+ ptr->path = path;
641
+ ptr->watch = watch;
642
+ ptr->buffer = buffer;
643
+ ptr->buffer_len = buffer_len;
644
+ ptr->stat = stat;
645
+
646
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_get, (void *)ptr);
647
+
648
+ rc = ptr->rc;
649
+
650
+ error:
651
+ free(ptr);
652
+ return rc;
653
+ }
654
+
655
+
656
+ static VALUE zkrb_gvl_zoo_wget(void *data) {
657
+ zkrb_zoo_wget_args_t *a = (zkrb_zoo_wget_args_t *)data;
658
+ a->rc = zoo_wget(a->zh, a->path, a->watcher, a->watcherCtx, a->buffer, a->buffer_len, a->stat);
659
+ return Qnil;
660
+ }
661
+
662
+ // wrapper that calls zoo_wget via zkrb_gvl_zoo_wget inside rb_thread_blocking_region
663
+ int zkrb_call_zoo_wget(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, char *buffer, int* buffer_len, struct Stat *stat) {
664
+ int rc = ZKRB_FAIL;
665
+ zkrb_zoo_wget_args_t *ptr = malloc(sizeof(zkrb_zoo_wget_args_t));
666
+ check_mem(ptr);
667
+
668
+ ptr->rc = rc;
669
+ ptr->zh = zh;
670
+ ptr->path = path;
671
+ ptr->watcher = watcher;
672
+ ptr->watcherCtx = watcherCtx;
673
+ ptr->buffer = buffer;
674
+ ptr->buffer_len = buffer_len;
675
+ ptr->stat = stat;
676
+
677
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_wget, (void *)ptr);
678
+
679
+ rc = ptr->rc;
680
+
681
+ error:
682
+ free(ptr);
683
+ return rc;
684
+ }
685
+
686
+
687
+ static VALUE zkrb_gvl_zoo_set(void *data) {
688
+ zkrb_zoo_set_args_t *a = (zkrb_zoo_set_args_t *)data;
689
+ a->rc = zoo_set(a->zh, a->path, a->buffer, a->buflen, a->version);
690
+ return Qnil;
691
+ }
692
+
693
+ // wrapper that calls zoo_set via zkrb_gvl_zoo_set inside rb_thread_blocking_region
694
+ int zkrb_call_zoo_set(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version) {
695
+ int rc = ZKRB_FAIL;
696
+ zkrb_zoo_set_args_t *ptr = malloc(sizeof(zkrb_zoo_set_args_t));
697
+ check_mem(ptr);
698
+
699
+ ptr->rc = rc;
700
+ ptr->zh = zh;
701
+ ptr->path = path;
702
+ ptr->buffer = buffer;
703
+ ptr->buflen = buflen;
704
+ ptr->version = version;
705
+
706
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_set, (void *)ptr);
707
+
708
+ rc = ptr->rc;
709
+
710
+ error:
711
+ free(ptr);
712
+ return rc;
713
+ }
714
+
715
+
716
+ static VALUE zkrb_gvl_zoo_set2(void *data) {
717
+ zkrb_zoo_set2_args_t *a = (zkrb_zoo_set2_args_t *)data;
718
+ a->rc = zoo_set2(a->zh, a->path, a->buffer, a->buflen, a->version, a->stat);
719
+ return Qnil;
720
+ }
721
+
722
+ // wrapper that calls zoo_set2 via zkrb_gvl_zoo_set2 inside rb_thread_blocking_region
723
+ int zkrb_call_zoo_set2(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version, struct Stat *stat) {
724
+ int rc = ZKRB_FAIL;
725
+ zkrb_zoo_set2_args_t *ptr = malloc(sizeof(zkrb_zoo_set2_args_t));
726
+ check_mem(ptr);
727
+
728
+ ptr->rc = rc;
729
+ ptr->zh = zh;
730
+ ptr->path = path;
731
+ ptr->buffer = buffer;
732
+ ptr->buflen = buflen;
733
+ ptr->version = version;
734
+ ptr->stat = stat;
735
+
736
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_set2, (void *)ptr);
737
+
738
+ rc = ptr->rc;
739
+
740
+ error:
741
+ free(ptr);
742
+ return rc;
743
+ }
744
+
745
+
746
+ static VALUE zkrb_gvl_zoo_get_children(void *data) {
747
+ zkrb_zoo_get_children_args_t *a = (zkrb_zoo_get_children_args_t *)data;
748
+ a->rc = zoo_get_children(a->zh, a->path, a->watch, a->strings);
749
+ return Qnil;
750
+ }
751
+
752
+ // wrapper that calls zoo_get_children via zkrb_gvl_zoo_get_children inside rb_thread_blocking_region
753
+ int zkrb_call_zoo_get_children(zhandle_t *zh, const char *path, int watch, struct String_vector *strings) {
754
+ int rc = ZKRB_FAIL;
755
+ zkrb_zoo_get_children_args_t *ptr = malloc(sizeof(zkrb_zoo_get_children_args_t));
756
+ check_mem(ptr);
757
+
758
+ ptr->rc = rc;
759
+ ptr->zh = zh;
760
+ ptr->path = path;
761
+ ptr->watch = watch;
762
+ ptr->strings = strings;
763
+
764
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_get_children, (void *)ptr);
765
+
766
+ rc = ptr->rc;
767
+
768
+ error:
769
+ free(ptr);
770
+ return rc;
771
+ }
772
+
773
+
774
+ static VALUE zkrb_gvl_zoo_wget_children(void *data) {
775
+ zkrb_zoo_wget_children_args_t *a = (zkrb_zoo_wget_children_args_t *)data;
776
+ a->rc = zoo_wget_children(a->zh, a->path, a->watcher, a->watcherCtx, a->strings);
777
+ return Qnil;
778
+ }
779
+
780
+ // wrapper that calls zoo_wget_children via zkrb_gvl_zoo_wget_children inside rb_thread_blocking_region
781
+ int zkrb_call_zoo_wget_children(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, struct String_vector *strings) {
782
+ int rc = ZKRB_FAIL;
783
+ zkrb_zoo_wget_children_args_t *ptr = malloc(sizeof(zkrb_zoo_wget_children_args_t));
784
+ check_mem(ptr);
785
+
786
+ ptr->rc = rc;
787
+ ptr->zh = zh;
788
+ ptr->path = path;
789
+ ptr->watcher = watcher;
790
+ ptr->watcherCtx = watcherCtx;
791
+ ptr->strings = strings;
792
+
793
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_wget_children, (void *)ptr);
794
+
795
+ rc = ptr->rc;
796
+
797
+ error:
798
+ free(ptr);
799
+ return rc;
800
+ }
801
+
802
+
803
+ static VALUE zkrb_gvl_zoo_get_children2(void *data) {
804
+ zkrb_zoo_get_children2_args_t *a = (zkrb_zoo_get_children2_args_t *)data;
805
+ a->rc = zoo_get_children2(a->zh, a->path, a->watch, a->strings, a->stat);
806
+ return Qnil;
807
+ }
808
+
809
+ // wrapper that calls zoo_get_children2 via zkrb_gvl_zoo_get_children2 inside rb_thread_blocking_region
810
+ int zkrb_call_zoo_get_children2(zhandle_t *zh, const char *path, int watch, struct String_vector *strings, struct Stat *stat) {
811
+ int rc = ZKRB_FAIL;
812
+ zkrb_zoo_get_children2_args_t *ptr = malloc(sizeof(zkrb_zoo_get_children2_args_t));
813
+ check_mem(ptr);
814
+
815
+ ptr->rc = rc;
816
+ ptr->zh = zh;
817
+ ptr->path = path;
818
+ ptr->watch = watch;
819
+ ptr->strings = strings;
820
+ ptr->stat = stat;
821
+
822
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_get_children2, (void *)ptr);
823
+
824
+ rc = ptr->rc;
825
+
826
+ error:
827
+ free(ptr);
828
+ return rc;
829
+ }
830
+
831
+
832
+ static VALUE zkrb_gvl_zoo_wget_children2(void *data) {
833
+ zkrb_zoo_wget_children2_args_t *a = (zkrb_zoo_wget_children2_args_t *)data;
834
+ a->rc = zoo_wget_children2(a->zh, a->path, a->watcher, a->watcherCtx, a->strings, a->stat);
835
+ return Qnil;
836
+ }
837
+
838
+ // wrapper that calls zoo_wget_children2 via zkrb_gvl_zoo_wget_children2 inside rb_thread_blocking_region
839
+ int zkrb_call_zoo_wget_children2(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, struct String_vector *strings, struct Stat *stat) {
840
+ int rc = ZKRB_FAIL;
841
+ zkrb_zoo_wget_children2_args_t *ptr = malloc(sizeof(zkrb_zoo_wget_children2_args_t));
842
+ check_mem(ptr);
843
+
844
+ ptr->rc = rc;
845
+ ptr->zh = zh;
846
+ ptr->path = path;
847
+ ptr->watcher = watcher;
848
+ ptr->watcherCtx = watcherCtx;
849
+ ptr->strings = strings;
850
+ ptr->stat = stat;
851
+
852
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_wget_children2, (void *)ptr);
853
+
854
+ rc = ptr->rc;
855
+
856
+ error:
857
+ free(ptr);
858
+ return rc;
859
+ }
860
+
861
+
862
+ static VALUE zkrb_gvl_zoo_get_acl(void *data) {
863
+ zkrb_zoo_get_acl_args_t *a = (zkrb_zoo_get_acl_args_t *)data;
864
+ a->rc = zoo_get_acl(a->zh, a->path, a->acl, a->stat);
865
+ return Qnil;
866
+ }
867
+
868
+ // wrapper that calls zoo_get_acl via zkrb_gvl_zoo_get_acl inside rb_thread_blocking_region
869
+ int zkrb_call_zoo_get_acl(zhandle_t *zh, const char *path, struct ACL_vector *acl, struct Stat *stat) {
870
+ int rc = ZKRB_FAIL;
871
+ zkrb_zoo_get_acl_args_t *ptr = malloc(sizeof(zkrb_zoo_get_acl_args_t));
872
+ check_mem(ptr);
873
+
874
+ ptr->rc = rc;
875
+ ptr->zh = zh;
876
+ ptr->path = path;
877
+ ptr->acl = acl;
878
+ ptr->stat = stat;
879
+
880
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_get_acl, (void *)ptr);
881
+
882
+ rc = ptr->rc;
883
+
884
+ error:
885
+ free(ptr);
886
+ return rc;
887
+ }
888
+
889
+
890
+ static VALUE zkrb_gvl_zoo_set_acl(void *data) {
891
+ zkrb_zoo_set_acl_args_t *a = (zkrb_zoo_set_acl_args_t *)data;
892
+ a->rc = zoo_set_acl(a->zh, a->path, a->version, a->acl);
893
+ return Qnil;
894
+ }
895
+
896
+ // wrapper that calls zoo_set_acl via zkrb_gvl_zoo_set_acl inside rb_thread_blocking_region
897
+ int zkrb_call_zoo_set_acl(zhandle_t *zh, const char *path, int version, const struct ACL_vector *acl) {
898
+ int rc = ZKRB_FAIL;
899
+ zkrb_zoo_set_acl_args_t *ptr = malloc(sizeof(zkrb_zoo_set_acl_args_t));
900
+ check_mem(ptr);
901
+
902
+ ptr->rc = rc;
903
+ ptr->zh = zh;
904
+ ptr->path = path;
905
+ ptr->version = version;
906
+ ptr->acl = acl;
907
+
908
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_set_acl, (void *)ptr);
909
+
910
+ rc = ptr->rc;
911
+
912
+ error:
913
+ free(ptr);
914
+ return rc;
915
+ }
916
+
917
+