agoo 2.2.0 → 2.2.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: 2aebba91a863e1bdbaa53c1d31560728968f7d2e27c27af21691bf8d502f4afb
4
- data.tar.gz: e0b3efd1eaa9dbe2629738c3b8ecdc0e61e208ae94f54598a182791c23d4873c
3
+ metadata.gz: d44ba7a7229894d86dba33f2138fc300cf1885c20078709fda7ebe9264e4a6fe
4
+ data.tar.gz: 411a5541b7d47bd2dd5dc68a45401206787b026599c33eff3544a71757cf8072
5
5
  SHA512:
6
- metadata.gz: 82944a0b58ea473b2b4228c3d59901b29fdae19ef3ad1711a84980d7d2028418abaeb9f05b93d4d7f8649e0ceeb3bebaaaa5d448ac48dcbc647cdeeaf494a169
7
- data.tar.gz: 84894610f09ea3a7c089cc11e4edc3479bf641dda306f7e9dbf89fc88e4c0c8018d0d84a8e7df98c6296215f9c4a26cacc6b3c593e63b869308177f820411cee
6
+ metadata.gz: 21ecc474d333acad22a54e781b135eb450273d0f6662c1566dd0b1949e9db3051db08264021b99fe01cd2fc819e7fab56abec3bbbb0dfd04b7fc6bc4a05f82e9
7
+ data.tar.gz: b7f92457d97efd991b2a8e54bc1c0ae488482dcde217f32a2a2ea6d4f07536cab3b97341aebf0eadeaa514c03251a97e85510e3bf7b185aa43007f52a130bacc
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ### 2.2.1 - 2018-05-31
4
+
5
+ - Corrected header bug where a `:` in the value would cause an incorrect header key and value.
6
+
7
+ - Improved idle CPU use.
8
+
3
9
  ### 2.2.0 - 2018-05-30
4
10
 
5
11
  - Clustering now supported with forked workers making Agoo even faster.
@@ -1,6 +1,8 @@
1
1
  // Copyright 2018 by Peter Ohler, All Rights Reserved
2
2
 
3
3
  #include <dirent.h>
4
+ #include <fcntl.h>
5
+ #include <poll.h>
4
6
  #include <stdio.h>
5
7
  #include <stdlib.h>
6
8
  #include <string.h>
@@ -8,6 +10,7 @@
8
10
  #include <sys/time.h>
9
11
  #include <sys/types.h>
10
12
  #include <time.h>
13
+ #include <unistd.h>
11
14
 
12
15
  #include "debug.h"
13
16
  #include "dtime.h"
@@ -15,6 +18,7 @@
15
18
 
16
19
  // lower gives faster response but burns more CPU. This is a reasonable compromise.
17
20
  #define RETRY_SECS 0.0001
21
+ #define WAIT_MSECS 100
18
22
  #define NOT_WAITING 0
19
23
  #define WAITING 1
20
24
  #define NOTIFIED 2
@@ -90,11 +94,37 @@ log_queue_empty() {
90
94
  return false;
91
95
  }
92
96
 
97
+ static int
98
+ log_listen() {
99
+ if (0 == the_log.rsock) {
100
+ int fd[2];
101
+
102
+ if (0 == pipe(fd)) {
103
+ fcntl(fd[0], F_SETFL, O_NONBLOCK);
104
+ fcntl(fd[1], F_SETFL, O_NONBLOCK);
105
+ the_log.rsock = fd[0];
106
+ the_log.wsock = fd[1];
107
+ }
108
+ }
109
+ atomic_store(&the_log.wait_state, WAITING);
110
+
111
+ return the_log.rsock;
112
+ }
113
+
114
+ static void
115
+ log_release() {
116
+ char buf[8];
117
+
118
+ // clear pipe
119
+ while (0 < read(the_log.rsock, buf, sizeof(buf))) {
120
+ }
121
+ atomic_store(&the_log.wait_state, NOT_WAITING);
122
+ }
123
+
93
124
  static LogEntry
