rage-iodine 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/iodine/http.c +37 -0
- data/ext/iodine/http.h +2 -0
- data/ext/iodine/iodine_helpers.c +36 -0
- data/ext/iodine/iodine_http.c +1 -1
- data/ext/iodine/scheduler.c +9 -5
- data/lib/iodine/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26c64867b568efaa1a0ae783f20270a2b5ed8c0fcc010092618c5d8dbc44c90b
|
4
|
+
data.tar.gz: 626631091ff1089858442160f6ef8e37acbed44dfa31f4840c8687ef6fa127c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46a415053aeb26048f786b2231c303e0d420dd01c25e0bb549e5b982952254fef69939a9f5771cdf8a6a4b54604496ac78853dedfae21a7577481f6e2f242654
|
7
|
+
data.tar.gz: 06f1410986a09fa0d5316907d02aeab6875dd2d7887ae679c3b289e0bb6222c23b208ad2e221dd425f2991dd9f4dd358f8ed68aaea36fb6852fb58a97dc42a15
|
data/ext/iodine/http.c
CHANGED
@@ -2361,6 +2361,43 @@ size_t http_date2rfc7231(char *target, struct tm *tmbuf) {
|
|
2361
2361
|
return pos - target;
|
2362
2362
|
}
|
2363
2363
|
|
2364
|
+
size_t http_date2timestamp(char *target, struct tm *tmbuf) {
|
2365
|
+
char *pos = target;
|
2366
|
+
uint16_t tmp;
|
2367
|
+
pos += fio_ltoa(pos, tmbuf->tm_year + 1900, 10);
|
2368
|
+
*(pos++) = '-';
|
2369
|
+
tmp = (tmbuf->tm_mon + 1) / 10;
|
2370
|
+
pos[0] = '0' + tmp;
|
2371
|
+
pos[1] = '0' + ((tmbuf->tm_mon + 1) - (tmp * 10));
|
2372
|
+
pos += 2;
|
2373
|
+
*(pos++) = '-';
|
2374
|
+
tmp = (tmbuf->tm_mday) / 10;
|
2375
|
+
pos[0] = '0' + tmp;
|
2376
|
+
pos[1] = '0' + (tmbuf->tm_mday - (tmp * 10));
|
2377
|
+
pos += 2;
|
2378
|
+
*(pos++) = 'T';
|
2379
|
+
tmp = tmbuf->tm_hour / 10;
|
2380
|
+
pos[0] = '0' + tmp;
|
2381
|
+
pos[1] = '0' + (tmbuf->tm_hour - (tmp * 10));
|
2382
|
+
pos[2] = ':';
|
2383
|
+
tmp = tmbuf->tm_min / 10;
|
2384
|
+
pos[3] = '0' + tmp;
|
2385
|
+
pos[4] = '0' + (tmbuf->tm_min - (tmp * 10));
|
2386
|
+
pos[5] = ':';
|
2387
|
+
tmp = tmbuf->tm_sec / 10;
|
2388
|
+
pos[6] = '0' + tmp;
|
2389
|
+
pos[7] = '0' + (tmbuf->tm_sec - (tmp * 10));
|
2390
|
+
pos += 8;
|
2391
|
+
pos[0] = '+';
|
2392
|
+
pos[1] = '0';
|
2393
|
+
pos[2] = '0';
|
2394
|
+
pos[3] = ':';
|
2395
|
+
pos[4] = '0';
|
2396
|
+
pos[5] = '0';
|
2397
|
+
pos += 6;
|
2398
|
+
return pos - target;
|
2399
|
+
}
|
2400
|
+
|
2364
2401
|
size_t http_date2str(char *target, struct tm *tmbuf);
|
2365
2402
|
|
2366
2403
|
size_t http_date2rfc2822(char *target, struct tm *tmbuf) {
|
data/ext/iodine/http.h
CHANGED
@@ -918,6 +918,8 @@ size_t http_date2rfc7231(char *target, struct tm *tmbuf);
|
|
918
918
|
size_t http_date2rfc2109(char *target, struct tm *tmbuf);
|
919
919
|
/** Writes an RFC 2822 date representation to target. */
|
920
920
|
size_t http_date2rfc2822(char *target, struct tm *tmbuf);
|
921
|
+
/** Writes a timestamp to target. */
|
922
|
+
size_t http_date2timestamp(char *target, struct tm *tmbuf);
|
921
923
|
/**
|
922
924
|
Writes an HTTP date string to the `target` buffer.
|
923
925
|
|
data/ext/iodine/iodine_helpers.c
CHANGED
@@ -456,6 +456,38 @@ static VALUE parse_multipart(VALUE self, VALUE rack_io, VALUE content_type) {
|
|
456
456
|
(void)self;
|
457
457
|
}
|
458
458
|
|
459
|
+
/**
|
460
|
+
Generate a timestamp to use in logs.
|
461
|
+
*/
|
462
|
+
static VALUE gen_timestamp(VALUE self) {
|
463
|
+
struct tm tm;
|
464
|
+
time_t last_tick = fio_last_tick().tv_sec;
|
465
|
+
http_gmtime(last_tick, &tm);
|
466
|
+
|
467
|
+
char buffer[32];
|
468
|
+
size_t len = http_date2timestamp(buffer, &tm);
|
469
|
+
|
470
|
+
return rb_str_new(buffer, len);
|
471
|
+
}
|
472
|
+
|
473
|
+
static const char request_tag_seed[] = "abcdefghijklmnopqrstuvwxyz0123456789";
|
474
|
+
static const uint8_t request_tag_len = 16;
|
475
|
+
|
476
|
+
/**
|
477
|
+
Generate a request tag to use in logs.
|
478
|
+
*/
|
479
|
+
static VALUE gen_request_tag(VALUE self) {
|
480
|
+
char buffer[request_tag_len];
|
481
|
+
uint8_t i, random_index;
|
482
|
+
|
483
|
+
for (i = 0; i < request_tag_len; i++) {
|
484
|
+
random_index = rand() % 36;
|
485
|
+
buffer[i] = request_tag_seed[random_index];
|
486
|
+
}
|
487
|
+
|
488
|
+
return rb_str_new(buffer, request_tag_len);
|
489
|
+
}
|
490
|
+
|
459
491
|
/* *****************************************************************************
|
460
492
|
Ruby Initialization
|
461
493
|
***************************************************************************** */
|
@@ -511,6 +543,8 @@ Results:
|
|
511
543
|
rb_define_module_function(tmp, "parse_nested_query", parse_nested_query, 1);
|
512
544
|
rb_define_module_function(tmp, "parse_urlencoded_nested_query", parse_urlencoded_nested_query, 1);
|
513
545
|
rb_define_module_function(tmp, "parse_multipart", parse_multipart, 2);
|
546
|
+
rb_define_module_function(tmp, "gen_timestamp", gen_timestamp, 0);
|
547
|
+
rb_define_module_function(tmp, "gen_request_tag", gen_request_tag, 0);
|
514
548
|
|
515
549
|
/*
|
516
550
|
The monkey-patched methods are in this module, allowing Iodine::Rack::Utils to
|
@@ -529,4 +563,6 @@ include non-patched methods as well.
|
|
529
563
|
rb_define_singleton_method(tmp, "rfc2109", iodine_rfc2109, 1);
|
530
564
|
rb_define_singleton_method(tmp, "rfc2822", iodine_rfc2822, 1);
|
531
565
|
// rb_define_module_function(IodineUtils, "time2str", date_str, -1);
|
566
|
+
|
567
|
+
srand(time(0));
|
532
568
|
}
|
data/ext/iodine/iodine_http.c
CHANGED
@@ -569,7 +569,7 @@ static inline int ruby2c_response_send(iodine_http_request_handle_s *handle,
|
|
569
569
|
if (body && rb_respond_to(body, close_method_id))
|
570
570
|
IodineCaller.call(body, close_method_id);
|
571
571
|
body = Qnil;
|
572
|
-
handle->type =
|
572
|
+
handle->type = IODINE_HTTP_EMPTY;
|
573
573
|
return 0;
|
574
574
|
}
|
575
575
|
if (TYPE(body) == T_ARRAY) {
|
data/ext/iodine/scheduler.c
CHANGED
@@ -44,8 +44,11 @@ static void iodine_scheduler_task_close(intptr_t uuid, fio_protocol_s *fio_proto
|
|
44
44
|
|
45
45
|
static void iodine_scheduler_task_perform(intptr_t uuid, fio_protocol_s *fio_protocol) {
|
46
46
|
scheduler_protocol_s *protocol = (scheduler_protocol_s *)fio_protocol;
|
47
|
-
|
48
|
-
protocol->fulfilled
|
47
|
+
|
48
|
+
if (!protocol->fulfilled) {
|
49
|
+
IodineCaller.call(protocol->block, call_id);
|
50
|
+
protocol->fulfilled = 1;
|
51
|
+
}
|
49
52
|
|
50
53
|
(void)uuid;
|
51
54
|
}
|
@@ -55,7 +58,7 @@ static void iodine_scheduler_task_timeout(intptr_t uuid, fio_protocol_s *fio_pro
|
|
55
58
|
|
56
59
|
if (!protocol->fulfilled) {
|
57
60
|
IodineCaller.call2(protocol->block, call_id, 1, timeout_args);
|
58
|
-
|
61
|
+
protocol->fulfilled = 1;
|
59
62
|
}
|
60
63
|
}
|
61
64
|
|
@@ -127,8 +130,9 @@ static VALUE iodine_scheduler_write(VALUE self, VALUE r_fd, VALUE r_buffer, VALU
|
|
127
130
|
Check_Type(r_offset, T_FIXNUM);
|
128
131
|
int offset = FIX2INT(r_offset);
|
129
132
|
|
130
|
-
|
131
|
-
|
133
|
+
void *cpy = fio_malloc(length);
|
134
|
+
memcpy(cpy, buffer, length);
|
135
|
+
fio_write2(fio_fd2uuid(fd), .data.buffer = cpy, .length = length, .offset = offset, .after.dealloc = fio_free);
|
132
136
|
|
133
137
|
return r_length;
|
134
138
|
|
data/lib/iodine/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rage-iodine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boaz Segev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|