iodine 0.7.15 → 0.7.16

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

Potentially problematic release.


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

@@ -382,8 +382,9 @@ re_eval:
382
382
  /* request / response line */
383
383
  case 0:
384
384
  /* clear out any leadinng white space */
385
- while (*start == '\r' || *start == '\n' || *start == ' ' || *start == 0) {
386
- start++;
385
+ while ((start < stop) &&
386
+ (*start == '\r' || *start == '\n' || *start == ' ' || *start == 0)) {
387
+ ++start;
387
388
  }
388
389
  end = start;
389
390
  /* make sure the whole line is available*/
@@ -407,7 +408,7 @@ re_eval:
407
408
  /* headers */
408
409
  case 1:
409
410
  do {
410
- if (start + 1 >= stop)
411
+ if (start >= stop)
411
412
  return CONSUMED; /* buffer ended on header line */
412
413
  if (*start == '\r' || *start == '\n') {
413
414
  goto finished_headers; /* empty line, end of headers */
@@ -7,6 +7,9 @@ Feel free to copy, use and enjoy according to the license provided.
7
7
  #ifndef H_HTTP_INTERNAL_H
8
8
  #define H_HTTP_INTERNAL_H
9
9
 
10
+ #include <fio.h>
11
+ /* subscription lists have a long lifetime */
12
+ #define FIO_FORCE_MALLOC_TMP 1
10
13
  #define FIO_INCLUDE_LINKED_LIST
11
14
  #include <fio.h>
12
15
 
@@ -340,37 +340,36 @@ static VALUE iodine_cli_parse(VALUE self) {
340
340
  desc[39 + 263 + RSTRING_LEN(iodine_version)] = 0;
341
341
  fio_cli_start(
342
342
  argc, (const char **)argv, 0, -1, desc,
343
- "Address Binding:", FIO_CLI_TYPE_PRINT_HEADER,
343
+ FIO_CLI_PRINT_HEADER("Address Binding:"),
344
344
  "-bind -b -address address to listen to. defaults to any available.",
345
- "-port -p port number to listen to. defaults port 3000", FIO_CLI_TYPE_INT,
346
- "\t\t\x1B[4mNote\x1B[0m: to bind to a Unix socket, "
347
- "set \x1B[1mport\x1B[0m to 0.",
348
- FIO_CLI_TYPE_PRINT, "Concurrency:", FIO_CLI_TYPE_PRINT_HEADER,
349
- "-workers -w number of processes to use.", FIO_CLI_TYPE_INT,
350
- "-threads -t number of threads per process.", FIO_CLI_TYPE_INT,
351
- "HTTP Server:", FIO_CLI_TYPE_PRINT_HEADER,
352
- "-public -www public folder, for static file service.",
353
- "-log -v HTTP request logging.", FIO_CLI_TYPE_BOOL,
354
- "-keep-alive -k -tout HTTP keep-alive timeout in seconds (0..255). "
355
- "Default: 40s",
356
- FIO_CLI_TYPE_INT, "-ping websocket ping interval (0..255). Default: 40s",
357
- FIO_CLI_TYPE_INT,
358
- "-max-body -maxbd HTTP upload limit in Mega-Bytes. Default: 50Mb",
359
- FIO_CLI_TYPE_INT,
360
- "-max-header -maxhd header limit per HTTP request in Kb."
361
- " Default: 32Kb.",
362
- FIO_CLI_TYPE_INT, "WebSocket Server:", FIO_CLI_TYPE_PRINT_HEADER,
363
- "-max-msg -maxms incoming WebSocket message limit in Kb. "
364
- "Default: 250Kb",
365
- FIO_CLI_TYPE_INT,
366
- "Connecting Iodine to Redis:", FIO_CLI_TYPE_PRINT_HEADER,
367
- "-redis -r an optional Redis URL server address. Default: none.",
368
- "-redis-ping -rp websocket ping interval (0..255). Default: 300s",
369
- FIO_CLI_TYPE_INT, "Misc:", FIO_CLI_TYPE_PRINT_HEADER,
370
- "-warmup --preload warm up the application. CAREFUL! with workers.",
371
- FIO_CLI_TYPE_BOOL,
372
- "-verbosity -V 0..5 server verbosity level. Default: 4",
373
- FIO_CLI_TYPE_INT);
345
+ FIO_CLI_INT("-port -p port number to listen to. defaults port 3000"),
346
+ FIO_CLI_PRINT("\t\t\x1B[4mNote\x1B[0m: to bind to a Unix socket, set "
347
+ "\x1B[1mport\x1B[0m to 0."),
348
+ FIO_CLI_PRINT_HEADER("Concurrency:"),
349
+ FIO_CLI_INT("-workers -w number of processes to use."),
350
+ FIO_CLI_INT("-threads -t number of threads per process."),
351
+ FIO_CLI_PRINT_HEADER("HTTP Settings:"),
352
+ FIO_CLI_STRING("-public -www public folder, for static file service."),
353
+ FIO_CLI_BOOL("-log -v HTTP request logging."),
354
+ FIO_CLI_INT("-keep-alive -k -tout HTTP keep-alive timeout in seconds "
355
+ "(0..255). Default: 40s"),
356
+ FIO_CLI_INT("-ping websocket ping interval (0..255). Default: 40s"),
357
+ FIO_CLI_INT(
358
+ "-max-body -maxbd HTTP upload limit in Mega-Bytes. Default: 50Mb"),
359
+ FIO_CLI_INT("-max-header -maxhd header limit per HTTP request in Kb. "
360
+ "Default: 32Kb."),
361
+ FIO_CLI_PRINT_HEADER("WebSocket Settings:"),
362
+ FIO_CLI_INT("-max-msg -maxms incoming WebSocket message limit in Kb. "
363
+ "Default: 250Kb"),
364
+ FIO_CLI_PRINT_HEADER("Connecting Iodine to Redis:"),
365
+ FIO_CLI_STRING(
366
+ "-redis -r an optional Redis URL server address. Default: none."),
367
+ FIO_CLI_INT(
368
+ "-redis-ping -rp websocket ping interval (0..255). Default: 300s"),
369
+ FIO_CLI_PRINT_HEADER("Misc:"),
370
+ FIO_CLI_BOOL(
371
+ "-warmup --preload warm up the application. CAREFUL! with workers."),
372
+ FIO_CLI_INT("-verbosity -V 0..5 server verbosity level. Default: 4"));
374
373
 
375
374
  /* copy values from CLI library to iodine */
376
375
  if (fio_cli_get("-V")) {
@@ -414,6 +413,9 @@ static VALUE iodine_cli_parse(VALUE self) {
414
413
  rb_hash_aset(defaults, ID2SYM(rb_intern("public")),
415
414
  rb_str_new_cstr(fio_cli_get("-www")));
416
415
  }
416
+ if (!fio_cli_get("-redis") && getenv("IODINE_REDIS_URL")) {
417
+ fio_cli_set("-redis", getenv("IODINE_REDIS_URL"));
418
+ }
417
419
  if (fio_cli_get("-redis")) {
418
420
  rb_hash_aset(defaults, ID2SYM(rb_intern("redis_")),
419
421
  rb_str_new_cstr(fio_cli_get("-redis")));
@@ -64,17 +64,20 @@ static inline VALUE fiobj_mustache_find_obj_absolute(VALUE udata,
64
64
  }
65
65
  return Qnil;
66
66
  }
67
- /* search by String */
68
- VALUE key = rb_str_new(name, name_len);
69
- tmp = rb_hash_aref(udata, key);
70
- if (tmp != Qnil)
71
- return tmp;
72
67
  /* search by Symbol */
73
68
  ID name_id = rb_intern2(name, name_len);
74
- key = rb_id2sym(name_id);
75
- tmp = rb_hash_aref(udata, key);
69
+ VALUE key = ID2SYM(name_id);
70
+ tmp = rb_hash_lookup2(udata, key, Qundef);
71
+ if (tmp != Qundef)
72
+ return tmp;
73
+ /* search by String */
74
+ key = rb_sym2str(key);
75
+ tmp = rb_hash_lookup2(udata, key, Qundef);
76
+ if (tmp != Qundef)
77
+ return tmp;
76
78
  /* search by method */
77
- if (tmp == Qnil && rb_respond_to(udata, name_id)) {
79
+ tmp = Qnil;
80
+ if (rb_respond_to(udata, name_id)) {
78
81
  tmp = IodineCaller.call(udata, name_id);
79
82
  }
80
83
 
@@ -390,11 +390,8 @@ static VALUE iodine_pubsub_redis_new(int argc, VALUE *argv, VALUE self) {
390
390
  /* parse URL assume redis://redis:password@localhost:6379 */
391
391
  http_url_s info = http_url_parse(RSTRING_PTR(url), RSTRING_LEN(url));
392
392
 
393
- FIO_LOG_INFO(
394
- "Initializing Redis engine for address: %s - port: %s - auth %s\n",
395
- info.host.data ? info.host.data : "-",
396
- info.port.data ? info.port.data : "-",
397
- info.password.data ? info.password.data : "-");
393
+ FIO_LOG_INFO("Initializing Redis engine for address: %.*s",
394
+ (int)RSTRING_LEN(url), RSTRING_PTR(url));
398
395
  /* create engine */
399
396
  e->engine = redis_engine_create(.address = info.host, .port = info.port,
400
397
  .auth = info.password, .ping_interval = ping);
@@ -4,10 +4,14 @@ license: MIT
4
4
 
5
5
  Feel free to copy, use and enjoy according to the license provided.
6
6
  */
7
- #define FIO_INCLUDE_LINKED_LIST
8
7
  #define FIO_INCLUDE_STR
9
8
  #include <fio.h>
10
9
 
10
+ /* subscription lists have a long lifetime */
11
+ #define FIO_FORCE_MALLOC_TMP 1
12
+ #define FIO_INCLUDE_LINKED_LIST
13
+ #include <fio.h>
14
+
11
15
  #include <fiobj.h>
12
16
 
13
17
  #include <http.h>
@@ -1,7 +1,7 @@
1
1
  module Iodine
2
2
  # Iodine includes a safe and fast Mustache templating engine.
3
3
  #
4
- # The engine is also faster and simpler than the official and feature richer Ruby engine.
4
+ # The engine is simpler and safer to use (and often faster) than the official and feature richer Ruby engine.
5
5
  #
6
6
  # Note: {Iodine::Mustache} behaves differently than the official Ruby templating engine in a number of ways:
7
7
  #
@@ -19,7 +19,7 @@ module Iodine
19
19
  #
20
20
  # Iodine Mustache's engine was designed to play best with basic data structures, such as results from the {Iodine::JSON} parser.
21
21
  #
22
- # Hash data is tested for String keys before being tested for Symbol keys and methods. This means that `"key"` has precedence over `:key`.
22
+ # Hash data is tested for Symbol keys before being tested for String keys and methods. This means that `:key` has precedence over `"key"`.
23
23
  #
24
24
  # Note: Although using methods as "keys" (or argument names) is supported, no Ruby code is evaluated.
25
25
  #
@@ -1,3 +1,3 @@
1
1
  module Iodine
2
- VERSION = '0.7.15'.freeze
2
+ VERSION = '0.7.16'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iodine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.15
4
+ version: 0.7.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-24 00:00:00.000000000 Z
11
+ date: 2018-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -211,7 +211,7 @@ licenses:
211
211
  - MIT
212
212
  metadata:
213
213
  allowed_push_host: https://rubygems.org
214
- post_install_message: 'Thank you for installing Iodine 0.7.15.
214
+ post_install_message: 'Thank you for installing Iodine 0.7.16.
215
215
 
216
216
  '
217
217
  rdoc_options: []