agoo 2.5.5 → 2.5.6

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.

Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/README.md +1 -1
  4. data/ext/agoo/agoo.c +4 -3
  5. data/ext/agoo/atomic.h +120 -0
  6. data/ext/agoo/bind.c +52 -52
  7. data/ext/agoo/bind.h +13 -13
  8. data/ext/agoo/con.c +499 -481
  9. data/ext/agoo/con.h +47 -39
  10. data/ext/agoo/debug.c +42 -42
  11. data/ext/agoo/debug.h +1 -1
  12. data/ext/agoo/doc.c +17 -17
  13. data/ext/agoo/doc.h +12 -12
  14. data/ext/agoo/err.c +18 -18
  15. data/ext/agoo/err.h +27 -27
  16. data/ext/agoo/error_stream.c +9 -9
  17. data/ext/agoo/extconf.rb +3 -0
  18. data/ext/agoo/gqlintro.c +43 -43
  19. data/ext/agoo/gqlintro.h +1 -1
  20. data/ext/agoo/gqlvalue.c +131 -131
  21. data/ext/agoo/gqlvalue.h +32 -32
  22. data/ext/agoo/graphql.c +158 -158
  23. data/ext/agoo/graphql.h +34 -33
  24. data/ext/agoo/hook.c +15 -14
  25. data/ext/agoo/hook.h +18 -14
  26. data/ext/agoo/http.c +14 -14
  27. data/ext/agoo/http.h +4 -4
  28. data/ext/agoo/kinds.h +5 -5
  29. data/ext/agoo/log.c +232 -224
  30. data/ext/agoo/log.h +93 -93
  31. data/ext/agoo/method.h +17 -17
  32. data/ext/agoo/page.c +88 -86
  33. data/ext/agoo/page.h +21 -21
  34. data/ext/agoo/pub.c +36 -36
  35. data/ext/agoo/pub.h +23 -23
  36. data/ext/agoo/queue.c +37 -38
  37. data/ext/agoo/queue.h +20 -19
  38. data/ext/agoo/rack_logger.c +13 -13
  39. data/ext/agoo/ready.c +357 -0
  40. data/ext/agoo/ready.h +41 -0
  41. data/ext/agoo/req.c +11 -11
  42. data/ext/agoo/req.h +30 -31
  43. data/ext/agoo/request.c +46 -46
  44. data/ext/agoo/request.h +2 -2
  45. data/ext/agoo/res.c +40 -18
  46. data/ext/agoo/res.h +14 -14
  47. data/ext/agoo/response.c +6 -6
  48. data/ext/agoo/response.h +9 -9
  49. data/ext/agoo/rhook.c +3 -3
  50. data/ext/agoo/rhook.h +1 -1
  51. data/ext/agoo/rlog.c +47 -42
  52. data/ext/agoo/rlog.h +0 -1
  53. data/ext/agoo/rresponse.c +33 -33
  54. data/ext/agoo/rresponse.h +1 -1
  55. data/ext/agoo/rserver.c +184 -175
  56. data/ext/agoo/rserver.h +2 -2
  57. data/ext/agoo/rupgraded.c +41 -41
  58. data/ext/agoo/rupgraded.h +3 -3
  59. data/ext/agoo/sdl.c +80 -80
  60. data/ext/agoo/sdl.h +1 -1
  61. data/ext/agoo/seg.h +2 -2
  62. data/ext/agoo/server.c +143 -117
  63. data/ext/agoo/server.h +43 -42
  64. data/ext/agoo/sse.c +7 -7
  65. data/ext/agoo/sse.h +4 -4
  66. data/ext/agoo/subject.c +5 -5
  67. data/ext/agoo/subject.h +6 -6
  68. data/ext/agoo/text.c +21 -21
  69. data/ext/agoo/text.h +14 -13
  70. data/ext/agoo/upgraded.c +41 -40
  71. data/ext/agoo/upgraded.h +41 -40
  72. data/ext/agoo/websocket.c +42 -42
  73. data/ext/agoo/websocket.h +16 -16
  74. data/lib/agoo/version.rb +1 -1
  75. data/test/static_test.rb +2 -0
  76. metadata +5 -5
  77. data/ext/agoo/log_queue.h +0 -30
  78. data/ext/agoo/sub.c +0 -111
  79. data/ext/agoo/sub.h +0 -36