94
125
  log_queue_pop(double timeout) {
95
126
  LogEntry e = the_log.head;
96
127
  LogEntry next;
97
-
98
128
  if (e->ready) {
99
129
  return e;
100
130
  }
@@ -103,12 +133,18 @@ log_queue_pop(double timeout) {
103
133
  next = the_log.q;
104
134
  }
105
135
  // If the next is the tail then wait for something to be appended.
106
- for (int cnt = (int)(timeout / RETRY_SECS); atomic_load(&the_log.tail) == next; cnt--) {
107
- // TBD poll would be better
136
+ for (int cnt = (int)(timeout / (double)WAIT_MSECS * 1000.0); atomic_load(&the_log.tail) == next; cnt--) {
137
+ struct pollfd pa;
138
+
108
139
  if (cnt <= 0) {
109
140
  return NULL;
110
141
  }
111
- dsleep(RETRY_SECS);
142
+ pa.fd = log_listen();
143
+ pa.events = POLLIN;
144
+ pa.revents = 0;
145
+ if (0 < poll(&pa, 1, WAIT_MSECS)) {
146
+ log_release();
147
+ }
112
148
  }
113
149
  atomic_store(&the_log.head, next);
114
150
 
@@ -313,6 +349,7 @@ open_log_file() {
313
349
  if (the_log.max_size <= the_log.size) {
314
350
  log_rotate();
315
351
  }
352
+ // TBD open rscok and wsock
316
353
  }
317
354
 
318
355
  void
@@ -937,6 +974,7 @@ log_start(bool with_pid) {
937
974
  if (NULL != the_log.file) {
938
975
  fclose(the_log.file);
939
976
  the_log.file = NULL;
977
+ // TBD close rsock and wsock
940
978
  }
941
979
  the_log.with_pid = with_pid;
942
980
  if (with_pid && '\0' != *the_log.dir) {
@@ -1,6 +1,7 @@
1
1
  // Copyright 2015, 2016, 2018 by Peter Ohler, All Rights Reserved
2
2
 
3
3
  #include <fcntl.h>
4
+ #include <poll.h>
4
5
  #include <stdio.h>
5
6
  #include <stdlib.h>
6
7
  #include <string.h>
@@ -14,6 +15,7 @@
14
15
 
15
16
  // lower gives faster response but burns more CPU. This is a reasonable compromise.
16
17
  #define RETRY_SECS 0.0001
18
+ #define WAIT_MSECS 100
17
19
 
18
20
  #define NOT_WAITING 0
19
21
  #define WAITING 1
@@ -126,14 +128,21 @@ queue_pop(Queue q, double timeout) {
126
128
  next = q->q;
127
129
  }
128
130
  // If the next is the tail then wait for something to be appended.
129
- for (int cnt = (int)(timeout / RETRY_SECS); atomic_load(&q->tail) == next; cnt--) {
131
+ for (int cnt = (int)(timeout / (double)WAIT_MSECS * 1000.0); atomic_load(&q->tail) == next; cnt--) {
132
+ struct pollfd pa;
133
+
130
134
  if (cnt <= 0) {
131
135
  if (q->multi_pop) {
132
136
  atomic_flag_clear(&q->pop_lock);
133
137
  }
134
138
  return NULL;
135
139
  }
136
- dsleep(RETRY_SECS);
140
+ pa.fd = queue_listen(q);
141
+ pa.events = POLLIN;
142
+ pa.revents = 0;
143
+ if (0 < poll(&pa, 1, WAIT_MSECS)) {
144
+ queue_release(q);
145
+ }
137
146
  }
138
147
  atomic_store(&q->head, next);
139
148
 
@@ -395,7 +395,7 @@ add_header_value(VALUE hh, const char *key, int klen, const char *val, int vlen)
395
395
  strncpy(k, key, klen);
396
396
  hkey[klen + 5] = '\0';
397
397
 
398
- rb_hash_aset(hh, rb_str_new(hkey, klen + 5), sval);
398
+ //rb_hash_aset(hh, rb_str_new(hkey, klen + 5), sval);
399
399
  // Contrary to the Rack spec, Rails expects all upper case keys so add those as well.
400
400
  for (k = hkey + 5; '\0' != *k; k++) {
401
401
  if ('-' == *k) {
@@ -423,11 +423,14 @@ fill_headers(Req r, VALUE hash) {
423
423
  if (NULL == r) {
424
424
  rb_raise(rb_eArgError, "Request is no longer valid.");
425
425
  }
426
+
426
427
  for (; h < end; h++) {
427
428
  switch (*h) {
428
429
  case ':':
429
- kend = h;
430
- val = h + 1;
430
+ if (NULL == val) {
431
+ kend = h;
432
+ val = h + 1;
433
+ }
431
434
  break;
432
435
  case '\r':
433
436
  if (NULL != val) {
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Agoo
3
3
  # Agoo version.
4
- VERSION = '2.2.0'
4
+ VERSION = '2.2.1'
5
5
  end
@@ -95,9 +95,9 @@ class BaseHandlerTest < Minitest::Test
95
95
  obj = Oj.load(content, mode: :strict)
96
96
 
97
97
  expect = {
98
- "HTTP_Accept" => "application/json",
99
- "HTTP_Accept-Encoding" => "*",
100
- "HTTP_User-Agent" => "Ruby",
98
+ "HTTP_ACCEPT" => "application/json",
99
+ "HTTP_ACCEPT_ENCODING" => "*",
100
+ "HTTP_USER_AGENT" => "Ruby",
101
101
  "PATH_INFO" => "/tellme",
102
102
  "QUERY_STRING" => "a=1",
103
103
  "REQUEST_METHOD" => "GET",
@@ -79,17 +79,18 @@ class RackHandlerTest < Minitest::Test
79
79
  req['Accept-Encoding'] = '*'
80
80
  req['Accept'] = 'application/json'
81
81
  req['User-Agent'] = 'Ruby'
82
+ req['Host'] = 'localhost:6467'
82
83
 
83
84
  res = Net::HTTP.start(uri.hostname, uri.port) { |h|
84
85
  h.request(req)
85
86
  }
86
87
  content = res.body
87
88
  obj = Oj.load(content, mode: :strict)
88
-
89
89
  expect = {
90
- "HTTP_Accept" => "application/json",
91
- "HTTP_Accept-Encoding" => "*",
92
- "HTTP_User-Agent" => "Ruby",
90
+ "HTTP_ACCEPT" => "application/json",
91
+ "HTTP_ACCEPT_ENCODING" => "*",
92
+ "HTTP_USER_AGENT" => "Ruby",
93
+ "HTTP_HOST" => "localhost:6467",
93
94
  "PATH_INFO" => "/tellme",
94
95
  "QUERY_STRING" => "a=1",
95
96
  "REQUEST_METHOD" => "GET",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-30 00:00:00.000000000 Z
11
+ date: 2018-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj