slyphon-zookeeper 0.9.1-java → 0.9.2-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -1
- data/CHANGELOG +6 -0
- data/README.markdown +3 -0
- data/Rakefile +68 -11
- data/ext/Rakefile +4 -0
- data/ext/generate_gvl_code.rb +26 -42
- data/ext/zkrb_wrapper.c +313 -499
- data/ext/zookeeper_lib.c +35 -16
- data/ext/zookeeper_lib.h +12 -5
- data/slyphon-zookeeper.gemspec +1 -1
- metadata +5 -5
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
v0.9.2 More efficient and simpler wrappers for GIL release
|
2
|
+
|
3
|
+
* After a code review by Andrew Wason (rectalogic), use a much simpler
|
4
|
+
technique for creating the arg structs and passing them to the
|
5
|
+
zkrb_gvl_* functions. No malloc(), no free(), no problem.
|
6
|
+
|
1
7
|
v0.9.1 see v0.8.4 notes, same patch
|
2
8
|
|
3
9
|
v0.9.0 RELEASE THE KRAK..er, GIL!!
|
data/README.markdown
CHANGED
@@ -7,6 +7,9 @@ such as locks, have a look at [ZK](https://github.com/slyphon/zk) (also
|
|
7
7
|
available is [ZK-EventMachine](https://github.com/slyphon/zk-eventmachine) for
|
8
8
|
those who prefer async).
|
9
9
|
|
10
|
+
Unfortunately, since this is a fork of twitter/zookeeper, we don't have our own
|
11
|
+
Issues tracker. Issues should be filed under [ZK](https://github.com/slyphon/zk/issues).
|
12
|
+
|
10
13
|
## License
|
11
14
|
|
12
15
|
Copyright 2008 Phillip Pearson, and 2010 Twitter, Inc. Licensed under the
|
data/Rakefile
CHANGED
@@ -1,29 +1,62 @@
|
|
1
1
|
# def gemset_name
|
2
2
|
# ENV.fetch('GEM_HOME').split('@').last
|
3
3
|
# end
|
4
|
-
|
4
|
+
|
5
|
+
GEM_FILES = FileList['slyphon-zookeeper-*.gem']
|
6
|
+
|
5
7
|
namespace :mb do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
namespace :gems do
|
9
|
+
task :build do
|
10
|
+
sh "rvm 1.8.7 do gem build slyphon-zookeeper.gemspec"
|
11
|
+
ENV['JAVA_GEM'] = '1'
|
12
|
+
sh "rvm 1.8.7 do gem build slyphon-zookeeper.gemspec"
|
13
|
+
end
|
14
|
+
|
15
|
+
task :push do
|
16
|
+
GEM_FILES.each do |gem|
|
17
|
+
sh "gem push #{gem}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
task :clean do
|
22
|
+
rm_rf GEM_FILES
|
23
|
+
end
|
24
|
+
|
25
|
+
task :all => [:build, :push, :clean]
|
10
26
|
end
|
11
27
|
end
|
12
28
|
|
13
29
|
gemset_name = 'zookeeper'
|
14
30
|
|
31
|
+
directory 'tmp'
|
32
|
+
|
33
|
+
# this nonsense w/ tmp and the Gemfile is a bundler optimization
|
34
|
+
|
35
|
+
GEMSPEC_LINK = 'tmp/slyphon-zookeeper.gemspec'
|
36
|
+
|
37
|
+
file GEMSPEC_LINK => 'tmp' do
|
38
|
+
ln_s '../slyphon-zookeeper.gemspec', GEMSPEC_LINK
|
39
|
+
end
|
15
40
|
|
16
|
-
%w[1.8.7 1.9.2 1.9.3
|
41
|
+
%w[1.8.7 1.9.2 jruby rbx 1.9.3].each do |ns_name|
|
17
42
|
rvm_ruby = (ns_name == 'rbx') ? "rbx-2.0.testing" : ns_name
|
18
43
|
|
19
44
|
ruby_with_gemset = "#{rvm_ruby}@#{gemset_name}"
|
20
45
|
|
21
46
|
create_gemset_name = "mb:#{ns_name}:create_gemset"
|
22
47
|
clobber_task_name = "mb:#{ns_name}:clobber"
|
48
|
+
clean_task_name = "mb:#{ns_name}:clean"
|
23
49
|
build_task_name = "mb:#{ns_name}:build"
|
24
50
|
bundle_task_name = "mb:#{ns_name}:bundle_install"
|
25
51
|
rspec_task_name = "mb:#{ns_name}:run_rspec"
|
26
52
|
|
53
|
+
phony_gemfile_link_name = File.expand_path("tmp/Gemfile.#{ns_name}")
|
54
|
+
|
55
|
+
file phony_gemfile_link_name => GEMSPEC_LINK do
|
56
|
+
# apparently, rake doesn't deal with symlinks intelligently :P
|
57
|
+
ln_s('../Gemfile', phony_gemfile_link_name) unless File.exists?(phony_gemfile_link_name)
|
58
|
+
end
|
59
|
+
|
27
60
|
task create_gemset_name do
|
28
61
|
sh "rvm #{rvm_ruby} do rvm gemset create #{gemset_name}"
|
29
62
|
end
|
@@ -36,7 +69,15 @@ gemset_name = 'zookeeper'
|
|
36
69
|
end
|
37
70
|
end
|
38
71
|
|
39
|
-
task
|
72
|
+
task clean_task_name do
|
73
|
+
unless rvm_ruby == 'jruby'
|
74
|
+
cd 'ext' do
|
75
|
+
sh "rake clean"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
task build_task_name => [create_gemset_name, clean_task_name] do
|
40
81
|
unless rvm_ruby == 'jruby'
|
41
82
|
cd 'ext' do
|
42
83
|
sh "rvm #{ruby_with_gemset} do rake build"
|
@@ -44,13 +85,12 @@ gemset_name = 'zookeeper'
|
|
44
85
|
end
|
45
86
|
end
|
46
87
|
|
47
|
-
task bundle_task_name => build_task_name do
|
48
|
-
|
49
|
-
sh "rvm #{ruby_with_gemset} do bundle install"
|
88
|
+
task bundle_task_name => [phony_gemfile_link_name, build_task_name] do
|
89
|
+
sh "rvm #{ruby_with_gemset} do bundle install --gemfile #{phony_gemfile_link_name}"
|
50
90
|
end
|
51
91
|
|
52
92
|
task rspec_task_name => bundle_task_name do
|
53
|
-
sh "rvm #{ruby_with_gemset} do bundle exec rspec spec --fail-fast"
|
93
|
+
sh "rvm #{ruby_with_gemset} do env BUNDLE_GEMFILE=#{phony_gemfile_link_name} bundle exec rspec spec --fail-fast"
|
54
94
|
end
|
55
95
|
|
56
96
|
task "mb:#{ns_name}" => rspec_task_name
|
@@ -58,6 +98,23 @@ gemset_name = 'zookeeper'
|
|
58
98
|
task "mb:test_all" => rspec_task_name
|
59
99
|
end
|
60
100
|
|
101
|
+
task :default => 'mb:1.9.3'
|
102
|
+
|
103
|
+
task :clean do
|
104
|
+
rm_rf 'tmp'
|
105
|
+
end
|
106
|
+
|
107
|
+
# cargo culted from http://blog.flavorjon.es/2009/06/easily-valgrind-gdb-your-ruby-c.html
|
108
|
+
VALGRIND_BASIC_OPTS = '--num-callers=50 --error-limit=no --partial-loads-ok=yes --undef-value-errors=no'
|
109
|
+
|
110
|
+
task 'valgrind' do
|
111
|
+
cd 'ext' do
|
112
|
+
sh "rake clean build"
|
113
|
+
end
|
114
|
+
|
115
|
+
sh "valgrind #{VALGRIND_BASIC_OPTS} bundle exec rspec spec"
|
116
|
+
end
|
117
|
+
|
61
118
|
namespace :build do
|
62
119
|
task :clean do
|
63
120
|
cd 'ext' do
|
data/ext/Rakefile
CHANGED
data/ext/generate_gvl_code.rb
CHANGED
@@ -35,29 +35,21 @@ we want
|
|
35
35
|
int valuelen, const struct ACL_vector *acl, int flags,
|
36
36
|
string_completion_t completion, const void *data) {
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
rc = ptr->rc;
|
55
|
-
free(ptr);
|
56
|
-
return rc;
|
57
|
-
|
58
|
-
error:
|
59
|
-
free(ptr);
|
60
|
-
return -1;
|
38
|
+
zkrb_zoo_acreate_args_t args = {
|
39
|
+
.rc = ZKRB_FAIL,
|
40
|
+
.zh = zh,
|
41
|
+
.path = path,
|
42
|
+
.value = value,
|
43
|
+
.valuelen = valuelen,
|
44
|
+
.acl = acl,
|
45
|
+
.flags = flags,
|
46
|
+
.completion = completion,
|
47
|
+
.data = data
|
48
|
+
};
|
49
|
+
|
50
|
+
zkrb_thread_blocking_region(zkrb_gvl_zoo_acreate, (void *)&args);
|
51
|
+
|
52
|
+
return args.rc;
|
61
53
|
}
|
62
54
|
|
63
55
|
=end
|
@@ -156,43 +148,35 @@ class CallingFunction
|
|
156
148
|
@fn_signature ||= "int #{name}(#{typed_args.join(', ')})"
|
157
149
|
end
|
158
150
|
|
159
|
-
def
|
160
|
-
@
|
161
|
-
lines = ["ptr->rc = rc;"]
|
162
|
-
lines += member_names.map { |n| "ptr->#{n} = #{n};" }
|
163
|
-
lines.map! { |n| " #{n}" }
|
164
|
-
lines.join("\n")
|
165
|
-
)
|
151
|
+
def initializer_lines
|
152
|
+
@initializer_lines ||= member_names.map { |n| " .#{n} = #{n}" }.join(",\n")
|
166
153
|
end
|
167
154
|
|
168
155
|
def top
|
169
156
|
<<-EOS
|
170
157
|
// wrapper that calls #{zoo_fn_name} via #{wrapper_fn.name} inside rb_thread_blocking_region
|
171
158
|
#{fn_signature} {
|
172
|
-
|
173
|
-
|
174
|
-
|
159
|
+
#{struct.name} args = {
|
160
|
+
.rc = ZKRB_FAIL,
|
161
|
+
#{initializer_lines}
|
162
|
+
};
|
175
163
|
EOS
|
176
164
|
end
|
177
165
|
|
178
166
|
def rb_thread_blocking_region_call
|
179
|
-
" zkrb_thread_blocking_region(#{wrapper_fn.name}, (void *)
|
167
|
+
" zkrb_thread_blocking_region(#{wrapper_fn.name}, (void *)&args);"
|
180
168
|
end
|
181
169
|
|
182
170
|
def bottom
|
183
171
|
<<-EOS
|
184
172
|
|
185
|
-
|
186
|
-
|
187
|
-
error:
|
188
|
-
free(ptr);
|
189
|
-
return rc;
|
173
|
+
return args.rc;
|
190
174
|
}
|
191
175
|
EOS
|
192
176
|
end
|
193
177
|
|
194
178
|
def body
|
195
|
-
@body ||= [top,
|
179
|
+
@body ||= [top, rb_thread_blocking_region_call, bottom].join("\n")
|
196
180
|
end
|
197
181
|
end
|
198
182
|
|
@@ -209,6 +193,8 @@ class GeneratedCode < Struct.new(:structs, :wrapper_fns, :calling_fns)
|
|
209
193
|
new.tap do |code|
|
210
194
|
while true
|
211
195
|
break unless text =~ REGEXP
|
196
|
+
text = $~.post_match
|
197
|
+
|
212
198
|
zoo_fn_name, argstr = $1
|
213
199
|
argstr = $2
|
214
200
|
|
@@ -228,8 +214,6 @@ class GeneratedCode < Struct.new(:structs, :wrapper_fns, :calling_fns)
|
|
228
214
|
code.structs << struct
|
229
215
|
code.wrapper_fns << wrapper_fn
|
230
216
|
code.calling_fns << calling_fn
|
231
|
-
|
232
|
-
text = $~.post_match
|
233
217
|
end
|
234
218
|
end
|
235
219
|
end
|