@@ -5,6 +5,6 @@
5
5
 
6
6
  #include "err.h"
7
7
 
8
- extern int sdl_parse(Err err, const char *str, int len);
8
+ extern int sdl_parse(agooErr err, const char *str, int len);
9
9
 
10
10
  #endif // AGOO_SDL_H
@@ -3,9 +3,9 @@
3
3
  #ifndef AGOO_SEG_H
4
4
  #define AGOO_SEG_H
5
5
 
6
- typedef struct _Seg {
6
+ typedef struct _agooSeg {
7
7
  char *start;
8
8
  char *end;
9
- } *Seg;
9
+ } *agooSeg;
10
10
 
11
11
  #endif // AGOO_SEG_H
@@ -20,31 +20,40 @@
20
20
 
21
21
  #include "server.h"
22
22
 
23
- #define LOOP_UP 512
24
- #define MAX_LOOP 4
23
+ #define LOOP_UP 100
25
24
 
26
- struct _Server the_server = {false};
25
+ struct _agooServer agoo_server = {false};
27
26
 
28
27
  void
29
- server_setup() {
30
- memset(&the_server, 0, sizeof(struct _Server));
31
- pthread_mutex_init(&the_server.up_lock, 0);
32
- the_server.up_list = NULL;
33
- the_server.max_push_pending = 32;
34
- pages_init();
35
- queue_multi_init(&the_server.con_queue, 1024, false, true);
36
- queue_multi_init(&the_server.eval_queue, 1024, true, true);
28
+ agoo_server_setup() {
29
+ long i;
30
+
31
+ memset(&agoo_server, 0, sizeof(struct _agooServer));
32
+ pthread_mutex_init(&agoo_server.up_lock, 0);
33
+ agoo_server.up_list = NULL;
34
+ agoo_server.max_push_pending = 32;
35
+ agoo_pages_init();
36
+ agoo_queue_multi_init(&agoo_server.con_queue, 1024, false, true);
37
+ agoo_queue_multi_init(&agoo_server.eval_queue, 1024, true, true);
38
+ agoo_server.loop_max = 4;
39
+ if (0 < (i = sysconf(_SC_NPROCESSORS_ONLN))) {
40
+ i /= 2;
41
+ if (1 >= i) {
42
+ i = 1;
43
+ }
44
+ agoo_server.loop_max = (int)i;
45
+ }
37
46
  }
38
47
 
39
48
  static void
40
49
  add_con_loop() {
41
- struct _Err err = ERR_INIT;
42
- ConLoop loop = conloop_create(&err, 0);
50
+ struct _agooErr err = AGOO_ERR_INIT;
51
+ agooConLoop loop = agoo_conloop_create(&err, 0);
43
52
 
44
53
  if (NULL != loop) {
45
- loop->next = the_server.con_loops;
46
- the_server.con_loops = loop;
47
- the_server.loop_cnt++;
54
+ loop->next = agoo_server.con_loops;
55
+ agoo_server.con_loops = loop;
56
+ agoo_server.loop_cnt++;
48
57
  }
49
58
  }
50
59
 
@@ -53,46 +62,46 @@ listen_loop(void *x) {
53
62
  int optval = 1;
54
63
  struct pollfd pa[100];
55
64
  struct pollfd *p;
56
- struct _Err err = ERR_INIT;
65
+ struct _agooErr err = AGOO_ERR_INIT;
57
66
  struct sockaddr_in client_addr;
58
67
  int client_sock;
59
68
  int pcnt = 0;
60
69
  socklen_t alen = 0;
61
- Con con;
70
+ agooCon con;
62
71
  int i;
63
72
  uint64_t cnt = 0;
64
- Bind b;
73
+ agooBind b;
65
74
 
66
75
  // TBD support multiple sockets, count binds, allocate pollfd, setup
67
76
  //
68
- for (b = the_server.binds, p = pa; NULL != b; b = b->next, p++, pcnt++) {
77
+ for (b = agoo_server.binds, p = pa; NULL != b; b = b->next, p++, pcnt++) {
69
78
  p->fd = b->fd;
70
79
  p->events = POLLIN;
71
80
  p->revents = 0;
72
81
  }
73
82
  memset(&client_addr, 0, sizeof(client_addr));
74
- atomic_fetch_add(&the_server.running, 1);
75
- while (the_server.active) {
83
+ atomic_fetch_add(&agoo_server.running, 1);
84
+ while (agoo_server.active) {
76
85
  if (0 > (i = poll(pa, pcnt, 200))) {
77
86
  if (EAGAIN == errno) {
78
87
  continue;
79
88
  }
80
- log_cat(&error_cat, "Server polling error. %s.", strerror(errno));
89
+ agoo_log_cat(&agoo_error_cat, "Server polling error. %s.", strerror(errno));
81
90
  // Either a signal or something bad like out of memory. Might as well exit.
82
91
  break;
83
92
  }
84
93
  if (0 == i) { // nothing to read
85
94
  continue;
86
95
  }
87
- for (b = the_server.binds, p = pa; NULL != b; b = b->next, p++) {
96
+ for (b = agoo_server.binds, p = pa; NULL != b; b = b->next, p++) {
88
97
  if (0 != (p->revents & POLLIN)) {
89
98
  if (0 > (client_sock = accept(p->fd, (struct sockaddr*)&client_addr, &alen))) {
90
- log_cat(&error_cat, "Server with pid %d accept connection failed. %s.", getpid(), strerror(errno));
91
- } else if (NULL == (con = con_create(&err, client_sock, ++cnt, b))) {
92
- log_cat(&error_cat, "Server with pid %d accept connection failed. %s.", getpid(), err.msg);
99
+ agoo_log_cat(&agoo_error_cat, "Server with pid %d accept connection failed. %s.", getpid(), strerror(errno));
100
+ } else if (NULL == (con = agoo_con_create(&err, client_sock, ++cnt, b))) {
101
+ agoo_log_cat(&agoo_error_cat, "Server with pid %d accept connection failed. %s.", getpid(), err.msg);
93
102
  close(client_sock);
94
103
  cnt--;
95
- err_clear(&err);
104
+ agoo_err_clear(&err);
96
105
  } else {
97
106
  int con_cnt;
98
107
  #ifdef OSX_OS
@@ -105,201 +114,218 @@ listen_loop(void *x) {
105
114
  //fcntl(client_sock, F_SETFL, FNDELAY);
106
115
  setsockopt(client_sock, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval));
107
116
  setsockopt(client_sock, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof(optval));
108
- log_cat(&con_cat, "Server with pid %d accepted connection %llu on %s [%d]",
109
- getpid(), (unsigned long long)cnt, b->id, con->sock);
117
+ agoo_log_cat(&agoo_con_cat, "Server with pid %d accepted connection %llu on %s [%d]",
118
+ getpid(), (unsigned long long)cnt, b->id, con->sock);
110
119
 
111
- con_cnt = atomic_fetch_add(&the_server.con_cnt, 1);
112
- if (MAX_LOOP > the_server.loop_cnt && the_server.loop_cnt * LOOP_UP < con_cnt) {
120
+ con_cnt = atomic_fetch_add(&agoo_server.con_cnt, 1);
121
+ if (agoo_server.loop_max > agoo_server.loop_cnt && agoo_server.loop_cnt * LOOP_UP < con_cnt) {
113
122
  add_con_loop();
114
123
  }
115
- queue_push(&the_server.con_queue, (void*)con);
124
+ agoo_queue_push(&agoo_server.con_queue, (void*)con);
116
125
  }
117
126
  }
118
127
  if (0 != (p->revents & (POLLERR | POLLHUP | POLLNVAL))) {
119
128
  if (0 != (p->revents & (POLLHUP | POLLNVAL))) {
120
- log_cat(&error_cat, "Agoo server with pid %d socket on %s closed.", getpid(), b->id);
129
+ agoo_log_cat(&agoo_error_cat, "Agoo server with pid %d socket on %s closed.", getpid(), b->id);
121
130
  } else {
122
- log_cat(&error_cat, "Agoo server with pid %d socket on %s error.", getpid(), b->id);
131
+ agoo_log_cat(&agoo_error_cat, "Agoo server with pid %d socket on %s error.", getpid(), b->id);
123
132
  }
124
- the_server.active = false;
133
+ agoo_server.active = false;
125
134
  }
126
135
  p->revents = 0;
127
136
  }
128
137
  }
129
- for (b = the_server.binds; NULL != b; b = b->next) {
130
- bind_close(b);
138
+ for (b = agoo_server.binds; NULL != b; b = b->next) {
139
+ agoo_bind_close(b);
131
140
  }
132
- atomic_fetch_sub(&the_server.running, 1);
141
+ atomic_fetch_sub(&agoo_server.running, 1);
133
142
 
134
143
  return NULL;
135
144
  }
136
145
 
137
146
  int
138
- server_start(Err err, const char *app_name, const char *version) {
147
+ agoo_server_start(agooErr err, const char *app_name, const char *version) {
139
148
  double giveup;
149
+ int xcnt = 0;
150
+ int stat;
140
151
 
141
- pthread_create(&the_server.listen_thread, NULL, listen_loop, NULL);
142
- the_server.con_loops = conloop_create(err, 0);
143
- the_server.loop_cnt = 1;
144
-
152
+ if (0 != (stat = pthread_create(&agoo_server.listen_thread, NULL, listen_loop, NULL))) {
153
+ return agoo_err_set(err, stat, "Failed to create server listener thread. %s", strerror(stat));
154
+ }
155
+ xcnt++;
156
+ agoo_server.con_loops = agoo_conloop_create(err, 0);
157
+ agoo_server.loop_cnt = 1;
158
+ xcnt++;
159
+
160
+ // If the eval thread count is 1 that implies the eval load is low so
161
+ // might as well create the maximum number of con threads as is
162
+ // reasonable.
163
+ if (1 >= agoo_server.thread_cnt) {
164
+ while (agoo_server.loop_cnt < agoo_server.loop_max) {
165
+ add_con_loop();
166
+ xcnt++;
167
+ }
168
+ }
145
169
  giveup = dtime() + 1.0;
146
170
  while (dtime() < giveup) {
147
- if (2 <= atomic_load(&the_server.running)) {
171
+ if (xcnt <= (long)atomic_load(&agoo_server.running)) {
148
172
  break;
149
173
  }
150
174
  dsleep(0.01);
151
175
  }
152
- if (info_cat.on) {
153
- Bind b;
176
+ if (agoo_info_cat.on) {
177
+ agooBind b;
154
178
 
155
- for (b = the_server.binds; NULL != b; b = b->next) {
156
- log_cat(&info_cat, "%s %s with pid %d is listening on %s.", app_name, version, getpid(), b->id);
179
+ for (b = agoo_server.binds; NULL != b; b = b->next) {
180
+ agoo_log_cat(&agoo_info_cat, "%s %s with pid %d is listening on %s.", app_name, version, getpid(), b->id);
157
181
  }
158
182
  }
159
- return ERR_OK;
183
+ return AGOO_ERR_OK;
160
184
  }
161
185
 
162
186
  int
163
- setup_listen(Err err) {
164
- Bind b;
187
+ setup_listen(agooErr err) {
188
+ agooBind b;
165
189
 
166
- for (b = the_server.binds; NULL != b; b = b->next) {
167
- if (ERR_OK != bind_listen(err, b)) {
190
+ for (b = agoo_server.binds; NULL != b; b = b->next) {
191
+ if (AGOO_ERR_OK != agoo_bind_listen(err, b)) {
168
192
  return err->code;
169
193
  }
170
194
  }
171
- the_server.active = true;
195
+ agoo_server.active = true;
172
196
 
173
- return ERR_OK;
197
+ return AGOO_ERR_OK;
174
198
  }
175
199
 
176
200
  void
177
- server_shutdown(const char *app_name, void (*stop)()) {
178
- if (the_server.inited) {
179
- ConLoop loop;
201
+ agoo_server_shutdown(const char *app_name, void (*stop)()) {
202
+ if (agoo_server.inited) {
203
+ agooConLoop loop;
180
204
 
181
- log_cat(&info_cat, "%s with pid %d shutting down.", app_name, getpid());
182
- the_server.inited = false;
183
- if (the_server.active) {
205
+ agoo_log_cat(&agoo_info_cat, "%s with pid %d shutting down.", app_name, getpid());
206
+ agoo_server.inited = false;
207
+ if (agoo_server.active) {
184
208
  double giveup = dtime() + 1.0;
185
209
 
186
- the_server.active = false;
187
- pthread_detach(the_server.listen_thread);
188
- for (loop = the_server.con_loops; NULL != loop; loop = loop->next) {
210
+ agoo_server.active = false;
211
+ pthread_detach(agoo_server.listen_thread);
212
+ for (loop = agoo_server.con_loops; NULL != loop; loop = loop->next) {
189
213
  pthread_detach(loop->thread);
190
214
  }
191
- while (0 < atomic_load(&the_server.running)) {
215
+ while (0 < (long)atomic_load(&agoo_server.running)) {
192
216
  dsleep(0.1);
193
217
  if (giveup < dtime()) {
194
218
  break;
195
219
  }
196
220
  }
197
- stop();
198
-
199
- while (NULL != the_server.hooks) {
200
- Hook h = the_server.hooks;
221
+ if (NULL != stop) {
222
+ stop();
223
+ }
224
+ while (NULL != agoo_server.hooks) {
225
+ agooHook h = agoo_server.hooks;
201
226
 
202
- the_server.hooks = h->next;
203
- hook_destroy(h);
227
+ agoo_server.hooks = h->next;
228
+ agoo_hook_destroy(h);
204
229
  }
205
230
  }
206
- while (NULL != the_server.binds) {
207
- Bind b = the_server.binds;
231
+ while (NULL != agoo_server.binds) {
232
+ agooBind b = agoo_server.binds;
208
233
 
209
- the_server.binds = b->next;
210
- bind_destroy(b);
234
+ agoo_server.binds = b->next;
235
+ agoo_bind_destroy(b);
211
236
  }
212
- queue_cleanup(&the_server.con_queue);
213
- for (loop = the_server.con_loops; NULL != loop; loop = loop->next) {
214
- queue_cleanup(&loop->pub_queue);
237
+ agoo_queue_cleanup(&agoo_server.con_queue);
238
+ while (NULL != (loop = agoo_server.con_loops)) {
239
+ agoo_server.con_loops = loop->next;
240
+ agoo_conloop_destroy(loop);
215
241
  }
216
- queue_cleanup(&the_server.eval_queue);
242
+ agoo_queue_cleanup(&agoo_server.eval_queue);
217
243
 
218
- pages_cleanup();
219
- http_cleanup();
244
+ agoo_pages_cleanup();
245
+ agoo_http_cleanup();
220
246
  }
221
247
  }
222
248
 
223
249
  void
224
- server_bind(Bind b) {
250
+ agoo_server_bind(agooBind b) {
225
251
  // If a bind with the same port already exists, replace it.
226
- Bind prev = NULL;
252
+ agooBind prev = NULL;
227
253
 
228
254
  if (NULL == b->read) {
229
- b->read = con_http_read;
255
+ b->read = agoo_con_http_read;
230
256
  }
231
257
  if (NULL == b->write) {
232
- b->write = con_http_write;
258
+ b->write = agoo_con_http_write;
233
259
  }
234
260
  if (NULL == b->events) {
235
- b->events = con_http_events;
261
+ b->events = agoo_con_http_events;
236
262
  }
237
- for (Bind bx = the_server.binds; NULL != bx; bx = bx->next) {
263
+ for (agooBind bx = agoo_server.binds; NULL != bx; bx = bx->next) {
238
264
  if (bx->port == b->port) {
239
265
  b->next = bx->next;
240
266
  if (NULL == prev) {
241
- the_server.binds = b;
267
+ agoo_server.binds = b;
242
268
  } else {
243
269
  prev->next = b;
244
270
  }
245
- bind_destroy(bx);
271
+ agoo_bind_destroy(bx);
246
272
  return;
247
273
  }
248
274
  prev = bx;
249
275
  }
250
- b->next = the_server.binds;
251
- the_server.binds = b;
276
+ b->next = agoo_server.binds;
277
+ agoo_server.binds = b;
252
278
  }
253
279
 
254
280
  void
255
- server_add_upgraded(Upgraded up) {
256
- pthread_mutex_lock(&the_server.up_lock);
257
- if (NULL == the_server.up_list) {
281
+ agoo_server_add_upgraded(agooUpgraded up) {
282
+ pthread_mutex_lock(&agoo_server.up_lock);
283
+ if (NULL == agoo_server.up_list) {
258
284
  up->next = NULL;
259
285
  } else {
260
- the_server.up_list->prev = up;
286
+ agoo_server.up_list->prev = up;
261
287
  }
262
- up->next = the_server.up_list;
263
- the_server.up_list = up;
288
+ up->next = agoo_server.up_list;
289
+ agoo_server.up_list = up;
264
290
  up->con->up = up;
265
- pthread_mutex_unlock(&the_server.up_lock);
291
+ pthread_mutex_unlock(&agoo_server.up_lock);
266
292
  }
267
293
 
268
294
  int
269
- server_add_func_hook(Err err,
270
- Method method,
271
- const char *pattern,
272
- void (*func)(Req req),
273
- Queue queue,
274
- bool quick) {
275
- Hook h;
276
- Hook prev = NULL;
277
- Hook hook = hook_func_create(method, pattern, func, queue);
295
+ agoo_server_add_func_hook(agooErr err,
296
+ agooMethod method,
297
+ const char *pattern,
298
+ void (*func)(agooReq req),
299
+ agooQueue queue,
300
+ bool quick) {
301
+ agooHook h;
302
+ agooHook prev = NULL;
303
+ agooHook hook = agoo_hook_func_create(method, pattern, func, queue);
278
304
 
279
305
  if (NULL == hook) {
280
- return err_set(err, ERR_MEMORY, "failed to allocate memory for HTTP server Hook.");
306
+ return agoo_err_set(err, AGOO_ERR_MEMORY, "failed to allocate memory for HTTP server Hook.");
281
307
  }
282
308
  hook->no_queue = quick;
283
- for (h = the_server.hooks; NULL != h; h = h->next) {
309
+ for (h = agoo_server.hooks; NULL != h; h = h->next) {
284
310
  prev = h;
285
311
  }
286
312
  if (NULL != prev) {
287
313
  prev->next = hook;
288
314
  } else {
289
- the_server.hooks = hook;
315
+ agoo_server.hooks = hook;
290
316
  }
291
- return ERR_OK;
317
+ return AGOO_ERR_OK;
292
318
  }
293
319
 
294
320
  void
295
- server_publish(struct _Pub *pub) {
296
- ConLoop loop;
321
+ agoo_server_publish(struct _agooPub *pub) {
322
+ agooConLoop loop;
297
323
 
298
- for (loop = the_server.con_loops; NULL != loop; loop = loop->next) {
324
+ for (loop = agoo_server.con_loops; NULL != loop; loop = loop->next) {
299
325
  if (NULL == loop->next) {
300
- queue_push(&loop->pub_queue, pub);
326
+ agoo_queue_push(&loop->pub_queue, pub);
301
327
  } else {
302
- queue_push(&loop->pub_queue, pub_dup(pub));
328
+ agoo_queue_push(&loop->pub_queue, agoo_pub_dup(pub));
303
329
  }
304
330
  }
305
331
  }
@@ -5,64 +5,65 @@
5
5
 
6
6
  #include <pthread.h>
7
7
  #include <stdbool.h>
8
- #include <stdatomic.h>
9
8
 
9
+ #include "atomic.h"
10
10
  #include "bind.h"
11
11
  #include "err.h"
12
12
  #include "hook.h"
13
13
  #include "queue.h"
14
14
 
15
- struct _ConLoop;
16
- struct _Pub;
17
- struct _Req;
18
- struct _Upgraded;
15
+ struct _agooCon;
16
+ struct _agooConLoop;
17
+ struct _agooPub;
18
+ struct _agooReq;
19
+ struct _agooUpgraded;
19
20
 
20
- typedef struct _Server {
21
- volatile bool inited;
22
- volatile bool active;
23
- int thread_cnt;
24
- bool pedantic;
25
- bool root_first;
26
- pthread_t listen_thread;
27
- struct _Queue con_queue;
28
- Hook hooks;
29
- Hook hook404;
30
- Bind binds;
21
+ typedef struct _agooServer {
22
+ volatile bool inited;
23
+ volatile bool active;
24
+ int thread_cnt;
25
+ bool pedantic;
26
+ bool root_first;
27
+ pthread_t listen_thread;
28
+ struct _agooQueue con_queue;
29
+ agooHook hooks;
30
+ agooHook hook404;
31
+ agooBind binds;
31
32
 
32
- struct _Queue eval_queue;
33
+ struct _agooQueue eval_queue;
33
34
 
34
- struct _ConLoop *con_loops;
35
- int loop_cnt;
36
- atomic_int con_cnt;
35
+ struct _agooConLoop *con_loops;
36
+ int loop_max;
37
+ int loop_cnt;
38
+ atomic_int con_cnt;
37
39
 
38
- struct _Upgraded *up_list;
39
- pthread_mutex_t up_lock;
40
- int max_push_pending;
41
- void *env_nil_value;
42
- void *ctx_nil_value;
40
+ struct _agooUpgraded *up_list;
41
+ pthread_mutex_t up_lock;
42
+ int max_push_pending;
43
+ void *env_nil_value;
44
+ void *ctx_nil_value;
43
45
 
44
46
  // A count of the running threads from the wrapper or the server managed
45
47
  // threads.
46
- atomic_int running;
47
- } *Server;
48
+ atomic_int running;
49
+ } *agooServer;
48
50
 
49
- extern struct _Server the_server;
51
+ extern struct _agooServer agoo_server;
52
+ extern void agoo_server_setup();
53
+ extern void agoo_server_shutdown(const char *app_name, void (*stop)());
54
+ extern void agoo_server_bind(agooBind b);
50
55
 
51
- extern void server_setup();
52
- extern void server_shutdown(const char *app_name, void (*stop)());
53
- extern void server_bind(Bind b);
56
+ extern int setup_listen(agooErr err);
57
+ extern int agoo_server_start(agooErr err, const char *app_name, const char *version);
54
58
 
55
- extern int setup_listen(Err err);
56
- extern int server_start(Err err, const char *app_name, const char *version);
59
+ extern void agoo_server_add_upgraded(struct _agooUpgraded *up);
60
+ extern int agoo_server_add_func_hook(agooErr err,
61
+ agooMethod method,
62
+ const char *pattern,
63
+ void (*func)(struct _agooReq *req),
64
+ agooQueue queue,
65
+ bool quick);
57
66
 
58
- extern void server_add_upgraded(struct _Upgraded *up);
59
- extern int server_add_func_hook(Err err,
60
- Method method,
61
- const char *pattern,
62
- void (*func)(struct _Req *req),
63
- Queue queue,
64
- bool quick);
65
-
66
- extern void server_publish(struct _Pub *pub);
67
+ extern void agoo_server_publish(struct _agooPub *pub);
67
68
 
68
69
  #endif // AGOO_SERVER_H