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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +8 -0
- data/README.md +13 -11
- data/examples/redis.ru +11 -6
- data/exe/iodine +6 -1
- data/ext/iodine/fio.c +90 -38
- data/ext/iodine/fio.h +124 -37
- data/ext/iodine/fio_cli.c +51 -59
- data/ext/iodine/fio_cli.h +58 -19
- data/ext/iodine/fio_siphash.c +1 -54
- data/ext/iodine/fio_siphash.h +1 -1
- data/ext/iodine/http1.c +7 -1
- data/ext/iodine/http1_parser.c +4 -3
- data/ext/iodine/http_internal.h +3 -0
- data/ext/iodine/iodine.c +32 -30
- data/ext/iodine/iodine_mustache.c +11 -8
- data/ext/iodine/iodine_pubsub.c +2 -5
- data/ext/iodine/websockets.c +5 -1
- data/lib/iodine/mustache.rb +2 -2
- data/lib/iodine/version.rb +1 -1
- metadata +3 -3
data/ext/iodine/fio_cli.c
CHANGED
@@ -91,11 +91,11 @@ char const *fio_cli_get_line_type(fio_cli_parser_data_s *parser,
|
|
91
91
|
char const **pos = parser->names;
|
92
92
|
while (*pos) {
|
93
93
|
switch ((intptr_t)*pos) {
|
94
|
-
case
|
95
|
-
case
|
96
|
-
case
|
97
|
-
case
|
98
|
-
case
|
94
|
+
case FIO_CLI_STRING__TYPE_I: /* fallthrough */
|
95
|
+
case FIO_CLI_BOOL__TYPE_I: /* fallthrough */
|
96
|
+
case FIO_CLI_INT__TYPE_I: /* fallthrough */
|
97
|
+
case FIO_CLI_PRINT__TYPE_I: /* fallthrough */
|
98
|
+
case FIO_CLI_PRINT_HEADER__TYPE_I: /* fallthrough */
|
99
99
|
++pos;
|
100
100
|
continue;
|
101
101
|
}
|
@@ -107,11 +107,11 @@ char const *fio_cli_get_line_type(fio_cli_parser_data_s *parser,
|
|
107
107
|
return NULL;
|
108
108
|
found:
|
109
109
|
switch ((size_t)pos[1]) {
|
110
|
-
case
|
111
|
-
case
|
112
|
-
case
|
113
|
-
case
|
114
|
-
case
|
110
|
+
case FIO_CLI_STRING__TYPE_I: /* fallthrough */
|
111
|
+
case FIO_CLI_BOOL__TYPE_I: /* fallthrough */
|
112
|
+
case FIO_CLI_INT__TYPE_I: /* fallthrough */
|
113
|
+
case FIO_CLI_PRINT__TYPE_I: /* fallthrough */
|
114
|
+
case FIO_CLI_PRINT_HEADER__TYPE_I: /* fallthrough */
|
115
115
|
return pos[1];
|
116
116
|
}
|
117
117
|
return NULL;
|
@@ -141,26 +141,21 @@ static void fio_cli_set_arg(cstr_s arg, char const *value, char const *line,
|
|
141
141
|
/* validate data types */
|
142
142
|
char const *type = fio_cli_get_line_type(parser, line);
|
143
143
|
switch ((size_t)type) {
|
144
|
-
case
|
144
|
+
case FIO_CLI_BOOL__TYPE_I:
|
145
145
|
if (value && value != parser->argv[parser->pos + 1]) {
|
146
146
|
goto error;
|
147
147
|
}
|
148
148
|
value = "1";
|
149
149
|
break;
|
150
|
-
case
|
150
|
+
case FIO_CLI_INT__TYPE_I:
|
151
151
|
if (value) {
|
152
152
|
char const *tmp = value;
|
153
|
-
|
154
|
-
++tmp;
|
155
|
-
}
|
156
|
-
while (*tmp && *tmp >= '0' && *tmp <= '9') {
|
157
|
-
++tmp;
|
158
|
-
}
|
153
|
+
fio_atol((char **)&tmp);
|
159
154
|
if (*tmp) {
|
160
155
|
goto error;
|
161
156
|
}
|
162
157
|
}
|
163
|
-
case
|
158
|
+
case FIO_CLI_STRING__TYPE_I: /* fallthrough */
|
164
159
|
if (!value)
|
165
160
|
goto error;
|
166
161
|
if (!value[0])
|
@@ -206,28 +201,28 @@ print_help:
|
|
206
201
|
char const **pos = parser->names;
|
207
202
|
while (*pos) {
|
208
203
|
switch ((intptr_t)*pos) {
|
209
|
-
case
|
210
|
-
case
|
211
|
-
case
|
212
|
-
case
|
213
|
-
case
|
204
|
+
case FIO_CLI_STRING__TYPE_I: /* fallthrough */
|
205
|
+
case FIO_CLI_BOOL__TYPE_I: /* fallthrough */
|
206
|
+
case FIO_CLI_INT__TYPE_I: /* fallthrough */
|
207
|
+
case FIO_CLI_PRINT__TYPE_I: /* fallthrough */
|
208
|
+
case FIO_CLI_PRINT_HEADER__TYPE_I: /* fallthrough */
|
214
209
|
++pos;
|
215
210
|
continue;
|
216
211
|
}
|
217
|
-
type =
|
212
|
+
type = (char *)FIO_CLI_STRING__TYPE_I;
|
218
213
|
switch ((intptr_t)pos[1]) {
|
219
|
-
case
|
214
|
+
case FIO_CLI_PRINT__TYPE_I:
|
220
215
|
fprintf(stderr, "%s\n", pos[0]);
|
221
216
|
pos += 2;
|
222
217
|
continue;
|
223
|
-
case
|
218
|
+
case FIO_CLI_PRINT_HEADER__TYPE_I:
|
224
219
|
fprintf(stderr, "\n\x1B[4m%s\x1B[0m\n", pos[0]);
|
225
220
|
pos += 2;
|
226
221
|
continue;
|
227
222
|
|
228
|
-
case
|
229
|
-
case
|
230
|
-
case
|
223
|
+
case FIO_CLI_STRING__TYPE_I: /* fallthrough */
|
224
|
+
case FIO_CLI_BOOL__TYPE_I: /* fallthrough */
|
225
|
+
case FIO_CLI_INT__TYPE_I: /* fallthrough */
|
231
226
|
type = pos[1];
|
232
227
|
}
|
233
228
|
/* print line @ pos, starting with main argument name */
|
@@ -247,14 +242,14 @@ print_help:
|
|
247
242
|
}
|
248
243
|
}
|
249
244
|
switch ((size_t)type) {
|
250
|
-
case
|
245
|
+
case FIO_CLI_STRING__TYPE_I:
|
251
246
|
fprintf(stderr, " \x1B[1m%.*s\x1B[0m\x1B[2m <>\x1B[0m\t%s\n", first_len,
|
252
247
|
p, p + tmp);
|
253
248
|
break;
|
254
|
-
case
|
249
|
+
case FIO_CLI_BOOL__TYPE_I:
|
255
250
|
fprintf(stderr, " \x1B[1m%.*s\x1B[0m \t%s\n", first_len, p, p + tmp);
|
256
251
|
break;
|
257
|
-
case
|
252
|
+
case FIO_CLI_INT__TYPE_I:
|
258
253
|
fprintf(stderr, " \x1B[1m%.*s\x1B[0m\x1B[2m ##\x1B[0m\t%s\n", first_len,
|
259
254
|
p, p + tmp);
|
260
255
|
break;
|
@@ -273,18 +268,18 @@ print_help:
|
|
273
268
|
if (padding < 0)
|
274
269
|
padding = 0;
|
275
270
|
switch ((size_t)type) {
|
276
|
-
case
|
271
|
+
case FIO_CLI_STRING__TYPE_I:
|
277
272
|
fprintf(stderr,
|
278
273
|
" \x1B[1m%.*s\x1B[0m\x1B[2m <>\x1B[0m%*s\t(same as "
|
279
274
|
"\x1B[1m%.*s\x1B[0m)\n",
|
280
275
|
(int)(tmp - start), p + start, padding, "", first_len, p);
|
281
276
|
break;
|
282
|
-
case
|
277
|
+
case FIO_CLI_BOOL__TYPE_I:
|
283
278
|
fprintf(stderr,
|
284
279
|
" \x1B[1m%.*s\x1B[0m %*s\t(same as \x1B[1m%.*s\x1B[0m)\n",
|
285
280
|
(int)(tmp - start), p + start, padding, "", first_len, p);
|
286
281
|
break;
|
287
|
-
case
|
282
|
+
case FIO_CLI_INT__TYPE_I:
|
288
283
|
fprintf(stderr,
|
289
284
|
" \x1B[1m%.*s\x1B[0m\x1B[2m ##\x1B[0m%*s\t(same as "
|
290
285
|
"\x1B[1m%.*s\x1B[0m)\n",
|
@@ -304,9 +299,18 @@ print_help:
|
|
304
299
|
exit(0);
|
305
300
|
}
|
306
301
|
|
302
|
+
static void fio_cli_end_promise(void *ignr_) {
|
303
|
+
/* make sure fio_cli_end is called before facil.io exists. */
|
304
|
+
fio_cli_end();
|
305
|
+
(void)ignr_;
|
306
|
+
}
|
307
|
+
|
307
308
|
void fio_cli_start AVOID_MACRO(int argc, char const *argv[], int unnamed_min,
|
308
309
|
int unnamed_max, char const *description,
|
309
310
|
char const **names) {
|
311
|
+
static fio_lock_i run_once = FIO_LOCK_INIT;
|
312
|
+
if (!fio_trylock(&run_once))
|
313
|
+
fio_state_callback_add(FIO_CALL_AT_EXIT, fio_cli_end_promise, NULL);
|
310
314
|
if (unnamed_max >= 0 && unnamed_max < unnamed_min)
|
311
315
|
unnamed_max = unnamed_min;
|
312
316
|
fio_cli_parser_data_s parser = {
|
@@ -328,15 +332,16 @@ void fio_cli_start AVOID_MACRO(int argc, char const *argv[], int unnamed_min,
|
|
328
332
|
char const **line = names;
|
329
333
|
while (*line) {
|
330
334
|
switch ((intptr_t)*line) {
|
331
|
-
case
|
332
|
-
case
|
333
|
-
case
|
334
|
-
case
|
335
|
-
case
|
335
|
+
case FIO_CLI_STRING__TYPE_I: /* fallthrough */
|
336
|
+
case FIO_CLI_BOOL__TYPE_I: /* fallthrough */
|
337
|
+
case FIO_CLI_INT__TYPE_I: /* fallthrough */
|
338
|
+
case FIO_CLI_PRINT__TYPE_I: /* fallthrough */
|
339
|
+
case FIO_CLI_PRINT_HEADER__TYPE_I: /* fallthrough */
|
336
340
|
++line;
|
337
341
|
continue;
|
338
342
|
}
|
339
|
-
if (line[1] !=
|
343
|
+
if (line[1] != (char *)FIO_CLI_PRINT__TYPE_I &&
|
344
|
+
line[1] != (char *)FIO_CLI_PRINT_HEADER__TYPE_I)
|
340
345
|
fio_cli_map_line2alias(*line);
|
341
346
|
++line;
|
342
347
|
}
|
@@ -385,7 +390,8 @@ char const *fio_cli_get(char const *name) {
|
|
385
390
|
if (!fio_cli_hash_count(&fio_values)) {
|
386
391
|
return NULL;
|
387
392
|
}
|
388
|
-
|
393
|
+
char const *val = fio_cli_hash_find(&fio_values, FIO_CLI_HASH_VAL(n), n);
|
394
|
+
return val;
|
389
395
|
}
|
390
396
|
|
391
397
|
/** Returns the argument's value as an integer. */
|
@@ -393,22 +399,8 @@ int fio_cli_get_i(char const *name) {
|
|
393
399
|
char const *val = fio_cli_get(name);
|
394
400
|
if (!val)
|
395
401
|
return 0;
|
396
|
-
int
|
397
|
-
|
398
|
-
while (*val == '-' || *val == '+') {
|
399
|
-
if (*val == '-') {
|
400
|
-
invert += 1;
|
401
|
-
}
|
402
|
-
++val;
|
403
|
-
}
|
404
|
-
while (*val) {
|
405
|
-
ret = (ret * 10) + (*val - '0');
|
406
|
-
++val;
|
407
|
-
}
|
408
|
-
if ((invert & 1)) {
|
409
|
-
ret = 0 - ret;
|
410
|
-
}
|
411
|
-
return ret;
|
402
|
+
int i = (int)fio_atol((char **)&val);
|
403
|
+
return i;
|
412
404
|
}
|
413
405
|
|
414
406
|
/** Returns the number of unrecognized argument. */
|
data/ext/iodine/fio_cli.h
CHANGED
@@ -16,16 +16,16 @@ extern "C" {
|
|
16
16
|
CLI API
|
17
17
|
***************************************************************************** */
|
18
18
|
|
19
|
-
/** Indicates the
|
20
|
-
#define
|
21
|
-
/** Indicates the
|
22
|
-
#define
|
23
|
-
/** Indicates the
|
24
|
-
#define
|
25
|
-
/** Indicates the
|
26
|
-
#define
|
27
|
-
/** Indicates the
|
28
|
-
#define
|
19
|
+
/** Indicates the CLI argument should be a String (default). */
|
20
|
+
#define FIO_CLI_STRING(line)
|
21
|
+
/** Indicates the CLI argument is a Boolean value. */
|
22
|
+
#define FIO_CLI_BOOL(line)
|
23
|
+
/** Indicates the CLI argument should be an Integer (numerical). */
|
24
|
+
#define FIO_CLI_INT(line)
|
25
|
+
/** Indicates the CLI string should be printed as is. */
|
26
|
+
#define FIO_CLI_PRINT(line)
|
27
|
+
/** Indicates the CLI string should be printed as a header. */
|
28
|
+
#define FIO_CLI_PRINT_HEADER(line)
|
29
29
|
|
30
30
|
/**
|
31
31
|
* This function parses the Command Line Interface (CLI), creating a temporary
|
@@ -45,9 +45,11 @@ CLI API
|
|
45
45
|
*
|
46
46
|
* The following optional type requirements are:
|
47
47
|
*
|
48
|
-
* *
|
49
|
-
* *
|
50
|
-
* *
|
48
|
+
* * FIO_CLI_STRING(desc_line) - (default) string argument.
|
49
|
+
* * FIO_CLI_BOOL(desc_line) - boolean argument (no value).
|
50
|
+
* * FIO_CLI_INT(desc_line) - integer argument.
|
51
|
+
* * FIO_CLI_PRINT_HEADER(desc_line) - extra header for output.
|
52
|
+
* * FIO_CLI_PRINT(desc_line) - extra information for output.
|
51
53
|
*
|
52
54
|
* Argument names MUST start with the '-' character. The first word starting
|
53
55
|
* without the '-' character will begin the description for the CLI argument.
|
@@ -60,11 +62,15 @@ CLI API
|
|
60
62
|
* Example use:
|
61
63
|
*
|
62
64
|
* fio_cli_start(argc, argv, 0, 0, "this example accepts the following:",
|
63
|
-
* "
|
64
|
-
* "-
|
65
|
+
* FIO_CLI_PRINT_HREADER("Concurrency:"),
|
66
|
+
* FIO_CLI_INT("-t -thread number of threads to run."),
|
67
|
+
* FIO_CLI_INT("-w -workers number of workers to run."),
|
68
|
+
* FIO_CLI_PRINT_HREADER("Address Binding:"),
|
65
69
|
* "-b, -address the address to bind to.",
|
66
|
-
* "-p,-port the port to bind to.",
|
67
|
-
* "
|
70
|
+
* FIO_CLI_INT("-p,-port the port to bind to."),
|
71
|
+
* FIO_CLI_PRINT("\t\tset port to zero (0) for Unix s."),
|
72
|
+
* FIO_CLI_PRINT_HREADER("Logging:"),
|
73
|
+
* FIO_CLI_BOOL("-v -log enable logging."));
|
68
74
|
*
|
69
75
|
*
|
70
76
|
* This would allow access to the named arguments:
|
@@ -123,12 +129,14 @@ char const *fio_cli_unnamed(unsigned int index);
|
|
123
129
|
*
|
124
130
|
* fio_cli_start(argc, argv,
|
125
131
|
* "this is example accepts the following options:",
|
126
|
-
* "-p -port the port to bind to",
|
132
|
+
* "-p -port the port to bind to", FIO_CLI_INT;
|
127
133
|
*
|
128
134
|
* fio_cli_set("-p", "hello"); // fio_cli_get("-p") != fio_cli_get("-port");
|
129
135
|
*
|
130
136
|
* Note: this does NOT copy the C strings to memory. Memory should be kept alive
|
131
|
-
*
|
137
|
+
* until `fio_cli_end` is called.
|
138
|
+
*
|
139
|
+
* This function is NOT thread safe.
|
132
140
|
*/
|
133
141
|
void fio_cli_set(char const *name, char const *value);
|
134
142
|
|
@@ -138,6 +146,8 @@ void fio_cli_set(char const *name, char const *value);
|
|
138
146
|
* if(!fio_cli_get(name)) {
|
139
147
|
* fio_cli_set(name, value)
|
140
148
|
* }
|
149
|
+
*
|
150
|
+
* See fio_cli_set for notes and restrictions.
|
141
151
|
*/
|
142
152
|
#define fio_cli_set_default(name, value) \
|
143
153
|
if (!fio_cli_get((name))) \
|
@@ -147,4 +157,33 @@ void fio_cli_set(char const *name, char const *value);
|
|
147
157
|
} /* extern "C" */
|
148
158
|
#endif
|
149
159
|
|
160
|
+
/* *****************************************************************************
|
161
|
+
Internal Macro Implementation
|
162
|
+
***************************************************************************** */
|
163
|
+
|
164
|
+
/** Used internally. */
|
165
|
+
#define FIO_CLI_STRING__TYPE_I 0x1
|
166
|
+
#define FIO_CLI_BOOL__TYPE_I 0x2
|
167
|
+
#define FIO_CLI_INT__TYPE_I 0x3
|
168
|
+
#define FIO_CLI_PRINT__TYPE_I 0x4
|
169
|
+
#define FIO_CLI_PRINT_HEADER__TYPE_I 0x5
|
170
|
+
|
171
|
+
#undef FIO_CLI_STRING
|
172
|
+
#undef FIO_CLI_BOOL
|
173
|
+
#undef FIO_CLI_INT
|
174
|
+
#undef FIO_CLI_PRINT
|
175
|
+
#undef FIO_CLI_PRINT_HEADER
|
176
|
+
|
177
|
+
/** Indicates the CLI argument should be a String (default). */
|
178
|
+
#define FIO_CLI_STRING(line) (line), ((char *)FIO_CLI_STRING__TYPE_I)
|
179
|
+
/** Indicates the CLI argument is a Boolean value. */
|
180
|
+
#define FIO_CLI_BOOL(line) (line), ((char *)FIO_CLI_BOOL__TYPE_I)
|
181
|
+
/** Indicates the CLI argument should be an Integer (numerical). */
|
182
|
+
#define FIO_CLI_INT(line) (line), ((char *)FIO_CLI_INT__TYPE_I)
|
183
|
+
/** Indicates the CLI string should be printed as is. */
|
184
|
+
#define FIO_CLI_PRINT(line) (line), ((char *)FIO_CLI_PRINT__TYPE_I)
|
185
|
+
/** Indicates the CLI string should be printed as a header. */
|
186
|
+
#define FIO_CLI_PRINT_HEADER(line) \
|
187
|
+
(line), ((char *)FIO_CLI_PRINT_HEADER__TYPE_I)
|
188
|
+
|
150
189
|
#endif
|
data/ext/iodine/fio_siphash.c
CHANGED
@@ -133,64 +133,11 @@ uint64_t __attribute__((weak)) fio_siphash13(const void *data, size_t len) {
|
|
133
133
|
return fio_siphash_xy(data, len, 1, 3);
|
134
134
|
}
|
135
135
|
|
136
|
-
#if
|
136
|
+
#if DEBUG
|
137
137
|
#include <stdio.h>
|
138
138
|
#include <string.h>
|
139
139
|
#include <time.h>
|
140
140
|
|
141
|
-
#if 0
|
142
|
-
static void fio_siphash_speed_test(void) {
|
143
|
-
/* test based on code from BearSSL with credit to Thomas Pornin */
|
144
|
-
uint8_t buffer[8192];
|
145
|
-
memset(buffer, 'T', sizeof(buffer));
|
146
|
-
/* warmup */
|
147
|
-
uint64_t hash = 0;
|
148
|
-
for (size_t i = 0; i < 4; i++) {
|
149
|
-
hash += fio_siphash(buffer, sizeof(buffer));
|
150
|
-
memcpy(buffer, &hash, sizeof(hash));
|
151
|
-
}
|
152
|
-
/* loop until test runs for more than 2 seconds */
|
153
|
-
for (uint64_t cycles = 8192;;) {
|
154
|
-
clock_t start, end;
|
155
|
-
start = clock();
|
156
|
-
for (size_t i = cycles; i > 0; i--) {
|
157
|
-
hash += fio_siphash(buffer, sizeof(buffer));
|
158
|
-
__asm__ volatile("" ::: "memory");
|
159
|
-
}
|
160
|
-
end = clock();
|
161
|
-
memcpy(buffer, &hash, sizeof(hash));
|
162
|
-
if ((end - start) >= (2 * CLOCKS_PER_SEC) ||
|
163
|
-
cycles >= ((uint64_t)1 << 62)) {
|
164
|
-
fprintf(stderr, "%-20s %8.2f MB/s\n", "fio SipHash24",
|
165
|
-
(double)(sizeof(buffer) * cycles) /
|
166
|
-
(((end - start) * 1000000.0 / CLOCKS_PER_SEC)));
|
167
|
-
break;
|
168
|
-
}
|
169
|
-
cycles <<= 2;
|
170
|
-
}
|
171
|
-
/* loop until test runs for more than 2 seconds */
|
172
|
-
for (uint64_t cycles = 8192;;) {
|
173
|
-
clock_t start, end;
|
174
|
-
start = clock();
|
175
|
-
for (size_t i = cycles; i > 0; i--) {
|
176
|
-
hash += fio_siphash13(buffer, sizeof(buffer));
|
177
|
-
__asm__ volatile("" ::: "memory");
|
178
|
-
}
|
179
|
-
end = clock();
|
180
|
-
memcpy(buffer, &hash, sizeof(hash));
|
181
|
-
if ((end - start) >= (2 * CLOCKS_PER_SEC) ||
|
182
|
-
cycles >= ((uint64_t)1 << 62)) {
|
183
|
-
fprintf(stderr, "%-20s %8.2f MB/s\n", "fio SipHash13",
|
184
|
-
(double)(sizeof(buffer) * cycles) /
|
185
|
-
(((end - start) * 1000000.0 / CLOCKS_PER_SEC)));
|
186
|
-
break;
|
187
|
-
}
|
188
|
-
cycles <<= 2;
|
189
|
-
}
|
190
|
-
}
|
191
|
-
|
192
|
-
#endif
|
193
|
-
|
194
141
|
void fiobj_siphash_test(void) {
|
195
142
|
fprintf(stderr, "===================================\n");
|
196
143
|
// fio_siphash_speed_test();
|
data/ext/iodine/fio_siphash.h
CHANGED
data/ext/iodine/http1.c
CHANGED
@@ -679,6 +679,8 @@ static inline void http1_consume_data(intptr_t uuid, http1pr_s *p) {
|
|
679
679
|
ssize_t i = 0;
|
680
680
|
size_t org_len = p->buf_len;
|
681
681
|
int pipeline_limit = 8;
|
682
|
+
if (!p->buf_len)
|
683
|
+
return;
|
682
684
|
do {
|
683
685
|
i = http1_fio_parser(.parser = &p->parser,
|
684
686
|
.buffer = p->buf + (org_len - p->buf_len),
|
@@ -772,6 +774,7 @@ fio_protocol_s *http1_new(uintptr_t uuid, http_settings_s *settings,
|
|
772
774
|
if (unread_data && unread_length > HTTP_MAX_HEADER_LENGTH)
|
773
775
|
return NULL;
|
774
776
|
http1pr_s *p = fio_malloc(sizeof(*p) + HTTP_MAX_HEADER_LENGTH);
|
777
|
+
// FIO_LOG_DEBUG("Allocated HTTP/1.1 protocol at. %p", (void *)p);
|
775
778
|
FIO_ASSERT_ALLOC(p);
|
776
779
|
*p = (http1pr_s){
|
777
780
|
.p.protocol =
|
@@ -785,10 +788,12 @@ fio_protocol_s *http1_new(uintptr_t uuid, http_settings_s *settings,
|
|
785
788
|
.is_client = settings->is_client,
|
786
789
|
};
|
787
790
|
http_s_new(&p->request, &p->p, &HTTP1_VTABLE);
|
788
|
-
fio_attach(uuid, &p->p.protocol);
|
789
791
|
if (unread_data && unread_length <= HTTP_MAX_HEADER_LENGTH) {
|
790
792
|
memcpy(p->buf, unread_data, unread_length);
|
791
793
|
p->buf_len = unread_length;
|
794
|
+
}
|
795
|
+
fio_attach(uuid, &p->p.protocol);
|
796
|
+
if (unread_data && unread_length <= HTTP_MAX_HEADER_LENGTH) {
|
792
797
|
fio_force_event(uuid, FIO_EVENT_ON_DATA);
|
793
798
|
}
|
794
799
|
return &p->p.protocol;
|
@@ -800,6 +805,7 @@ void http1_destroy(fio_protocol_s *pr) {
|
|
800
805
|
http1_pr2handle(p).status = 0;
|
801
806
|
http_s_destroy(&http1_pr2handle(p), 0);
|
802
807
|
fio_free(p);
|
808
|
+
// FIO_LOG_DEBUG("Deallocated HTTP/1.1 protocol at. %p", (void *)p);
|
803
809
|
}
|
804
810
|
|
805
811
|
/* *****************************************************************************
|