iodine 0.2.9 → 0.2.10
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/CHANGELOG.md +27 -0
- data/README.md +14 -4
- data/bin/raw-rbhttp +4 -6
- data/bin/raw-rbhttp-em +63 -0
- data/ext/iodine/bscrypt-common.h +2 -2
- data/ext/iodine/http1.c +2 -2
- data/ext/iodine/http1_simple_parser.c +2 -1
- data/ext/iodine/http_request.h +4 -4
- data/ext/iodine/http_response.c +4 -3
- data/ext/iodine/http_response_http1.h +10 -10
- data/ext/iodine/iodine_core.c +60 -6
- data/ext/iodine/iodine_http.c +5 -2
- data/ext/iodine/libasync.c +22 -11
- data/ext/iodine/libasync.h +6 -1
- data/ext/iodine/libreact.c +8 -5
- data/ext/iodine/libreact.h +1 -1
- data/ext/iodine/libserver.c +32 -14
- data/ext/iodine/libserver.h +12 -6
- data/ext/iodine/libsock.c +16 -9
- data/ext/iodine/libsock.h +7 -7
- data/ext/iodine/mempool.h +17 -14
- data/ext/iodine/misc.c +2 -2
- data/ext/iodine/random.c +17 -2
- data/ext/iodine/sha1.h +1 -1
- data/ext/iodine/sha2.h +3 -3
- data/ext/iodine/siphash.c +2 -2
- data/ext/iodine/spnlock.h +35 -35
- data/lib/iodine/protocol.rb +4 -0
- data/lib/iodine/version.rb +1 -1
- metadata +3 -2
data/ext/iodine/mempool.h
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
Copyright: Boaz
|
2
|
+
Copyright: Boaz Segev, 2016-2017
|
3
3
|
License: MIT
|
4
4
|
|
5
5
|
Feel free to copy, use and enjoy according to the license provided.
|
@@ -63,8 +63,8 @@ MEMPOOL_H
|
|
63
63
|
#include <stdlib.h>
|
64
64
|
#include <string.h>
|
65
65
|
|
66
|
-
#ifndef
|
67
|
-
#define
|
66
|
+
#ifndef UNUSED_FUNC
|
67
|
+
#define UNUSED_FUNC __attribute__((unused))
|
68
68
|
#endif
|
69
69
|
|
70
70
|
/* *****************************************************************************
|
@@ -74,11 +74,11 @@ API Declerations
|
|
74
74
|
***************************************************************************** */
|
75
75
|
|
76
76
|
/** Allocates memory from the pool. */
|
77
|
-
static
|
77
|
+
static UNUSED_FUNC void *mempool_malloc(size_t size);
|
78
78
|
/**
|
79
79
|
* Frees the memory, releasing it back to the pool (or, sometimes, the system).
|
80
80
|
*/
|
81
|
-
static
|
81
|
+
static UNUSED_FUNC void mempool_free(void *ptr);
|
82
82
|
/**
|
83
83
|
* Behaves the same a the systems `realloc`, attempting to resize the memory
|
84
84
|
* when possible.
|
@@ -87,13 +87,13 @@ static __unused void mempool_free(void *ptr);
|
|
87
87
|
* otherwise returns a new pointer (either equal to the old or after
|
88
88
|
* deallocating the old one).
|
89
89
|
*/
|
90
|
-
static
|
90
|
+
static UNUSED_FUNC void *mempool_realloc(void *ptr, size_t new_size);
|
91
91
|
|
92
92
|
#if defined(DEBUG) && DEBUG == 1
|
93
93
|
/** Tests the memory pool, both testing against issues / corruption and testing
|
94
94
|
* it's performance against the system's `malloc`.
|
95
95
|
*/
|
96
|
-
static
|
96
|
+
static UNUSED_FUNC void mempool_test(void);
|
97
97
|
#endif
|
98
98
|
|
99
99
|
/* *****************************************************************************
|
@@ -176,7 +176,7 @@ Memory Block Allocation / Deallocation
|
|
176
176
|
target = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, \
|
177
177
|
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
|
178
178
|
if (target == MAP_FAILED) \
|
179
|
-
target
|
179
|
+
target = NULL; \
|
180
180
|
} while (0);
|
181
181
|
|
182
182
|
#define MEMPOOL_DEALLOC_SPECIAL(target, size) munmap((target), (size))
|
@@ -200,7 +200,7 @@ Helpers: Memory block slicing and memory pool list maintanence.
|
|
200
200
|
API implementation
|
201
201
|
*/
|
202
202
|
|
203
|
-
static
|
203
|
+
static UNUSED_FUNC void *mempool_malloc(size_t size) {
|
204
204
|
if (!size)
|
205
205
|
return NULL;
|
206
206
|
if (size & 15) {
|
@@ -304,7 +304,7 @@ alloc_indi:
|
|
304
304
|
* Frees the memory, releasing it back to the pool (or, sometimes, the
|
305
305
|
* system).
|
306
306
|
*/
|
307
|
-
static
|
307
|
+
static UNUSED_FUNC void mempool_free(void *ptr) {
|
308
308
|
if (!ptr)
|
309
309
|
return;
|
310
310
|
mempool_reserved_slice_s **pos, *slice = MEMPOOL_PTR2SLICE(ptr), *tmp;
|
@@ -417,7 +417,7 @@ error:
|
|
417
417
|
* and valid) otherwise returns a new pointer (either equal to the old or after
|
418
418
|
* deallocating the old one).
|
419
419
|
*/
|
420
|
-
static
|
420
|
+
static UNUSED_FUNC void *mempool_realloc(void *ptr, size_t size) {
|
421
421
|
if (!size)
|
422
422
|
return NULL;
|
423
423
|
if (size & 15) {
|
@@ -531,6 +531,7 @@ TESTING
|
|
531
531
|
#define MEMTEST_SLICE 32
|
532
532
|
|
533
533
|
#include <time.h>
|
534
|
+
#include <inttypes.h>
|
534
535
|
static void mempool_stats(void) {
|
535
536
|
fprintf(stderr, "* Pool object: %lu bytes\n"
|
536
537
|
"* Alignment: %lu \n"
|
@@ -713,12 +714,13 @@ static void mempool_speedtest(size_t memtest_repeats, void *(*mlk)(size_t),
|
|
713
714
|
: (end_test.tv_nsec - start_test.tv_nsec);
|
714
715
|
uint64_t sec_for_test = end_test.tv_sec - start_test.tv_sec;
|
715
716
|
|
716
|
-
fprintf(stderr,
|
717
|
+
fprintf(stderr,
|
718
|
+
"Finished test in %" PRIu64 "m, %" PRIu64 "s %" PRIu64 " mili.sec.\n",
|
717
719
|
sec_for_test / 60, sec_for_test - (((sec_for_test) / 60) * 60),
|
718
720
|
msec_for_test / 1000000);
|
719
721
|
}
|
720
722
|
|
721
|
-
static
|
723
|
+
static UNUSED_FUNC void mempool_test(void) {
|
722
724
|
fprintf(stderr, "*****************************\n");
|
723
725
|
fprintf(stderr, "mempool implementation details:\n");
|
724
726
|
mempool_stats();
|
@@ -799,7 +801,8 @@ static __unused void mempool_test(void) {
|
|
799
801
|
: (end_test.tv_nsec - start_test.tv_nsec);
|
800
802
|
uint64_t sec_for_test = end_test.tv_sec - start_test.tv_sec;
|
801
803
|
|
802
|
-
fprintf(stderr,
|
804
|
+
fprintf(stderr,
|
805
|
+
" %" PRIu64 "m, %" PRIu64 "s %" PRIu64 " mili.sec. ( %lu CPU)\n",
|
803
806
|
sec_for_test / 60, sec_for_test - (((sec_for_test) / 60) * 60),
|
804
807
|
msec_for_test / 1000000, end - start);
|
805
808
|
|
data/ext/iodine/misc.c
CHANGED
@@ -52,7 +52,7 @@ fdump_s *bscrypt_fdump(const char *file_path, size_t size_limit) {
|
|
52
52
|
|
53
53
|
if (stat(file_path, &f_data))
|
54
54
|
goto error;
|
55
|
-
if (size_limit == 0 || f_data.st_size < size_limit)
|
55
|
+
if (size_limit == 0 || (size_t)f_data.st_size < size_limit)
|
56
56
|
size_limit = f_data.st_size;
|
57
57
|
container = malloc(size_limit + sizeof(fdump_s));
|
58
58
|
if (!container)
|
@@ -61,7 +61,7 @@ fdump_s *bscrypt_fdump(const char *file_path, size_t size_limit) {
|
|
61
61
|
file = open(file_path, O_RDONLY);
|
62
62
|
if (file < 0)
|
63
63
|
goto error;
|
64
|
-
if (read(file, container->data, size_limit)
|
64
|
+
if (read(file, container->data, size_limit) != (ssize_t)size_limit)
|
65
65
|
goto error;
|
66
66
|
close(file);
|
67
67
|
return container;
|
data/ext/iodine/random.c
CHANGED
@@ -13,6 +13,21 @@ Feel free to copy, use and enjoy in accordance with to the license(s).
|
|
13
13
|
#if defined(USE_ALT_RANDOM) || !defined(HAS_UNIX_FEATURES)
|
14
14
|
#include "sha2.h"
|
15
15
|
#include <time.h>
|
16
|
+
|
17
|
+
#ifdef RUSAGE_SELF
|
18
|
+
static size_t get_clock_mili(void) {
|
19
|
+
struct rusage rusage;
|
20
|
+
getrusage(RUSAGE_SELF, &rusage);
|
21
|
+
return ((rusage.ru_utime.tv_sec + rusage.ru_stime.tv_sec) * 1000000) +
|
22
|
+
(rusage.ru_utime.tv_usec + rusage.ru_stime.tv_usec);
|
23
|
+
}
|
24
|
+
#elif defined CLOCKS_PER_SEC
|
25
|
+
#define get_clock_mili() (size_t) clock()
|
26
|
+
#else
|
27
|
+
#define get_clock_mili() 0
|
28
|
+
#error Random alternative failed to find access to the CPU clock state.
|
29
|
+
#endif
|
30
|
+
|
16
31
|
uint32_t bscrypt_rand32(void) {
|
17
32
|
bits256_u pseudo = bscrypt_rand256();
|
18
33
|
return pseudo.ints[3];
|
@@ -32,14 +47,14 @@ bits128_u bscrypt_rand128(void) {
|
|
32
47
|
}
|
33
48
|
|
34
49
|
bits256_u bscrypt_rand256(void) {
|
35
|
-
|
50
|
+
size_t cpu_state = get_clock_mili();
|
36
51
|
time_t the_time;
|
37
52
|
time(&the_time);
|
38
53
|
bits256_u pseudo;
|
39
54
|
sha2_s sha2 = bscrypt_sha2_init(SHA_256);
|
40
55
|
bscrypt_sha2_write(&sha2, &cpu_state, sizeof(cpu_state));
|
41
56
|
bscrypt_sha2_write(&sha2, &the_time, sizeof(the_time));
|
42
|
-
bscrypt_sha2_write(&sha2, &cpu_state -
|
57
|
+
bscrypt_sha2_write(&sha2, ((char *)&cpu_state) - 64, 64); /* the stack */
|
43
58
|
bscrypt_sha2_result(&sha2);
|
44
59
|
pseudo.words[0] = sha2.digest.i64[0];
|
45
60
|
pseudo.words[1] = sha2.digest.i64[1];
|
data/ext/iodine/sha1.h
CHANGED
@@ -64,7 +64,7 @@ char *bscrypt_sha1_result(sha1_s *s);
|
|
64
64
|
/**
|
65
65
|
An SHA1 helper function that performs initialiation, writing and finalizing.
|
66
66
|
*/
|
67
|
-
static inline
|
67
|
+
static inline UNUSED_FUNC char *bscrypt_sha1(sha1_s *s, const void *data,
|
68
68
|
size_t len) {
|
69
69
|
*s = bscrypt_sha1_init();
|
70
70
|
bscrypt_sha1_write(s, data, len);
|
data/ext/iodine/sha2.h
CHANGED
@@ -95,7 +95,7 @@ char *bscrypt_sha2_result(sha2_s *s);
|
|
95
95
|
An SHA2 helper function that performs initialiation, writing and finalizing.
|
96
96
|
Uses the SHA2 512 variant.
|
97
97
|
*/
|
98
|
-
static inline
|
98
|
+
static inline UNUSED_FUNC char *bscrypt_sha2_512(sha2_s *s, const void *data,
|
99
99
|
size_t len) {
|
100
100
|
*s = bscrypt_sha2_init(SHA_512);
|
101
101
|
bscrypt_sha2_write(s, data, len);
|
@@ -106,7 +106,7 @@ static inline __unused char *bscrypt_sha2_512(sha2_s *s, const void *data,
|
|
106
106
|
An SHA2 helper function that performs initialiation, writing and finalizing.
|
107
107
|
Uses the SHA2 256 variant.
|
108
108
|
*/
|
109
|
-
static inline
|
109
|
+
static inline UNUSED_FUNC char *bscrypt_sha2_256(sha2_s *s, const void *data,
|
110
110
|
size_t len) {
|
111
111
|
*s = bscrypt_sha2_init(SHA_256);
|
112
112
|
bscrypt_sha2_write(s, data, len);
|
@@ -117,7 +117,7 @@ static inline __unused char *bscrypt_sha2_256(sha2_s *s, const void *data,
|
|
117
117
|
An SHA2 helper function that performs initialiation, writing and finalizing.
|
118
118
|
Uses the SHA2 384 variant.
|
119
119
|
*/
|
120
|
-
static inline
|
120
|
+
static inline UNUSED_FUNC char *bscrypt_sha2_384(sha2_s *s, const void *data,
|
121
121
|
size_t len) {
|
122
122
|
*s = bscrypt_sha2_init(SHA_384);
|
123
123
|
bscrypt_sha2_write(s, data, len);
|
data/ext/iodine/siphash.c
CHANGED
@@ -24,8 +24,8 @@ Feel free to copy, use and enjoy in accordance with to the license(s).
|
|
24
24
|
# endif
|
25
25
|
#endif
|
26
26
|
|
27
|
-
#ifndef
|
28
|
-
# define
|
27
|
+
#ifndef UNUSED_FUNC
|
28
|
+
# define UNUSED_FUNC __attribute__((unused))
|
29
29
|
#endif
|
30
30
|
// clang-format on
|
31
31
|
|
data/ext/iodine/spnlock.h
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
/*
|
2
|
-
Copyright: Boaz
|
2
|
+
Copyright: Boaz Segev, 2016-2017
|
3
3
|
License: MIT
|
4
4
|
|
5
5
|
Feel free to copy, use and enjoy according to the license provided.
|
6
6
|
*/
|
7
|
-
#ifndef
|
7
|
+
#ifndef SIMPLE_SPN_LOCK_H
|
8
8
|
/* *****************************************************************************
|
9
9
|
A Simple busy lock implementation ... (spnlock.h)
|
10
10
|
|
@@ -13,11 +13,10 @@ karnel's code and the more readable Apple's kernel code)
|
|
13
13
|
|
14
14
|
Written by Boaz Segev at 2016. Donated to the public domain for all to enjoy.
|
15
15
|
*/
|
16
|
-
#define
|
16
|
+
#define SIMPLE_SPN_LOCK_H
|
17
17
|
|
18
|
-
|
19
|
-
#
|
20
|
-
#define __unused __attribute__((unused))
|
18
|
+
#ifndef _GNU_SOURCE
|
19
|
+
#define _GNU_SOURCE
|
21
20
|
#endif
|
22
21
|
|
23
22
|
#include <stdint.h>
|
@@ -62,19 +61,17 @@ Written by Boaz Segev at 2016. Donated to the public domain for all to enjoy.
|
|
62
61
|
typedef atomic_bool spn_lock_i;
|
63
62
|
#define SPN_LOCK_INIT ATOMIC_VAR_INIT(0)
|
64
63
|
/** returns 1 if the lock was busy (TRUE == FAIL). */
|
65
|
-
|
64
|
+
static inline int spn_trylock(spn_lock_i *lock) {
|
66
65
|
__asm__ volatile("" ::: "memory");
|
67
66
|
return atomic_exchange(lock, 1);
|
68
67
|
}
|
69
68
|
/** Releases a lock. */
|
70
|
-
|
69
|
+
static inline void spn_unlock(spn_lock_i *lock) {
|
71
70
|
atomic_store(lock, 0);
|
72
71
|
__asm__ volatile("" ::: "memory");
|
73
72
|
}
|
74
73
|
/** returns a lock's state (non 0 == Busy). */
|
75
|
-
|
76
|
-
return atomic_load(lock);
|
77
|
-
}
|
74
|
+
static inline int spn_is_locked(spn_lock_i *lock) { return atomic_load(lock); }
|
78
75
|
#endif
|
79
76
|
#endif
|
80
77
|
|
@@ -91,9 +88,7 @@ __unused static inline int spn_is_locked(spn_lock_i *lock) {
|
|
91
88
|
/* define the type */
|
92
89
|
typedef volatile uint8_t spn_lock_i;
|
93
90
|
/** returns 1 if the lock was busy (TRUE == FAIL). */
|
94
|
-
|
95
|
-
return __sync_swap(lock, 1);
|
96
|
-
}
|
91
|
+
static inline int spn_trylock(spn_lock_i *lock) { return __sync_swap(lock, 1); }
|
97
92
|
#define SPN_TMP_HAS_BUILTIN 1
|
98
93
|
#endif
|
99
94
|
/* use gcc builtins if available - trust the compiler */
|
@@ -102,7 +97,7 @@ __unused static inline int spn_trylock(spn_lock_i *lock) {
|
|
102
97
|
/* define the type */
|
103
98
|
typedef volatile uint8_t spn_lock_i;
|
104
99
|
/** returns 1 if the lock was busy (TRUE == FAIL). */
|
105
|
-
|
100
|
+
static inline int spn_trylock(spn_lock_i *lock) {
|
106
101
|
return __sync_fetch_and_or(lock, 1);
|
107
102
|
}
|
108
103
|
#define SPN_TMP_HAS_BUILTIN 1
|
@@ -119,7 +114,7 @@ __unused static inline int spn_trylock(spn_lock_i *lock) {
|
|
119
114
|
/* define the type */
|
120
115
|
typedef volatile uint8_t spn_lock_i;
|
121
116
|
/** returns 1 if the lock was busy (TRUE == FAIL). */
|
122
|
-
|
117
|
+
static inline int spn_trylock(spn_lock_i *lock) {
|
123
118
|
spn_lock_i tmp;
|
124
119
|
__asm__ volatile("xchgb %0,%1" : "=r"(tmp), "=m"(*lock) : "0"(1) : "memory");
|
125
120
|
return tmp;
|
@@ -130,7 +125,7 @@ __unused static inline int spn_trylock(spn_lock_i *lock) {
|
|
130
125
|
/* define the type */
|
131
126
|
typedef volatile uint8_t spn_lock_i;
|
132
127
|
/** returns TRUE (non-zero) if the lock was busy (TRUE == FAIL). */
|
133
|
-
|
128
|
+
static inline int spn_trylock(spn_lock_i *lock) {
|
134
129
|
spn_lock_i tmp;
|
135
130
|
__asm__ volatile("ldstub [%1], %0" : "=r"(tmp) : "r"(lock) : "memory");
|
136
131
|
return tmp; /* return 0xFF if the lock was busy, 0 if free */
|
@@ -144,12 +139,12 @@ __unused static inline int spn_trylock(spn_lock_i *lock) {
|
|
144
139
|
#define SPN_LOCK_INIT 0
|
145
140
|
|
146
141
|
/** Releases a lock. */
|
147
|
-
|
142
|
+
static inline void spn_unlock(spn_lock_i *lock) {
|
148
143
|
__asm__ volatile("" ::: "memory");
|
149
144
|
*lock = 0;
|
150
145
|
}
|
151
146
|
/** returns a lock's state (non 0 == Busy). */
|
152
|
-
|
147
|
+
static inline int spn_is_locked(spn_lock_i *lock) {
|
153
148
|
__asm__ volatile("" ::: "memory");
|
154
149
|
return *lock;
|
155
150
|
}
|
@@ -157,7 +152,7 @@ __unused static inline int spn_is_locked(spn_lock_i *lock) {
|
|
157
152
|
#endif /* has atomics */
|
158
153
|
#include <stdio.h>
|
159
154
|
/** Busy waits for the lock. */
|
160
|
-
|
155
|
+
static inline void spn_lock(spn_lock_i *lock) {
|
161
156
|
while (spn_trylock(lock)) {
|
162
157
|
reschedule_thread();
|
163
158
|
}
|
@@ -168,17 +163,22 @@ spnlock.h finished
|
|
168
163
|
*/
|
169
164
|
#endif
|
170
165
|
|
171
|
-
#if DEBUG == 1 && !defined(
|
166
|
+
#if DEBUG == 1 && !defined(SPN_LOCK_TEST_REPEAT_COUNT)
|
167
|
+
|
168
|
+
/* allow of the unused flag */
|
169
|
+
#ifndef UNUSED_FUNC
|
170
|
+
#define UNUSED_FUNC __attribute__((unused))
|
171
|
+
#endif
|
172
172
|
|
173
|
-
#define
|
174
|
-
#define
|
173
|
+
#define SPN_LOCK_TEST_REPEAT_COUNT 10000UL
|
174
|
+
#define SPN_LOCK_TEST_THREAD_COUNT 10000UL
|
175
175
|
#include <pthread.h>
|
176
176
|
#include <stdio.h>
|
177
177
|
|
178
|
-
|
178
|
+
UNUSED_FUNC static void *test_spn_lock_work(void *arg) {
|
179
179
|
static spn_lock_i lck = SPN_LOCK_INIT;
|
180
180
|
uint64_t *ip = arg;
|
181
|
-
for (size_t i = 0; i <
|
181
|
+
for (size_t i = 0; i < SPN_LOCK_TEST_REPEAT_COUNT; i++) {
|
182
182
|
spn_lock(&lck);
|
183
183
|
uint64_t j = *ip;
|
184
184
|
j++;
|
@@ -189,9 +189,9 @@ __unused static void *test_spn_lock_work(void *arg) {
|
|
189
189
|
return NULL;
|
190
190
|
}
|
191
191
|
|
192
|
-
|
192
|
+
UNUSED_FUNC static void *test_spn_lock_lockless_work(void *arg) {
|
193
193
|
uint64_t *ip = arg;
|
194
|
-
for (size_t i = 0; i <
|
194
|
+
for (size_t i = 0; i < SPN_LOCK_TEST_REPEAT_COUNT; i++) {
|
195
195
|
uint64_t j = *ip;
|
196
196
|
j++;
|
197
197
|
__asm__ volatile("" ::: "memory", "cc");
|
@@ -200,16 +200,16 @@ __unused static void *test_spn_lock_lockless_work(void *arg) {
|
|
200
200
|
return NULL;
|
201
201
|
}
|
202
202
|
|
203
|
-
|
204
|
-
|
203
|
+
UNUSED_FUNC static void spn_lock_test(void) {
|
204
|
+
size_t start, end;
|
205
205
|
unsigned long num = 0;
|
206
|
-
pthread_t *threads = malloc(
|
206
|
+
pthread_t *threads = malloc(SPN_LOCK_TEST_THREAD_COUNT * sizeof(*threads));
|
207
207
|
void *tmp;
|
208
208
|
start = clock();
|
209
|
-
for (size_t i = 0; i <
|
209
|
+
for (size_t i = 0; i < SPN_LOCK_TEST_THREAD_COUNT; i++) {
|
210
210
|
pthread_create(threads + i, NULL, test_spn_lock_lockless_work, &num);
|
211
211
|
}
|
212
|
-
for (size_t i = 0; i <
|
212
|
+
for (size_t i = 0; i < SPN_LOCK_TEST_THREAD_COUNT; i++) {
|
213
213
|
pthread_join(threads[i], &tmp);
|
214
214
|
}
|
215
215
|
end = clock();
|
@@ -219,7 +219,7 @@ __unused static void spn_lock_test(void) {
|
|
219
219
|
num = 0;
|
220
220
|
|
221
221
|
start = clock();
|
222
|
-
for (size_t i = 0; i <
|
222
|
+
for (size_t i = 0; i < SPN_LOCK_TEST_THREAD_COUNT; i++) {
|
223
223
|
if (pthread_create(threads + i, NULL, test_spn_lock_work, &num))
|
224
224
|
fprintf(stderr,
|
225
225
|
"Failed to create thread number %lu... test will fail to run as "
|
@@ -227,14 +227,14 @@ __unused static void spn_lock_test(void) {
|
|
227
227
|
i);
|
228
228
|
;
|
229
229
|
}
|
230
|
-
for (size_t i = 0; i <
|
230
|
+
for (size_t i = 0; i < SPN_LOCK_TEST_THREAD_COUNT; i++) {
|
231
231
|
pthread_join(threads[i], &tmp);
|
232
232
|
}
|
233
233
|
end = clock();
|
234
234
|
free(threads);
|
235
235
|
fprintf(stderr, "Locked Num = %lu with %lu CPU cycles.\n", num, end - start);
|
236
236
|
fprintf(stderr, "spn_lock test %s\n",
|
237
|
-
num ==
|
237
|
+
num == SPN_LOCK_TEST_THREAD_COUNT * SPN_LOCK_TEST_REPEAT_COUNT
|
238
238
|
? "passed."
|
239
239
|
: "FAILED!");
|
240
240
|
}
|
data/lib/iodine/protocol.rb
CHANGED
@@ -28,6 +28,10 @@ module Iodine
|
|
28
28
|
# Use {#defer} to run protocol related tasks (this locks the connection, preventing it from running more then one task at a time and offering thread safety),
|
29
29
|
# or {#run} to run asynchronous tasks that aren't protocol related.
|
30
30
|
#
|
31
|
+
# <b>Connection timeouts</b>
|
32
|
+
#
|
33
|
+
# By setting a class variable called `@timeout` it is possible to define a default timeout for new connections. However, changing this default timeout should be performed using the {#timeout} methods.
|
34
|
+
#
|
31
35
|
# <b>The API:</b>
|
32
36
|
#
|
33
37
|
# After a new connection is accepted and a new protocol object is created, the protocol will be linked with Iodine's Protocol API.
|
data/lib/iodine/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boaz Segev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- bin/poc/gemfile
|
110
110
|
- bin/poc/www/index.html
|
111
111
|
- bin/raw-rbhttp
|
112
|
+
- bin/raw-rbhttp-em
|
112
113
|
- bin/raw_broadcast
|
113
114
|
- bin/test_with_faye
|
114
115
|
- bin/ws-broadcast
|