slyphon-zookeeper 0.9.1-java → 0.9.2-java
Sign up to get free protection for your applications and to get access to all the features.
- 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/ext/zookeeper_lib.c
CHANGED
@@ -49,7 +49,7 @@ void zkrb_enqueue(zkrb_queue_t *q, zkrb_event_t *elt) {
|
|
49
49
|
check_debug(q != NULL && q->tail != NULL, "zkrb_enqueue: queue ptr or tail was NULL\n");
|
50
50
|
|
51
51
|
q->tail->event = elt;
|
52
|
-
q->tail->next = (
|
52
|
+
q->tail->next = (zkrb_event_ll_t *) malloc(sizeof(zkrb_event_ll_t));
|
53
53
|
q->tail = q->tail->next;
|
54
54
|
q->tail->event = NULL;
|
55
55
|
q->tail->next = NULL;
|
@@ -87,20 +87,21 @@ zkrb_event_t * zkrb_peek(zkrb_queue_t *q) {
|
|
87
87
|
|
88
88
|
zkrb_event_t* zkrb_dequeue(zkrb_queue_t *q, int need_lock) {
|
89
89
|
zkrb_event_t *rv = NULL;
|
90
|
-
|
90
|
+
zkrb_event_ll_t *old_root = NULL;
|
91
|
+
|
91
92
|
if (need_lock)
|
92
93
|
GLOBAL_MUTEX_LOCK("zkrb_dequeue");
|
93
94
|
|
94
95
|
if (!ZKRB_QUEUE_EMPTY(q)) {
|
95
|
-
|
96
|
+
old_root = q->head;
|
96
97
|
q->head = q->head->next;
|
97
98
|
rv = old_root->event;
|
98
|
-
free(old_root);
|
99
99
|
}
|
100
100
|
|
101
101
|
if (need_lock)
|
102
102
|
GLOBAL_MUTEX_UNLOCK("zkrb_dequeue");
|
103
103
|
|
104
|
+
free(old_root);
|
104
105
|
return rv;
|
105
106
|
}
|
106
107
|
|
@@ -113,6 +114,17 @@ void zkrb_signal(zkrb_queue_t *q) {
|
|
113
114
|
GLOBAL_MUTEX_UNLOCK("zkrb_signal");
|
114
115
|
}
|
115
116
|
|
117
|
+
zkrb_event_ll_t *zkrb_event_ll_t_alloc(void) {
|
118
|
+
zkrb_event_ll_t *rv = malloc(sizeof(zkrb_event_ll_t));
|
119
|
+
|
120
|
+
if (!rv) return NULL;
|
121
|
+
|
122
|
+
rv->event = NULL;
|
123
|
+
rv->next = NULL;
|
124
|
+
|
125
|
+
return rv;
|
126
|
+
}
|
127
|
+
|
116
128
|
zkrb_queue_t *zkrb_queue_alloc(void) {
|
117
129
|
// some of the locking is a little coarse, but it
|
118
130
|
// eases the logic of releasing in case of error.
|
@@ -126,10 +138,9 @@ zkrb_queue_t *zkrb_queue_alloc(void) {
|
|
126
138
|
rq = malloc(sizeof(zkrb_queue_t));
|
127
139
|
check_mem(rq);
|
128
140
|
|
129
|
-
rq->head =
|
141
|
+
rq->head = zkrb_event_ll_t_alloc();
|
130
142
|
check_mem(rq->head);
|
131
143
|
|
132
|
-
rq->head->event = NULL; rq->head->next = NULL;
|
133
144
|
rq->tail = rq->head;
|
134
145
|
rq->pipe_read = pfd[0];
|
135
146
|
rq->pipe_write = pfd[1];
|
@@ -139,6 +150,7 @@ zkrb_queue_t *zkrb_queue_alloc(void) {
|
|
139
150
|
|
140
151
|
error:
|
141
152
|
GLOBAL_MUTEX_UNLOCK("zkrb_queue_alloc");
|
153
|
+
free(rq);
|
142
154
|
return NULL;
|
143
155
|
}
|
144
156
|
|
@@ -160,7 +172,7 @@ error:
|
|
160
172
|
}
|
161
173
|
|
162
174
|
zkrb_event_t *zkrb_event_alloc(void) {
|
163
|
-
zkrb_event_t *rv =
|
175
|
+
zkrb_event_t *rv = malloc(sizeof(zkrb_event_t));
|
164
176
|
return rv;
|
165
177
|
}
|
166
178
|
|
@@ -225,11 +237,10 @@ void zkrb_event_free(zkrb_event_t *event) {
|
|
225
237
|
case ZKRB_VOID: {
|
226
238
|
break;
|
227
239
|
}
|
228
|
-
|
229
240
|
default:
|
230
|
-
|
231
|
-
fprintf(stderr, "ERROR?\n");
|
241
|
+
log_err("unrecognized event in event_free!");
|
232
242
|
}
|
243
|
+
|
233
244
|
free(event);
|
234
245
|
}
|
235
246
|
|
@@ -238,6 +249,11 @@ void zkrb_event_free(zkrb_event_t *event) {
|
|
238
249
|
VALUE zkrb_event_to_ruby(zkrb_event_t *event) {
|
239
250
|
VALUE hash = rb_hash_new();
|
240
251
|
|
252
|
+
if (!event) {
|
253
|
+
log_err("event was NULL in zkrb_event_to_ruby");
|
254
|
+
return hash;
|
255
|
+
}
|
256
|
+
|
241
257
|
rb_hash_aset(hash, GET_SYM("req_id"), LL2NUM(event->req_id));
|
242
258
|
if (event->type != ZKRB_WATCHER)
|
243
259
|
rb_hash_aset(hash, GET_SYM("rc"), INT2FIX(event->rc));
|
@@ -251,39 +267,39 @@ VALUE zkrb_event_to_ruby(zkrb_event_t *event) {
|
|
251
267
|
break;
|
252
268
|
}
|
253
269
|
case ZKRB_STAT: {
|
254
|
-
|
270
|
+
zkrb_debug("zkrb_event_to_ruby ZKRB_STAT\n");
|
255
271
|
struct zkrb_stat_completion *stat_ctx = event->completion.stat_completion;
|
256
272
|
rb_hash_aset(hash, GET_SYM("stat"), stat_ctx->stat ? zkrb_stat_to_rarray(stat_ctx->stat) : Qnil);
|
257
273
|
break;
|
258
274
|
}
|
259
275
|
case ZKRB_STRING: {
|
260
|
-
|
276
|
+
zkrb_debug("zkrb_event_to_ruby ZKRB_STRING\n");
|
261
277
|
struct zkrb_string_completion *string_ctx = event->completion.string_completion;
|
262
278
|
rb_hash_aset(hash, GET_SYM("string"), string_ctx->value ? rb_str_new2(string_ctx->value) : Qnil);
|
263
279
|
break;
|
264
280
|
}
|
265
281
|
case ZKRB_STRINGS: {
|
266
|
-
|
282
|
+
zkrb_debug("zkrb_event_to_ruby ZKRB_STRINGS\n");
|
267
283
|
struct zkrb_strings_completion *strings_ctx = event->completion.strings_completion;
|
268
284
|
rb_hash_aset(hash, GET_SYM("strings"), strings_ctx->values ? zkrb_string_vector_to_ruby(strings_ctx->values) : Qnil);
|
269
285
|
break;
|
270
286
|
}
|
271
287
|
case ZKRB_STRINGS_STAT: {
|
272
|
-
|
288
|
+
zkrb_debug("zkrb_event_to_ruby ZKRB_STRINGS_STAT\n");
|
273
289
|
struct zkrb_strings_stat_completion *strings_stat_ctx = event->completion.strings_stat_completion;
|
274
290
|
rb_hash_aset(hash, GET_SYM("strings"), strings_stat_ctx->values ? zkrb_string_vector_to_ruby(strings_stat_ctx->values) : Qnil);
|
275
291
|
rb_hash_aset(hash, GET_SYM("stat"), strings_stat_ctx->stat ? zkrb_stat_to_rarray(strings_stat_ctx->stat) : Qnil);
|
276
292
|
break;
|
277
293
|
}
|
278
294
|
case ZKRB_ACL: {
|
279
|
-
|
295
|
+
zkrb_debug("zkrb_event_to_ruby ZKRB_ACL\n");
|
280
296
|
struct zkrb_acl_completion *acl_ctx = event->completion.acl_completion;
|
281
297
|
rb_hash_aset(hash, GET_SYM("acl"), acl_ctx->acl ? zkrb_acl_vector_to_ruby(acl_ctx->acl) : Qnil);
|
282
298
|
rb_hash_aset(hash, GET_SYM("stat"), acl_ctx->stat ? zkrb_stat_to_rarray(acl_ctx->stat) : Qnil);
|
283
299
|
break;
|
284
300
|
}
|
285
301
|
case ZKRB_WATCHER: {
|
286
|
-
|
302
|
+
zkrb_debug("zkrb_event_to_ruby ZKRB_WATCHER\n");
|
287
303
|
struct zkrb_acl_completion *acl_ctx = event->completion.acl_completion;
|
288
304
|
struct zkrb_watcher_completion *watcher_ctx = event->completion.watcher_completion;
|
289
305
|
rb_hash_aset(hash, GET_SYM("type"), INT2FIX(watcher_ctx->type));
|
@@ -321,8 +337,11 @@ void zkrb_print_stat(const struct Stat *s) {
|
|
321
337
|
|
322
338
|
zkrb_calling_context *zkrb_calling_context_alloc(int64_t req_id, zkrb_queue_t *queue) {
|
323
339
|
zkrb_calling_context *ctx = malloc(sizeof(zkrb_calling_context));
|
340
|
+
if (!ctx) return NULL;
|
341
|
+
|
324
342
|
ctx->req_id = req_id;
|
325
343
|
ctx->queue = queue;
|
344
|
+
|
326
345
|
return ctx;
|
327
346
|
}
|
328
347
|
|
data/ext/zookeeper_lib.h
CHANGED
@@ -11,6 +11,11 @@
|
|
11
11
|
#define ZK_FALSE 0
|
12
12
|
#define ZKRB_GLOBAL_REQ -1
|
13
13
|
|
14
|
+
// (slyphon): this RC value does not conflict with any of the ZOO_ERRORS
|
15
|
+
// but need to find a better way of formalizing and defining this stuff
|
16
|
+
#define ZKRB_ERR_REQ -2
|
17
|
+
#define ZKRB_ERR_RC -15
|
18
|
+
|
14
19
|
#ifndef RSTRING_LEN
|
15
20
|
# define RSTRING_LEN(x) RSTRING(x)->len
|
16
21
|
#endif
|
@@ -88,14 +93,16 @@ typedef struct {
|
|
88
93
|
} completion;
|
89
94
|
} zkrb_event_t;
|
90
95
|
|
91
|
-
struct
|
92
|
-
zkrb_event_t
|
93
|
-
struct
|
96
|
+
struct zkrb_event_ll {
|
97
|
+
zkrb_event_t *event;
|
98
|
+
struct zkrb_event_ll *next;
|
94
99
|
};
|
95
100
|
|
101
|
+
typedef struct zkrb_event_ll zkrb_event_ll_t;
|
102
|
+
|
96
103
|
typedef struct {
|
97
|
-
|
98
|
-
|
104
|
+
zkrb_event_ll_t *head;
|
105
|
+
zkrb_event_ll_t *tail;
|
99
106
|
int pipe_read;
|
100
107
|
int pipe_write;
|
101
108
|
} zkrb_queue_t;
|
data/slyphon-zookeeper.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "slyphon-zookeeper"
|
6
|
-
s.version = '0.9.
|
6
|
+
s.version = '0.9.2'
|
7
7
|
|
8
8
|
s.authors = ["Phillip Pearson", "Eric Maland", "Evan Weaver", "Brian Wickman", "Neil Conway", "Jonathan D. Simms"]
|
9
9
|
s.email = ["slyphon@gmail.com"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slyphon-zookeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 2
|
10
|
+
version: 0.9.2
|
11
11
|
platform: java
|
12
12
|
authors:
|
13
13
|
- Phillip Pearson
|
@@ -20,7 +20,7 @@ autorequire:
|
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
22
|
|
23
|
-
date: 2012-04-
|
23
|
+
date: 2012-04-27 00:00:00 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
@@ -62,7 +62,7 @@ dependencies:
|
|
62
62
|
requirements:
|
63
63
|
- - "="
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
hash: -
|
65
|
+
hash: -2116566254
|
66
66
|
segments:
|
67
67
|
- 1
|
68
68
|
- 0
|