agoo 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of agoo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 875dd13c45030ea940c3afe58571a260f6220ff8f09ed3fd1084957e0efa3586
4
- data.tar.gz: d8efe96974e9299d1627373cc31be42f93b7bed3eb00c7593c32b8aa9fe954cb
3
+ metadata.gz: 4972cbbcab2bb5e6efd12fdbe709e6e3b5e3c21edba29bd9abf66e6aecb5dcf5
4
+ data.tar.gz: 6a5d2c4c783a19c4452ea65b5509a8c9acce86bb15dcdacef805615084c07c6a
5
5
  SHA512:
6
- metadata.gz: b66d7a3f8265fab7f84c9a78894401950adcbd7a55df412ab7ff92bc497ff825777498cf58ff1a0e3ba0b168aecec597da823ac61455f57b4f9d26ef32e1264b
7
- data.tar.gz: d82ea3f18c07459186e64a8db4fda82e07bdb55e7506a031eebeb628c05e458eb4507fb531144fd1559f39c5543d0569a9fdc9738df47110ed4edf68045c1c83
6
+ metadata.gz: dded79dd9e1850504e766708f3c646ecc2930991a5cfbf3c470533a1881e606404aaf75abf0ae1f81ec161d4caac3b85268f0504c11b748bb024b57194034b67
7
+ data.tar.gz: ec6ec4aa3199cfb1aedea0203f2ec33602884c134b7144f2febcf2b7009cd069c54439b9ae90485a68e12ec3f18fcf37d36b2e96928744aa6937fe8e28e0f61a
@@ -52,7 +52,7 @@ con_header_value(const char *header, int hlen, const char *key, int *vlen) {
52
52
  const char *h = header;
53
53
  const char *hend = header + hlen;
54
54
  const char *value;
55
- int klen = strlen(key);
55
+ int klen = (int)strlen(key);
56
56
 
57
57
  while (h < hend) {
58
58
  if (0 == strncmp(key, h, klen) && ':' == h[klen]) {
@@ -62,7 +62,7 @@ con_header_value(const char *header, int hlen, const char *key, int *vlen) {
62
62
  value = h;
63
63
  for (; '\r' != *h && '\0' != *h; h++) {
64
64
  }
65
- *vlen = h - value;
65
+ *vlen = (int)(h - value);
66
66
 
67
67
  return value;
68
68
  }
@@ -161,7 +161,7 @@ con_header_read(Con c) {
161
161
  } else {
162
162
  return bad_request(c, 400, __LINE__);
163
163
  }
164
- if (NULL == (v = con_header_value(c->buf, hend - c->buf, "Content-Length", &vlen))) {
164
+ if (NULL == (v = con_header_value(c->buf, (int)(hend - c->buf), "Content-Length", &vlen))) {
165
165
  return bad_request(c, 411, __LINE__);
166
166
  }
167
167
  clen = (size_t)strtoul(v, &vend, 10);
@@ -225,7 +225,7 @@ con_header_read(Con c) {
225
225
  if (NULL == (hook = hook_find(server->hooks, method, path, pend))) {
226
226
  if (GET == method) {
227
227
  struct _Err err = ERR_INIT;
228
- Page p = page_get(&err, &server->pages, server->root, path, pend - path);
228
+ Page p = page_get(&err, &server->pages, server->root, path, (int)(pend - path));
229
229
  Res res;
230
230
 
231
231
  if (NULL == p) {
@@ -242,7 +242,7 @@ con_header_read(Con c) {
242
242
  c->res_tail = res;
243
243
 
244
244
  b = strstr(c->buf, "\r\n");
245
- res->close = should_close(b, hend - b);
245
+ res->close = should_close(b, (int)(hend - b));
246
246
 
247
247
  text_ref(p->resp);
248
248
  res_set_message(res, p->resp);
@@ -262,15 +262,15 @@ con_header_read(Con c) {
262
262
  c->req->server = server;
263
263
  c->req->method = method;
264
264
  c->req->path.start = c->req->msg + (path - c->buf);
265
- c->req->path.len = pend - path;
265
+ c->req->path.len = (int)(pend - path);
266
266
  c->req->query.start = c->req->msg + (query - c->buf);
267
- c->req->query.len = qend - query;
267
+ c->req->query.len = (int)(qend - query);
268
268
  c->req->mlen = mlen;
269
269
  c->req->body.start = c->req->msg + (hend - c->buf + 4);
270
- c->req->body.len = clen;
270
+ c->req->body.len = (unsigned int)clen;
271
271
  b = strstr(b, "\r\n");
272
272
  c->req->header.start = c->req->msg + (b + 2 - c->buf);
273
- c->req->header.len = hend - b - 2;
273
+ c->req->header.len = (unsigned int)(hend - b - 2);
274
274
  c->req->res = NULL;
275
275
  if (NULL != hook) {
276
276
  c->req->handler = hook->handler;
@@ -441,7 +441,7 @@ con_loop(void *x) {
441
441
  i--;
442
442
  pp++;
443
443
  }
444
- if (0 > (i = poll(pa, pp - pa, 100))) {
444
+ if (0 > (i = poll(pa, (nfds_t)(pp - pa), 100))) {
445
445
  if (EAGAIN == errno) {
446
446
  continue;
447
447
  }
@@ -39,7 +39,7 @@ static VALUE
39
39
  es_puts(VALUE self, VALUE str) {
40
40
  ErrorStream es = (ErrorStream)DATA_PTR(self);
41
41
 
42
- es->text = text_append(es->text, StringValuePtr(str), RSTRING_LEN(str));
42
+ es->text = text_append(es->text, StringValuePtr(str), (int)RSTRING_LEN(str));
43
43
  es->text = text_append(es->text, "\n", 1);
44
44
 
45
45
  return Qnil;
@@ -54,7 +54,7 @@ es_puts(VALUE self, VALUE str) {
54
54
  static VALUE
55
55
  es_write(VALUE self, VALUE str) {
56
56
  ErrorStream es = (ErrorStream)DATA_PTR(self);
57
- int cnt = RSTRING_LEN(str);
57
+ int cnt = (int)RSTRING_LEN(str);
58
58
 
59
59
  es->text = text_append(es->text, StringValuePtr(str), cnt);
60
60
 
@@ -5,6 +5,7 @@ extension_name = 'agoo'
5
5
  dir_config(extension_name)
6
6
 
7
7
  $CPPFLAGS += " -DPLATFORM_LINUX" if 'x86_64-linux' == RUBY_PLATFORM
8
+ RbConfig::MAKEFILE_CONFIG['CC'] = "gcc-6" if 'x86_64-linux' == RUBY_PLATFORM
8
9
 
9
10
  create_makefile(File.join(extension_name, extension_name))
10
11
 
@@ -464,7 +464,7 @@ get_bucketp(uint64_t h) {
464
464
 
465
465
  static void
466
466
  key_set(const char *key) {
467
- int len = strlen(key);
467
+ int len = (int)strlen(key);
468
468
  int64_t h = calc_hash(key, &len);
469
469
  Slot *bucket = get_bucketp(h);
470
470
  Slot s;
@@ -121,7 +121,7 @@ classic_write(Log log, LogEntry e, FILE *file) {
121
121
  t += log->zone;
122
122
  if (log->day_start <= t && t < log->day_end) {
123
123
  t -= log->day_start;
124
- hour = t / 3600;
124
+ hour = (int)(t / 3600);
125
125
  min = t % 3600 / 60;
126
126
  sec = t % 60;
127
127
  } else {
@@ -346,7 +346,7 @@ log_init(Err err, Log log, VALUE cfg) {
346
346
  log->console = true;
347
347
  log->classic = true;
348
348
  log->colorize = true;
349
- log->zone = (int64_t)(timegm(tm) - t);
349
+ log->zone = (int)(timegm(tm) - t);
350
350
  log->day_start = 0;
351
351
  log->day_end = 0;
352
352
  *log->day_buf = '\0';
@@ -184,7 +184,7 @@ page_destroy(Page p) {
184
184
  static bool
185
185
  update_contents(Page p) {
186
186
  const char *mime = NULL;
187
- int plen = strlen(p->path);
187
+ int plen = (int)strlen(p->path);
188
188
  const char *suffix = p->path + plen - 1;
189
189
  FILE *f;
190
190
  long size;
@@ -284,7 +284,7 @@ update_contents(Page p) {
284
284
  text_release(p->resp);
285
285
  p->resp = NULL;
286
286
  }
287
- p->resp = text_create(msg, msize);
287
+ p->resp = text_create(msg, (int)msize);
288
288
  text_ref(p->resp);
289
289
  p->last_check = dtime();
290
290
 
@@ -184,7 +184,7 @@ queue_release(Queue q) {
184
184
 
185
185
  int
186
186
  queue_count(Queue q) {
187
- int size = q->end - q->q;
187
+ int size = (int)(q->end - q->q);
188
188
 
189
189
  return (q->tail - q->head + size) % size;
190
190
  }
@@ -354,7 +354,7 @@ fill_headers(Req r, VALUE hash) {
354
354
  char *h = r->header.start;
355
355
  char *end = h + r->header.len;
356
356
  char *key = h;
357
- char *kend;
357
+ char *kend = key;
358
358
  char *val = NULL;
359
359
  char *vend;
360
360
 
@@ -382,7 +382,7 @@ fill_headers(Req r, VALUE hash) {
382
382
  if ('\n' == *(h + 1)) {
383
383
  h++;
384
384
  }
385
- add_header_value(hash, key, kend - key, val, vend - val);
385
+ add_header_value(hash, key, (int)(kend - key), val, (int)(vend - val));
386
386
  key = h + 1;
387
387
  kend = NULL;
388
388
  val = NULL;
@@ -125,7 +125,7 @@ body_set(VALUE self, VALUE val) {
125
125
 
126
126
  if (T_STRING == rb_type(val)) {
127
127
  res->body = strdup(StringValuePtr(val));
128
- res->blen = RSTRING_LEN(val);
128
+ res->blen = (int)RSTRING_LEN(val);
129
129
  } else {
130
130
  // TBD use Oj
131
131
  }
@@ -172,7 +172,7 @@ head_get(VALUE self, VALUE key) {
172
172
  Response res = (Response)DATA_PTR(self);
173
173
  Header h;
174
174
  const char *ks = StringValuePtr(key);
175
- int klen = RSTRING_LEN(key);
175
+ int klen = (int)RSTRING_LEN(key);
176
176
 
177
177
  for (h = res->headers; NULL != h; h = h->next) {
178
178
  if (0 == strncasecmp(h->text, ks, klen) && klen + 1 < h->len && ':' == h->text[klen]) {
@@ -195,7 +195,7 @@ head_set(VALUE self, VALUE key, VALUE val) {
195
195
  Header prev = NULL;
196
196
  const char *ks = StringValuePtr(key);
197
197
  const char *vs;
198
- int klen = RSTRING_LEN(key);
198
+ int klen = (int)RSTRING_LEN(key);
199
199
  int vlen;
200
200
  int hlen;
201
201
 
@@ -215,7 +215,7 @@ head_set(VALUE self, VALUE key, VALUE val) {
215
215
  val = rb_funcall(val, rb_intern("to_s"), 0);
216
216
  }
217
217
  vs = StringValuePtr(val);
218
- vlen = RSTRING_LEN(val);
218
+ vlen = (int)RSTRING_LEN(val);
219
219
 
220
220
  if (res->server->pedantic) {
221
221
  http_header_ok(ks, klen, vs, vlen);
@@ -249,6 +249,7 @@ listen_loop(void *x) {
249
249
  return NULL;
250
250
  }
251
251
  listen(pa->fd, 1000);
252
+ server->ready = true;
252
253
  pa->events = POLLIN;
253
254
  pa->revents = 0;
254
255
 
@@ -317,7 +318,7 @@ rescue_error(VALUE x) {
317
318
  if ((int)(sizeof(buf) - sizeof(bad500) + 7) <= len) {
318
319
  len = sizeof(buf) - sizeof(bad500) + 7;
319
320
  }
320
- cnt = snprintf(buf, sizeof(buf), "HTTP/1.1 500 Internal Error\r\nConnection: Close\r\nContent-Length: %d\r\n\r\n%s: %s", len, classname, ms);
321
+ cnt = snprintf(buf, sizeof(buf), "%s%d\r\n\r\n%s: %s", bad500, len, classname, ms);
321
322
  message = text_create(buf, cnt);
322
323
 
323
324
  req->res->close = true;
@@ -421,7 +422,7 @@ handle_rack_inner(void *x) {
421
422
  }
422
423
  if (T_ARRAY != rb_type(bv)) {
423
424
  int i;
424
- int bcnt = RARRAY_LEN(bv);
425
+ int bcnt = (int)RARRAY_LEN(bv);
425
426
 
426
427
  for (i = 0; i < bcnt; i++) {
427
428
  bsize += (int)RSTRING_LEN(rb_ary_entry(bv, i));
@@ -437,10 +438,11 @@ handle_rack_inner(void *x) {
437
438
  case 205:
438
439
  case 304:
439
440
  // TBD Content-Type and Content-Length can not be present
440
- t->len = sprintf(t->text, "HTTP/1.1 %d %s\r\n", code, status_msg);
441
+ t->len = snprintf(t->text, 1024, "HTTP/1.1 %d %s\r\n", code, status_msg);
441
442
  break;
442
443
  default:
443
- t->len = sprintf(t->text, "HTTP/1.1 %d %s\r\nContent-Length: %d\r\n", code, status_msg, bsize);
444
+ // Note that using simply sprintf causes an abort with travis OSX tests.
445
+ t->len = snprintf(t->text, 1024, "HTTP/1.1 %d %s\r\nContent-Length: %d\r\n", code, status_msg, bsize);
444
446
  break;
445
447
  }
446
448
  if (T_HASH == rb_type(hv)) {
@@ -453,7 +455,7 @@ handle_rack_inner(void *x) {
453
455
  if (T_ARRAY == rb_type(bv)) {
454
456
  VALUE v;
455
457
  int i;
456
- int bcnt = RARRAY_LEN(bv);
458
+ int bcnt = (int)RARRAY_LEN(bv);
457
459
 
458
460
  for (i = 0; i < bcnt; i++) {
459
461
  v = rb_ary_entry(bv, i);
@@ -561,11 +563,24 @@ start(VALUE self) {
561
563
  Server server = (Server)DATA_PTR(self);
562
564
  VALUE *vp;
563
565
  int i;
566
+ double giveup;
564
567
 
565
568
  server->active = true;
569
+ server->ready = false;
566
570
 
567
571
  pthread_create(&server->listen_thread, NULL, listen_loop, server);
568
572
  pthread_create(&server->con_thread, NULL, con_loop, server);
573
+
574
+ giveup = dtime() + 1.0;
575
+ while (dtime() < giveup) {
576
+ if (server->ready) {
577
+ break;
578
+ }
579
+ dsleep(0.001);
580
+ }
581
+ signal(SIGINT, sig_handler);
582
+ signal(SIGTERM, sig_handler);
583
+ signal(SIGPIPE, SIG_IGN);
569
584
 
570
585
  if (0 >= server->thread_cnt) {
571
586
  Req req;
@@ -884,8 +899,4 @@ server_init(VALUE mod) {
884
899
  put_sym = ID2SYM(rb_intern("PUT")); rb_gc_register_address(&put_sym);
885
900
 
886
901
  http_init();
887
-
888
- signal(SIGINT, sig_handler);
889
- signal(SIGTERM, sig_handler);
890
- signal(SIGPIPE, SIG_IGN);
891
902
  }
@@ -16,6 +16,7 @@
16
16
 
17
17
  typedef struct _Server {
18
18
  volatile bool active;
19
+ volatile bool ready;
19
20
  int thread_cnt;
20
21
  int port;
21
22
  bool pedantic;
@@ -47,7 +47,7 @@ text_release(Text t) {
47
47
  Text
48
48
  text_append(Text t, const char *s, int len) {
49
49
  if (0 >= len) {
50
- len = strlen(s);
50
+ len = (int)strlen(s);
51
51
  }
52
52
  if (t->alen <= t->len + len) {
53
53
  long new_len = t->alen + t->alen / 2;
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Agoo
3
3
  # Agoo version.
4
- VERSION = '0.9.0'
4
+ VERSION = '0.9.1'
5
5
  end
@@ -116,6 +116,7 @@ class LogClassicTest < Minitest::Test
116
116
  def error_test(server)
117
117
  server.error('my message')
118
118
  server.log_flush(1.0)
119
+ sleep(0.01) # seems to be needed to assure writes actually happened even though flush was called.
119
120
  content = IO.read('log/agoo.log')
120
121
  assert_match(/ERROR: my message/, content)
121
122
  end
@@ -123,6 +124,7 @@ class LogClassicTest < Minitest::Test
123
124
  def warn_test(server)
124
125
  server.warn('my message')
125
126
  server.log_flush(1.0)
127
+ sleep(0.01)
126
128
  content = IO.read('log/agoo.log')
127
129
  assert_match(/WARN: my message/, content)
128
130
  end
@@ -130,6 +132,7 @@ class LogClassicTest < Minitest::Test
130
132
  def info_test(server)
131
133
  server.info('my message')
132
134
  server.log_flush(1.0)
135
+ sleep(0.01)
133
136
  content = IO.read('log/agoo.log')
134
137
  assert_match(/INFO: my message/, content)
135
138
  end
@@ -137,6 +140,7 @@ class LogClassicTest < Minitest::Test
137
140
  def debug_test(server)
138
141
  server.debug('my message')
139
142
  server.log_flush(1.0)
143
+ sleep(0.01)
140
144
  content = IO.read('log/agoo.log')
141
145
  assert_match(/DEBUG: my message/, content)
142
146
  end
@@ -144,6 +148,7 @@ class LogClassicTest < Minitest::Test
144
148
  def log_eval_test(server)
145
149
  server.log_eval('my message')
146
150
  server.log_flush(1.0)
151
+ sleep(0.01)
147
152
  content = IO.read('log/agoo.log')
148
153
  assert_match(/eval: my message/, content)
149
154
  end
@@ -180,6 +185,7 @@ class LogJsonTest < Minitest::Test
180
185
  def error_test(server)
181
186
  server.error('my message')
182
187
  server.log_flush(1.0)
188
+ sleep(0.01)
183
189
  content = IO.read('log/agoo.log.1')
184
190
  assert_match(/"where":"ERROR"/, content)
185
191
  assert_match(/"level":1/, content)
@@ -189,6 +195,7 @@ class LogJsonTest < Minitest::Test
189
195
  def warn_test(server)
190
196
  server.warn('my message')
191
197
  server.log_flush(1.0)
198
+ sleep(0.01)
192
199
  content = IO.read('log/agoo.log.1')
193
200
  assert_match(/"where":"WARN"/, content)
194
201
  assert_match(/"level":2/, content)
@@ -198,6 +205,7 @@ class LogJsonTest < Minitest::Test
198
205
  def info_test(server)
199
206
  server.info('my message')
200
207
  server.log_flush(1.0)
208
+ sleep(0.01)
201
209
  content = IO.read('log/agoo.log.1')
202
210
  assert_match(/"where":"INFO"/, content)
203
211
  assert_match(/"level":3/, content)
@@ -207,6 +215,7 @@ class LogJsonTest < Minitest::Test
207
215
  def debug_test(server)
208
216
  server.debug('my message')
209
217
  server.log_flush(1.0)
218
+ sleep(0.01)
210
219
  content = IO.read('log/agoo.log.1')
211
220
  assert_match(/"where":"DEBUG"/, content)
212
221
  assert_match(/"level":4/, content)
@@ -216,6 +225,7 @@ class LogJsonTest < Minitest::Test
216
225
  def eval_test(server)
217
226
  server.log_eval('my message')
218
227
  server.log_flush(1.0)
228
+ sleep(0.01)
219
229
  content = IO.read('log/agoo.log.1')
220
230
  assert_match(/"where":"eval"/, content)
221
231
  assert_match(/"level":3/, content)
@@ -245,6 +255,7 @@ class LogRollTest < Minitest::Test
245
255
  @server.info("my #{i} message")
246
256
  }
247
257
  @server.log_flush(1.0)
258
+ sleep(0.01)
248
259
  content = IO.read('log/agoo.log')
249
260
  assert_match(/INFO: my 9 message/, content)
250
261
 
@@ -42,7 +42,7 @@ class RackHandlerTest < Minitest::Test
42
42
 
43
43
  def test_rack
44
44
  begin
45
- server = Agoo::Server.new(6465, 'root',
45
+ server = Agoo::Server.new(6467, 'root',
46
46
  pedantic: false,
47
47
  log_dir: '',
48
48
  thread_count: 1,
@@ -63,6 +63,7 @@ class RackHandlerTest < Minitest::Test
63
63
  server.handle(:GET, "/tellme", handler)
64
64
  server.handle(:POST, "/makeme", handler)
65
65
  server.handle(:PUT, "/makeme", handler)
66
+
66
67
  server.start()
67
68
 
68
69
  eval_test
@@ -74,7 +75,7 @@ class RackHandlerTest < Minitest::Test
74
75
  end
75
76
 
76
77
  def eval_test
77
- uri = URI('http://localhost:6465/tellme?a=1')
78
+ uri = URI('http://localhost:6467/tellme?a=1')
78
79
  req = Net::HTTP::Get.new(uri)
79
80
  # Set the headers the way we want them.
80
81
  req['Accept-Encoding'] = '*'
@@ -96,7 +97,7 @@ class RackHandlerTest < Minitest::Test
96
97
  "REQUEST_METHOD" => "GET",
97
98
  "SCRIPT_NAME" => "/tellme",
98
99
  "SERVER_NAME" => "localhost",
99
- "SERVER_PORT" => "6465",
100
+ "SERVER_PORT" => "6467",
100
101
  "rack.errors" => nil,
101
102
  "rack.input" => nil,
102
103
  "rack.multiprocess" => false,
@@ -115,7 +116,7 @@ class RackHandlerTest < Minitest::Test
115
116
  end
116
117
 
117
118
  def post_test
118
- uri = URI('http://localhost:6465/makeme')
119
+ uri = URI('http://localhost:6467/makeme')
119
120
  req = Net::HTTP::Post.new(uri)
120
121
  # Set the headers the way we want them.
121
122
  req['Accept-Encoding'] = '*'
@@ -129,7 +130,7 @@ class RackHandlerTest < Minitest::Test
129
130
  end
130
131
 
131
132
  def put_test
132
- uri = URI('http://localhost:6465/makeme')
133
+ uri = URI('http://localhost:6467/makeme')
133
134
  req = Net::HTTP::Put.new(uri)
134
135
  # Set the headers the way we want them.
135
136
  req['Accept-Encoding'] = '*'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler