diff options
author | t3sserakt <t3ss@posteo.de> | 2021-01-25 15:47:22 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-01-25 15:55:14 +0100 |
commit | 4eeb7fbf0a9aba7d5853ea94b1b04a6dda75a811 (patch) | |
tree | b16ba7dcf2589ac7afc20a99ad5bb5c4ba2b5d3b | |
parent | ac71165822501c42b00980db2fb7f5e2144f3d20 (diff) | |
parent | b7abb3a11f1b8252945fab43c4575741fa90143b (diff) | |
download | gnunet-4eeb7fbf0a9aba7d5853ea94b1b04a6dda75a811.tar.gz gnunet-4eeb7fbf0a9aba7d5853ea94b1b04a6dda75a811.zip |
Merge branch 'master' of ssh://gnunet.org/gnunet
-rwxr-xr-x | .buildbot/firefly-x86_64-amdepyc_test_tng.sh | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/hello/gnunet-hello.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_program_lib.h | 14 | ||||
-rw-r--r-- | src/include/gnunet_time_lib.h | 2 | ||||
-rw-r--r-- | src/pq/pq_result_helper.c | 11 | ||||
-rw-r--r-- | src/setu/gnunet-service-setu.c | 3 | ||||
-rw-r--r-- | src/setu/ibf.c | 103 | ||||
-rw-r--r-- | src/testbed/testbed_api_test.c | 12 | ||||
-rw-r--r-- | src/util/getopt.c | 23 | ||||
-rw-r--r-- | src/util/program.c | 87 | ||||
-rw-r--r-- | src/util/test_configuration.c | 40 | ||||
-rw-r--r-- | src/util/test_os_start_process.c | 10 | ||||
-rw-r--r-- | src/util/time.c | 32 |
14 files changed, 208 insertions, 135 deletions
diff --git a/.buildbot/firefly-x86_64-amdepyc_test_tng.sh b/.buildbot/firefly-x86_64-amdepyc_test_tng.sh index ff504ae57..f247f5a69 100755 --- a/.buildbot/firefly-x86_64-amdepyc_test_tng.sh +++ b/.buildbot/firefly-x86_64-amdepyc_test_tng.sh | |||
@@ -3,6 +3,6 @@ | |||
3 | # echo "Skipped" | 3 | # echo "Skipped" |
4 | 4 | ||
5 | pushd src/transport | 5 | pushd src/transport |
6 | make check TESTS='test_communicator_basic-tcp test_communicator_rekey-tcp test_communicator_basic-unix test_communicator_basic-udp test_communicator_backchannel-udp test_communicator_rekey-udp' | 6 | make check TESTS='test_communicator_basic-tcp test_communicator_rekey-tcp test_communicator_basic-unix test_communicator_basic-udp test_communicator_backchannel-udp test_communicator_rekey-udp test_communicator_bidirect-tcp' |
7 | pkill --signal 9 -U buildbot gnunet | 7 | pkill --signal 9 -U buildbot gnunet |
8 | popd | 8 | popd |
diff --git a/configure.ac b/configure.ac index 530e38d88..eca988bb3 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1538,7 +1538,7 @@ AC_FUNC_VPRINTF | |||
1538 | AC_HEADER_SYS_WAIT | 1538 | AC_HEADER_SYS_WAIT |
1539 | AC_TYPE_OFF_T | 1539 | AC_TYPE_OFF_T |
1540 | AC_TYPE_UID_T | 1540 | AC_TYPE_UID_T |
1541 | AC_CHECK_FUNCS([atoll stat64 strnlen mremap getrlimit setrlimit sysconf initgroups strndup gethostbyname2 getpeerucred getpeereid setresuid $funcstocheck getifaddrs freeifaddrs getresgid mallinfo malloc_size malloc_usable_size getrusage random srandom stat statfs statvfs wait4]) | 1541 | AC_CHECK_FUNCS([atoll stat64 strnlen mremap getrlimit setrlimit sysconf initgroups strndup gethostbyname2 getpeerucred getpeereid setresuid $funcstocheck getifaddrs freeifaddrs getresgid mallinfo malloc_size malloc_usable_size getrusage random srandom stat statfs statvfs wait4 timegm]) |
1542 | 1542 | ||
1543 | # restore LIBS | 1543 | # restore LIBS |
1544 | LIBS=$SAVE_LIBS | 1544 | LIBS=$SAVE_LIBS |
diff --git a/src/hello/gnunet-hello.c b/src/hello/gnunet-hello.c index b3f48322b..1f110ac18 100644 --- a/src/hello/gnunet-hello.c +++ b/src/hello/gnunet-hello.c | |||
@@ -51,7 +51,7 @@ static int address_count; | |||
51 | 51 | ||
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Add the given address with infinit expiration to the buffer. | 54 | * Add the given address with infinite expiration to the buffer. |
55 | * | 55 | * |
56 | * @param cls closure | 56 | * @param cls closure |
57 | * @param address address to add | 57 | * @param address address to add |
diff --git a/src/include/gnunet_program_lib.h b/src/include/gnunet_program_lib.h index adb159e55..4167060c0 100644 --- a/src/include/gnunet_program_lib.h +++ b/src/include/gnunet_program_lib.h | |||
@@ -72,9 +72,12 @@ typedef void | |||
72 | * @param task_cls closure for @a task | 72 | * @param task_cls closure for @a task |
73 | * @param run_without_scheduler #GNUNET_NO start the scheduler, | 73 | * @param run_without_scheduler #GNUNET_NO start the scheduler, |
74 | * #GNUNET_YES do not start the scheduler just run the main task | 74 | * #GNUNET_YES do not start the scheduler just run the main task |
75 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 75 | * @return #GNUNET_SYSERR on error, |
76 | * #GNUNET_NO if successful option processing called | ||
77 | * for the program to terminate, | ||
78 | * #GNUNET_OK on success (#a task was invoked) | ||
76 | */ | 79 | */ |
77 | int | 80 | enum GNUNET_GenericReturnValue |
78 | GNUNET_PROGRAM_run2 (int argc, | 81 | GNUNET_PROGRAM_run2 (int argc, |
79 | char *const *argv, | 82 | char *const *argv, |
80 | const char *binaryName, | 83 | const char *binaryName, |
@@ -96,9 +99,12 @@ GNUNET_PROGRAM_run2 (int argc, | |||
96 | * @param options command line options | 99 | * @param options command line options |
97 | * @param task main function to run | 100 | * @param task main function to run |
98 | * @param task_cls closure for @a task | 101 | * @param task_cls closure for @a task |
99 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 102 | * @return #GNUNET_SYSERR on error, |
103 | * #GNUNET_NO if successful option processing called | ||
104 | * for the program to terminate, | ||
105 | * #GNUNET_OK on success (#a task was invoked) | ||
100 | */ | 106 | */ |
101 | int | 107 | enum GNUNET_GenericReturnValue |
102 | GNUNET_PROGRAM_run (int argc, | 108 | GNUNET_PROGRAM_run (int argc, |
103 | char *const *argv, | 109 | char *const *argv, |
104 | const char *binaryName, | 110 | const char *binaryName, |
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index 1237c4a65..38c372f23 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h | |||
@@ -179,7 +179,7 @@ GNUNET_NETWORK_STRUCT_END | |||
179 | #define GNUNET_TIME_STD_BACKOFF(r) GNUNET_TIME_relative_min ( \ | 179 | #define GNUNET_TIME_STD_BACKOFF(r) GNUNET_TIME_relative_min ( \ |
180 | GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD, \ | 180 | GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD, \ |
181 | GNUNET_TIME_relative_multiply ( \ | 181 | GNUNET_TIME_relative_multiply ( \ |
182 | GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, (r)), 2)); | 182 | GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, (r)), 2)) |
183 | 183 | ||
184 | 184 | ||
185 | /** | 185 | /** |
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index 546822e45..204ccee72 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c | |||
@@ -170,6 +170,9 @@ extract_fixed_blob (void *cls, | |||
170 | if (fnum < 0) | 170 | if (fnum < 0) |
171 | { | 171 | { |
172 | GNUNET_break (0); | 172 | GNUNET_break (0); |
173 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
174 | "Result does not have field %s\n", | ||
175 | fname); | ||
173 | return GNUNET_SYSERR; | 176 | return GNUNET_SYSERR; |
174 | } | 177 | } |
175 | if (PQgetisnull (result, | 178 | if (PQgetisnull (result, |
@@ -187,6 +190,11 @@ extract_fixed_blob (void *cls, | |||
187 | fnum); | 190 | fnum); |
188 | if (*dst_size != len) | 191 | if (*dst_size != len) |
189 | { | 192 | { |
193 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
194 | "Expected %u bytes for field `%s', got %u\n", | ||
195 | (unsigned int) *dst_size, | ||
196 | fname, | ||
197 | (unsigned int) len); | ||
190 | GNUNET_break (0); | 198 | GNUNET_break (0); |
191 | return GNUNET_SYSERR; | 199 | return GNUNET_SYSERR; |
192 | } | 200 | } |
@@ -861,6 +869,9 @@ extract_uint64 (void *cls, | |||
861 | fname); | 869 | fname); |
862 | if (fnum < 0) | 870 | if (fnum < 0) |
863 | { | 871 | { |
872 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
873 | "Field %s missing in result\n", | ||
874 | fname); | ||
864 | GNUNET_break (0); | 875 | GNUNET_break (0); |
865 | return GNUNET_SYSERR; | 876 | return GNUNET_SYSERR; |
866 | } | 877 | } |
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c index e7f27bd7d..e5d8751f2 100644 --- a/src/setu/gnunet-service-setu.c +++ b/src/setu/gnunet-service-setu.c | |||
@@ -1000,7 +1000,8 @@ op_register_element (struct Operation *op, | |||
1000 | 1000 | ||
1001 | 1001 | ||
1002 | /** | 1002 | /** |
1003 | * FIXME. | 1003 | * Modify an IBF key @a k_in based on the @a salt, returning a |
1004 | * salted key in @a k_out. | ||
1004 | */ | 1005 | */ |
1005 | static void | 1006 | static void |
1006 | salt_key (const struct IBF_Key *k_in, | 1007 | salt_key (const struct IBF_Key *k_in, |
diff --git a/src/setu/ibf.c b/src/setu/ibf.c index 1532afceb..79b4f28db 100644 --- a/src/setu/ibf.c +++ b/src/setu/ibf.c | |||
@@ -112,7 +112,7 @@ ibf_create (uint32_t size, uint8_t hash_num) | |||
112 | 112 | ||
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Store unique bucket indices for the specified key in dst. | 115 | * Store unique bucket indices for the specified @a key in @a dst. |
116 | */ | 116 | */ |
117 | static void | 117 | static void |
118 | ibf_get_indices (const struct InvertibleBloomFilter *ibf, | 118 | ibf_get_indices (const struct InvertibleBloomFilter *ibf, |
@@ -126,13 +126,13 @@ ibf_get_indices (const struct InvertibleBloomFilter *ibf, | |||
126 | bucket = GNUNET_CRYPTO_crc32_n (&key, sizeof key); | 126 | bucket = GNUNET_CRYPTO_crc32_n (&key, sizeof key); |
127 | for (i = 0, filled = 0; filled < ibf->hash_num; i++) | 127 | for (i = 0, filled = 0; filled < ibf->hash_num; i++) |
128 | { | 128 | { |
129 | unsigned int j; | ||
130 | uint64_t x; | 129 | uint64_t x; |
131 | for (j = 0; j < filled; j++) | 130 | |
132 | if (dst[j] == bucket) | 131 | for (unsigned int j = 0; j < filled; j++) |
132 | if (dst[j] == bucket % ibf->size) | ||
133 | goto try_next; | 133 | goto try_next; |
134 | dst[filled++] = bucket % ibf->size; | 134 | dst[filled++] = bucket % ibf->size; |
135 | try_next:; | 135 | try_next: |
136 | x = ((uint64_t) bucket << 32) | i; | 136 | x = ((uint64_t) bucket << 32) | i; |
137 | bucket = GNUNET_CRYPTO_crc32_n (&x, sizeof x); | 137 | bucket = GNUNET_CRYPTO_crc32_n (&x, sizeof x); |
138 | } | 138 | } |
@@ -142,13 +142,13 @@ try_next:; | |||
142 | static void | 142 | static void |
143 | ibf_insert_into (struct InvertibleBloomFilter *ibf, | 143 | ibf_insert_into (struct InvertibleBloomFilter *ibf, |
144 | struct IBF_Key key, | 144 | struct IBF_Key key, |
145 | const int *buckets, int side) | 145 | const int *buckets, |
146 | int side) | ||
146 | { | 147 | { |
147 | int i; | 148 | for (unsigned int i = 0; i < ibf->hash_num; i++) |
148 | |||
149 | for (i = 0; i < ibf->hash_num; i++) | ||
150 | { | 149 | { |
151 | const int bucket = buckets[i]; | 150 | const int bucket = buckets[i]; |
151 | |||
152 | ibf->count[bucket].count_val += side; | 152 | ibf->count[bucket].count_val += side; |
153 | ibf->key_sum[bucket].key_val ^= key.key_val; | 153 | ibf->key_sum[bucket].key_val ^= key.key_val; |
154 | ibf->key_hash_sum[bucket].key_hash_val | 154 | ibf->key_hash_sum[bucket].key_hash_val |
@@ -164,7 +164,8 @@ ibf_insert_into (struct InvertibleBloomFilter *ibf, | |||
164 | * @param key the element's hash code | 164 | * @param key the element's hash code |
165 | */ | 165 | */ |
166 | void | 166 | void |
167 | ibf_insert (struct InvertibleBloomFilter *ibf, struct IBF_Key key) | 167 | ibf_insert (struct InvertibleBloomFilter *ibf, |
168 | struct IBF_Key key) | ||
168 | { | 169 | { |
169 | int buckets[ibf->hash_num]; | 170 | int buckets[ibf->hash_num]; |
170 | 171 | ||
@@ -181,7 +182,8 @@ ibf_insert (struct InvertibleBloomFilter *ibf, struct IBF_Key key) | |||
181 | * @param key the element's hash code | 182 | * @param key the element's hash code |
182 | */ | 183 | */ |
183 | void | 184 | void |
184 | ibf_remove (struct InvertibleBloomFilter *ibf, struct IBF_Key key) | 185 | ibf_remove (struct InvertibleBloomFilter *ibf, |
186 | struct IBF_Key key) | ||
185 | { | 187 | { |
186 | int buckets[ibf->hash_num]; | 188 | int buckets[ibf->hash_num]; |
187 | 189 | ||
@@ -197,9 +199,7 @@ ibf_remove (struct InvertibleBloomFilter *ibf, struct IBF_Key key) | |||
197 | static int | 199 | static int |
198 | ibf_is_empty (struct InvertibleBloomFilter *ibf) | 200 | ibf_is_empty (struct InvertibleBloomFilter *ibf) |
199 | { | 201 | { |
200 | int i; | 202 | for (uint32_t i = 0; i < ibf->size; i++) |
201 | |||
202 | for (i = 0; i < ibf->size; i++) | ||
203 | { | 203 | { |
204 | if (0 != ibf->count[i].count_val) | 204 | if (0 != ibf->count[i].count_val) |
205 | return GNUNET_NO; | 205 | return GNUNET_NO; |
@@ -220,27 +220,25 @@ ibf_is_empty (struct InvertibleBloomFilter *ibf) | |||
220 | * A negative sign indicates that the element was recovered | 220 | * A negative sign indicates that the element was recovered |
221 | * resides in an IBF that was previously subtracted from. | 221 | * resides in an IBF that was previously subtracted from. |
222 | * @param ret_id receives the hash code of the decoded element, if successful | 222 | * @param ret_id receives the hash code of the decoded element, if successful |
223 | * @return GNUNET_YES if decoding an element was successful, | 223 | * @return #GNUNET_YES if decoding an element was successful, |
224 | * GNUNET_NO if the IBF is empty, | 224 | * #GNUNET_NO if the IBF is empty, |
225 | * GNUNET_SYSERR if the decoding has failed | 225 | * #GNUNET_SYSERR if the decoding has failed |
226 | */ | 226 | */ |
227 | int | 227 | int |
228 | ibf_decode (struct InvertibleBloomFilter *ibf, | 228 | ibf_decode (struct InvertibleBloomFilter *ibf, |
229 | int *ret_side, struct IBF_Key *ret_id) | 229 | int *ret_side, |
230 | struct IBF_Key *ret_id) | ||
230 | { | 231 | { |
231 | struct IBF_KeyHash hash; | 232 | struct IBF_KeyHash hash; |
232 | int i; | ||
233 | int buckets[ibf->hash_num]; | 233 | int buckets[ibf->hash_num]; |
234 | 234 | ||
235 | GNUNET_assert (NULL != ibf); | 235 | for (uint32_t i = 0; i < ibf->size; i++) |
236 | |||
237 | for (i = 0; i < ibf->size; i++) | ||
238 | { | 236 | { |
239 | int j; | ||
240 | int hit; | 237 | int hit; |
241 | 238 | ||
242 | /* we can only decode from pure buckets */ | 239 | /* we can only decode from pure buckets */ |
243 | if ((1 != ibf->count[i].count_val) && (-1 != ibf->count[i].count_val)) | 240 | if ( (1 != ibf->count[i].count_val) && |
241 | (-1 != ibf->count[i].count_val) ) | ||
244 | continue; | 242 | continue; |
245 | 243 | ||
246 | hash.key_hash_val = IBF_KEY_HASH_VAL (ibf->key_sum[i]); | 244 | hash.key_hash_val = IBF_KEY_HASH_VAL (ibf->key_sum[i]); |
@@ -253,7 +251,7 @@ ibf_decode (struct InvertibleBloomFilter *ibf, | |||
253 | * if not, the key hash was subject to collision */ | 251 | * if not, the key hash was subject to collision */ |
254 | hit = GNUNET_NO; | 252 | hit = GNUNET_NO; |
255 | ibf_get_indices (ibf, ibf->key_sum[i], buckets); | 253 | ibf_get_indices (ibf, ibf->key_sum[i], buckets); |
256 | for (j = 0; j < ibf->hash_num; j++) | 254 | for (int j = 0; j < ibf->hash_num; j++) |
257 | if (buckets[j] == i) | 255 | if (buckets[j] == i) |
258 | hit = GNUNET_YES; | 256 | hit = GNUNET_YES; |
259 | 257 | ||
@@ -287,7 +285,8 @@ ibf_decode (struct InvertibleBloomFilter *ibf, | |||
287 | * @param buf buffer to write the data to | 285 | * @param buf buffer to write the data to |
288 | */ | 286 | */ |
289 | void | 287 | void |
290 | ibf_write_slice (const struct InvertibleBloomFilter *ibf, uint32_t start, | 288 | ibf_write_slice (const struct InvertibleBloomFilter *ibf, |
289 | uint32_t start, | ||
291 | uint32_t count, void *buf) | 290 | uint32_t count, void *buf) |
292 | { | 291 | { |
293 | struct IBF_Key *key_dst; | 292 | struct IBF_Key *key_dst; |
@@ -298,16 +297,21 @@ ibf_write_slice (const struct InvertibleBloomFilter *ibf, uint32_t start, | |||
298 | 297 | ||
299 | /* copy keys */ | 298 | /* copy keys */ |
300 | key_dst = (struct IBF_Key *) buf; | 299 | key_dst = (struct IBF_Key *) buf; |
301 | GNUNET_memcpy (key_dst, ibf->key_sum + start, count * sizeof *key_dst); | 300 | GNUNET_memcpy (key_dst, |
301 | ibf->key_sum + start, | ||
302 | count * sizeof *key_dst); | ||
302 | key_dst += count; | 303 | key_dst += count; |
303 | /* copy key hashes */ | 304 | /* copy key hashes */ |
304 | key_hash_dst = (struct IBF_KeyHash *) key_dst; | 305 | key_hash_dst = (struct IBF_KeyHash *) key_dst; |
305 | GNUNET_memcpy (key_hash_dst, ibf->key_hash_sum + start, count | 306 | GNUNET_memcpy (key_hash_dst, |
306 | * sizeof *key_hash_dst); | 307 | ibf->key_hash_sum + start, |
308 | count * sizeof *key_hash_dst); | ||
307 | key_hash_dst += count; | 309 | key_hash_dst += count; |
308 | /* copy counts */ | 310 | /* copy counts */ |
309 | count_dst = (struct IBF_Count *) key_hash_dst; | 311 | count_dst = (struct IBF_Count *) key_hash_dst; |
310 | GNUNET_memcpy (count_dst, ibf->count + start, count * sizeof *count_dst); | 312 | GNUNET_memcpy (count_dst, |
313 | ibf->count + start, | ||
314 | count * sizeof *count_dst); | ||
311 | } | 315 | } |
312 | 316 | ||
313 | 317 | ||
@@ -320,8 +324,10 @@ ibf_write_slice (const struct InvertibleBloomFilter *ibf, uint32_t start, | |||
320 | * @param ibf the ibf to read from | 324 | * @param ibf the ibf to read from |
321 | */ | 325 | */ |
322 | void | 326 | void |
323 | ibf_read_slice (const void *buf, uint32_t start, uint32_t count, struct | 327 | ibf_read_slice (const void *buf, |
324 | InvertibleBloomFilter *ibf) | 328 | uint32_t start, |
329 | uint32_t count, | ||
330 | struct InvertibleBloomFilter *ibf) | ||
325 | { | 331 | { |
326 | struct IBF_Key *key_src; | 332 | struct IBF_Key *key_src; |
327 | struct IBF_KeyHash *key_hash_src; | 333 | struct IBF_KeyHash *key_hash_src; |
@@ -332,16 +338,21 @@ ibf_read_slice (const void *buf, uint32_t start, uint32_t count, struct | |||
332 | 338 | ||
333 | /* copy keys */ | 339 | /* copy keys */ |
334 | key_src = (struct IBF_Key *) buf; | 340 | key_src = (struct IBF_Key *) buf; |
335 | GNUNET_memcpy (ibf->key_sum + start, key_src, count * sizeof *key_src); | 341 | GNUNET_memcpy (ibf->key_sum + start, |
342 | key_src, | ||
343 | count * sizeof *key_src); | ||
336 | key_src += count; | 344 | key_src += count; |
337 | /* copy key hashes */ | 345 | /* copy key hashes */ |
338 | key_hash_src = (struct IBF_KeyHash *) key_src; | 346 | key_hash_src = (struct IBF_KeyHash *) key_src; |
339 | GNUNET_memcpy (ibf->key_hash_sum + start, key_hash_src, count | 347 | GNUNET_memcpy (ibf->key_hash_sum + start, |
340 | * sizeof *key_hash_src); | 348 | key_hash_src, |
349 | count * sizeof *key_hash_src); | ||
341 | key_hash_src += count; | 350 | key_hash_src += count; |
342 | /* copy counts */ | 351 | /* copy counts */ |
343 | count_src = (struct IBF_Count *) key_hash_src; | 352 | count_src = (struct IBF_Count *) key_hash_src; |
344 | GNUNET_memcpy (ibf->count + start, count_src, count * sizeof *count_src); | 353 | GNUNET_memcpy (ibf->count + start, |
354 | count_src, | ||
355 | count * sizeof *count_src); | ||
345 | } | 356 | } |
346 | 357 | ||
347 | 358 | ||
@@ -353,15 +364,13 @@ ibf_read_slice (const void *buf, uint32_t start, uint32_t count, struct | |||
353 | * @param ibf2 IBF that will be subtracted from ibf1 | 364 | * @param ibf2 IBF that will be subtracted from ibf1 |
354 | */ | 365 | */ |
355 | void | 366 | void |
356 | ibf_subtract (struct InvertibleBloomFilter *ibf1, const struct | 367 | ibf_subtract (struct InvertibleBloomFilter *ibf1, |
357 | InvertibleBloomFilter *ibf2) | 368 | const struct InvertibleBloomFilter *ibf2) |
358 | { | 369 | { |
359 | int i; | ||
360 | |||
361 | GNUNET_assert (ibf1->size == ibf2->size); | 370 | GNUNET_assert (ibf1->size == ibf2->size); |
362 | GNUNET_assert (ibf1->hash_num == ibf2->hash_num); | 371 | GNUNET_assert (ibf1->hash_num == ibf2->hash_num); |
363 | 372 | ||
364 | for (i = 0; i < ibf1->size; i++) | 373 | for (uint32_t i = 0; i < ibf1->size; i++) |
365 | { | 374 | { |
366 | ibf1->count[i].count_val -= ibf2->count[i].count_val; | 375 | ibf1->count[i].count_val -= ibf2->count[i].count_val; |
367 | ibf1->key_hash_sum[i].key_hash_val ^= ibf2->key_hash_sum[i].key_hash_val; | 376 | ibf1->key_hash_sum[i].key_hash_val ^= ibf2->key_hash_sum[i].key_hash_val; |
@@ -383,12 +392,12 @@ ibf_dup (const struct InvertibleBloomFilter *ibf) | |||
383 | copy = GNUNET_malloc (sizeof *copy); | 392 | copy = GNUNET_malloc (sizeof *copy); |
384 | copy->hash_num = ibf->hash_num; | 393 | copy->hash_num = ibf->hash_num; |
385 | copy->size = ibf->size; | 394 | copy->size = ibf->size; |
386 | copy->key_hash_sum = GNUNET_memdup (ibf->key_hash_sum, ibf->size | 395 | copy->key_hash_sum = GNUNET_memdup (ibf->key_hash_sum, |
387 | * sizeof(struct IBF_KeyHash)); | 396 | ibf->size * sizeof(struct IBF_KeyHash)); |
388 | copy->key_sum = GNUNET_memdup (ibf->key_sum, ibf->size * sizeof(struct | 397 | copy->key_sum = GNUNET_memdup (ibf->key_sum, |
389 | IBF_Key)); | 398 | ibf->size * sizeof(struct IBF_Key)); |
390 | copy->count = GNUNET_memdup (ibf->count, ibf->size * sizeof(struct | 399 | copy->count = GNUNET_memdup (ibf->count, |
391 | IBF_Count)); | 400 | ibf->size * sizeof(struct IBF_Count)); |
392 | return copy; | 401 | return copy; |
393 | } | 402 | } |
394 | 403 | ||
diff --git a/src/testbed/testbed_api_test.c b/src/testbed/testbed_api_test.c index 6179a23ef..30dbe455d 100644 --- a/src/testbed/testbed_api_test.c +++ b/src/testbed/testbed_api_test.c | |||
@@ -23,9 +23,11 @@ | |||
23 | * @brief high-level test function | 23 | * @brief high-level test function |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * @author Sree Harsha Totakura | 25 | * @author Sree Harsha Totakura |
26 | * @author Tobias Frisch | ||
26 | */ | 27 | */ |
27 | #include "platform.h" | 28 | #include "platform.h" |
28 | #include "gnunet_testbed_service.h" | 29 | #include "gnunet_testbed_service.h" |
30 | #include "testbed.h" | ||
29 | 31 | ||
30 | 32 | ||
31 | /** | 33 | /** |
@@ -143,6 +145,10 @@ GNUNET_TESTBED_test_run (const char *testname, | |||
143 | argv2[2] = GNUNET_strdup (cfg_filename); | 145 | argv2[2] = GNUNET_strdup (cfg_filename); |
144 | GNUNET_assert (NULL != test_master); | 146 | GNUNET_assert (NULL != test_master); |
145 | GNUNET_assert (num_peers > 0); | 147 | GNUNET_assert (num_peers > 0); |
148 | |||
149 | char* envcfg = getenv(ENV_TESTBED_CONFIG); | ||
150 | setenv(ENV_TESTBED_CONFIG, cfg_filename, 1); | ||
151 | |||
146 | rc = GNUNET_malloc (sizeof(struct TestRunContext) | 152 | rc = GNUNET_malloc (sizeof(struct TestRunContext) |
147 | + (num_peers * sizeof(struct GNUNET_TESTBED_Peer *))); | 153 | + (num_peers * sizeof(struct GNUNET_TESTBED_Peer *))); |
148 | rc->test_master = test_master; | 154 | rc->test_master = test_master; |
@@ -153,6 +159,12 @@ GNUNET_TESTBED_test_run (const char *testname, | |||
153 | rc->cc_cls = cc_cls; | 159 | rc->cc_cls = cc_cls; |
154 | ret = GNUNET_PROGRAM_run ((sizeof(argv2) / sizeof(char *)) - 1, argv2, | 160 | ret = GNUNET_PROGRAM_run ((sizeof(argv2) / sizeof(char *)) - 1, argv2, |
155 | testname, "nohelp", options, &run, rc); | 161 | testname, "nohelp", options, &run, rc); |
162 | |||
163 | if (envcfg) | ||
164 | setenv(ENV_TESTBED_CONFIG, envcfg, 1); | ||
165 | else | ||
166 | unsetenv(ENV_TESTBED_CONFIG); | ||
167 | |||
156 | GNUNET_free (rc); | 168 | GNUNET_free (rc); |
157 | GNUNET_free (argv2[0]); | 169 | GNUNET_free (argv2[0]); |
158 | GNUNET_free (argv2[2]); | 170 | GNUNET_free (argv2[2]); |
diff --git a/src/util/getopt.c b/src/util/getopt.c index acc1b6535..6dfad96da 100644 --- a/src/util/getopt.c +++ b/src/util/getopt.c | |||
@@ -878,16 +878,7 @@ GNgetopt_long (int argc, | |||
878 | 878 | ||
879 | /* ******************** now the GNUnet specific modifications... ********************* */ | 879 | /* ******************** now the GNUnet specific modifications... ********************* */ |
880 | 880 | ||
881 | /** | 881 | |
882 | * Parse the command line. | ||
883 | * | ||
884 | * @param binaryOptions Name of application with option summary | ||
885 | * @param allOptions defined options and handlers | ||
886 | * @param argc number of arguments | ||
887 | * @param argv actual arguments | ||
888 | * @return index into argv with first non-option | ||
889 | * argument, or #GNUNET_SYSERR on error | ||
890 | */ | ||
891 | int | 882 | int |
892 | GNUNET_GETOPT_run (const char *binaryOptions, | 883 | GNUNET_GETOPT_run (const char *binaryOptions, |
893 | const struct GNUNET_GETOPT_CommandLineOption *allOptions, | 884 | const struct GNUNET_GETOPT_CommandLineOption *allOptions, |
@@ -899,7 +890,7 @@ GNUNET_GETOPT_run (const char *binaryOptions, | |||
899 | int count; | 890 | int count; |
900 | char *shorts; | 891 | char *shorts; |
901 | int spos; | 892 | int spos; |
902 | int cont; | 893 | enum GNUNET_GenericReturnValue cont; |
903 | uint8_t *seen; | 894 | uint8_t *seen; |
904 | unsigned int optmatch = 0; | 895 | unsigned int optmatch = 0; |
905 | const char *have_exclusive = NULL; | 896 | const char *have_exclusive = NULL; |
@@ -944,7 +935,11 @@ GNUNET_GETOPT_run (const char *binaryOptions, | |||
944 | unsigned int i; | 935 | unsigned int i; |
945 | int c; | 936 | int c; |
946 | 937 | ||
947 | c = GNgetopt_long (argc, argv, shorts, long_options, &option_index); | 938 | c = GNgetopt_long (argc, |
939 | argv, | ||
940 | shorts, | ||
941 | long_options, | ||
942 | &option_index); | ||
948 | if (c == GNUNET_SYSERR) | 943 | if (c == GNUNET_SYSERR) |
949 | break; /* No more flags to process */ | 944 | break; /* No more flags to process */ |
950 | 945 | ||
@@ -971,7 +966,9 @@ GNUNET_GETOPT_run (const char *binaryOptions, | |||
971 | } | 966 | } |
972 | if (i == count) | 967 | if (i == count) |
973 | { | 968 | { |
974 | fprintf (stderr, _ ("Use %s to get a list of options.\n"), "--help"); | 969 | fprintf (stderr, |
970 | _ ("Use %s to get a list of options.\n"), | ||
971 | "--help"); | ||
975 | cont = GNUNET_SYSERR; | 972 | cont = GNUNET_SYSERR; |
976 | } | 973 | } |
977 | } | 974 | } |
diff --git a/src/util/program.c b/src/util/program.c index b5484855c..e34b37370 100644 --- a/src/util/program.c +++ b/src/util/program.c | |||
@@ -122,22 +122,7 @@ cmd_sorter (const void *a1, const void *a2) | |||
122 | } | 122 | } |
123 | 123 | ||
124 | 124 | ||
125 | /** | 125 | enum GNUNET_GenericReturnValue |
126 | * Run a standard GNUnet command startup sequence (initialize loggers | ||
127 | * and configuration, parse options). | ||
128 | * | ||
129 | * @param argc number of command line arguments in @a argv | ||
130 | * @param argv command line arguments | ||
131 | * @param binaryName our expected name | ||
132 | * @param binaryHelp help text for the program | ||
133 | * @param options command line options | ||
134 | * @param task main function to run | ||
135 | * @param task_cls closure for @a task | ||
136 | * @param run_without_scheduler #GNUNET_NO start the scheduler, #GNUNET_YES do not | ||
137 | * start the scheduler just run the main task | ||
138 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
139 | */ | ||
140 | int | ||
141 | GNUNET_PROGRAM_run2 (int argc, | 126 | GNUNET_PROGRAM_run2 (int argc, |
142 | char *const *argv, | 127 | char *const *argv, |
143 | const char *binaryName, | 128 | const char *binaryName, |
@@ -156,7 +141,8 @@ GNUNET_PROGRAM_run2 (int argc, | |||
156 | char *logfile; | 141 | char *logfile; |
157 | char *cfg_fn; | 142 | char *cfg_fn; |
158 | const char *xdg; | 143 | const char *xdg; |
159 | int ret; | 144 | enum GNUNET_GenericReturnValue ret; |
145 | int iret; | ||
160 | unsigned int cnt; | 146 | unsigned int cnt; |
161 | unsigned long long skew_offset; | 147 | unsigned long long skew_offset; |
162 | unsigned long long skew_variance; | 148 | unsigned long long skew_variance; |
@@ -232,7 +218,7 @@ GNUNET_PROGRAM_run2 (int argc, | |||
232 | sizeof(struct GNUNET_GETOPT_CommandLineOption), | 218 | sizeof(struct GNUNET_GETOPT_CommandLineOption), |
233 | &cmd_sorter); | 219 | &cmd_sorter); |
234 | loglev = NULL; | 220 | loglev = NULL; |
235 | if (NULL != pd->config_file && NULL != pd->user_config_file) | 221 | if ((NULL != pd->config_file) && (NULL != pd->user_config_file)) |
236 | { | 222 | { |
237 | xdg = getenv ("XDG_CONFIG_HOME"); | 223 | xdg = getenv ("XDG_CONFIG_HOME"); |
238 | if (NULL != xdg) | 224 | if (NULL != xdg) |
@@ -249,12 +235,18 @@ GNUNET_PROGRAM_run2 (int argc, | |||
249 | lpfx = GNUNET_strdup (binaryName); | 235 | lpfx = GNUNET_strdup (binaryName); |
250 | if (NULL != (spc = strstr (lpfx, " "))) | 236 | if (NULL != (spc = strstr (lpfx, " "))) |
251 | *spc = '\0'; | 237 | *spc = '\0'; |
252 | ret = GNUNET_GETOPT_run (binaryName, allopts, (unsigned int) argc, argv); | 238 | iret = GNUNET_GETOPT_run (binaryName, |
253 | if ((GNUNET_OK > ret) || | 239 | allopts, |
254 | (GNUNET_OK != GNUNET_log_setup (lpfx, loglev, logfile))) | 240 | (unsigned int) argc, |
241 | argv); | ||
242 | if ((GNUNET_OK > iret) || | ||
243 | (GNUNET_OK != GNUNET_log_setup (lpfx, | ||
244 | loglev, | ||
245 | logfile))) | ||
255 | { | 246 | { |
256 | GNUNET_free (allopts); | 247 | GNUNET_free (allopts); |
257 | GNUNET_free (lpfx); | 248 | GNUNET_free (lpfx); |
249 | ret = (enum GNUNET_GenericReturnValue) iret; | ||
258 | goto cleanup; | 250 | goto cleanup; |
259 | } | 251 | } |
260 | if (NULL != cc.cfgfile) | 252 | if (NULL != cc.cfgfile) |
@@ -274,7 +266,7 @@ GNUNET_PROGRAM_run2 (int argc, | |||
274 | } | 266 | } |
275 | else | 267 | else |
276 | { | 268 | { |
277 | if (NULL != cfg_fn && GNUNET_YES == GNUNET_DISK_file_test (cfg_fn)) | 269 | if ((NULL != cfg_fn) && (GNUNET_YES == GNUNET_DISK_file_test (cfg_fn))) |
278 | { | 270 | { |
279 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfg_fn)) | 271 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfg_fn)) |
280 | { | 272 | { |
@@ -306,14 +298,16 @@ GNUNET_PROGRAM_run2 (int argc, | |||
306 | } | 298 | } |
307 | GNUNET_free (allopts); | 299 | GNUNET_free (allopts); |
308 | GNUNET_free (lpfx); | 300 | GNUNET_free (lpfx); |
309 | if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cc.cfg, | 301 | if ((GNUNET_OK == |
310 | "testing", | 302 | GNUNET_CONFIGURATION_get_value_number (cc.cfg, |
311 | "skew_offset", | 303 | "testing", |
312 | &skew_offset)) && | 304 | "skew_offset", |
313 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cc.cfg, | 305 | &skew_offset)) && |
314 | "testing", | 306 | (GNUNET_OK == |
315 | "skew_variance", | 307 | GNUNET_CONFIGURATION_get_value_number (cc.cfg, |
316 | &skew_variance))) | 308 | "testing", |
309 | "skew_variance", | ||
310 | &skew_variance))) | ||
317 | { | 311 | { |
318 | clock_offset = skew_offset - skew_variance; | 312 | clock_offset = skew_offset - skew_variance; |
319 | GNUNET_TIME_set_offset (clock_offset); | 313 | GNUNET_TIME_set_offset (clock_offset); |
@@ -323,16 +317,26 @@ GNUNET_PROGRAM_run2 (int argc, | |||
323 | specified in the configuration, remember the command-line option | 317 | specified in the configuration, remember the command-line option |
324 | in "cfg". This is typically really only having an effect if we | 318 | in "cfg". This is typically really only having an effect if we |
325 | are running code in src/arm/, as obviously the rest of the code | 319 | are running code in src/arm/, as obviously the rest of the code |
326 | has little business with ARM-specific options. */if (GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg, "arm", "CONFIG")) | 320 | has little business with ARM-specific options. */ |
321 | if (GNUNET_YES != | ||
322 | GNUNET_CONFIGURATION_have_value (cfg, | ||
323 | "arm", | ||
324 | "CONFIG")) | ||
327 | { | 325 | { |
328 | if (NULL != cc.cfgfile) | 326 | if (NULL != cc.cfgfile) |
329 | GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", cc.cfgfile); | 327 | GNUNET_CONFIGURATION_set_value_string (cfg, |
328 | "arm", | ||
329 | "CONFIG", | ||
330 | cc.cfgfile); | ||
330 | else if (NULL != cfg_fn) | 331 | else if (NULL != cfg_fn) |
331 | GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", cfg_fn); | 332 | GNUNET_CONFIGURATION_set_value_string (cfg, |
333 | "arm", | ||
334 | "CONFIG", | ||
335 | cfg_fn); | ||
332 | } | 336 | } |
333 | 337 | ||
334 | /* run */ | 338 | /* run */ |
335 | cc.args = &argv[ret]; | 339 | cc.args = &argv[iret]; |
336 | if ((NULL == cc.cfgfile) && (NULL != cfg_fn)) | 340 | if ((NULL == cc.cfgfile) && (NULL != cfg_fn)) |
337 | cc.cfgfile = GNUNET_strdup (cfg_fn); | 341 | cc.cfgfile = GNUNET_strdup (cfg_fn); |
338 | if (GNUNET_NO == run_without_scheduler) | 342 | if (GNUNET_NO == run_without_scheduler) |
@@ -355,20 +359,7 @@ cleanup: | |||
355 | } | 359 | } |
356 | 360 | ||
357 | 361 | ||
358 | /** | 362 | enum GNUNET_GenericReturnValue |
359 | * Run a standard GNUnet command startup sequence (initialize loggers | ||
360 | * and configuration, parse options). | ||
361 | * | ||
362 | * @param argc number of command line arguments | ||
363 | * @param argv command line arguments | ||
364 | * @param binaryName our expected name | ||
365 | * @param binaryHelp help text for the program | ||
366 | * @param options command line options | ||
367 | * @param task main function to run | ||
368 | * @param task_cls closure for @a task | ||
369 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
370 | */ | ||
371 | int | ||
372 | GNUNET_PROGRAM_run (int argc, | 363 | GNUNET_PROGRAM_run (int argc, |
373 | char *const *argv, | 364 | char *const *argv, |
374 | const char *binaryName, | 365 | const char *binaryName, |
diff --git a/src/util/test_configuration.c b/src/util/test_configuration.c index 59b1b2291..823bf273d 100644 --- a/src/util/test_configuration.c +++ b/src/util/test_configuration.c | |||
@@ -70,12 +70,17 @@ initDiffsCBData (struct DiffsCBData *cbData) | |||
70 | * and comparing configuration | 70 | * and comparing configuration |
71 | */ | 71 | */ |
72 | static void | 72 | static void |
73 | diffsCallBack (void *cls, const char *section, const char *option, | 73 | diffsCallBack (void *cls, |
74 | const char *section, | ||
75 | const char *option, | ||
74 | const char *value) | 76 | const char *value) |
75 | { | 77 | { |
76 | struct DiffsCBData *cbData = cls; | 78 | struct DiffsCBData *cbData = cls; |
77 | int cbOption = cbData->callBackOption; | 79 | int cbOption = cbData->callBackOption; |
78 | 80 | ||
81 | if (0 == strcasecmp ("PATHS", | ||
82 | section)) | ||
83 | return; | ||
79 | switch (cbOption) | 84 | switch (cbOption) |
80 | { | 85 | { |
81 | case EDIT_SECTION: | 86 | case EDIT_SECTION: |
@@ -89,14 +94,12 @@ diffsCallBack (void *cls, const char *section, const char *option, | |||
89 | "new-value"); | 94 | "new-value"); |
90 | } | 95 | } |
91 | break; | 96 | break; |
92 | |||
93 | case EDIT_ALL: | 97 | case EDIT_ALL: |
94 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, | 98 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, |
95 | "new-value"); | 99 | "new-value"); |
96 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, option, | 100 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, option, |
97 | "new-value"); | 101 | "new-value"); |
98 | break; | 102 | break; |
99 | |||
100 | case ADD_NEW_ENTRY: | 103 | case ADD_NEW_ENTRY: |
101 | { | 104 | { |
102 | static int hit = 0; | 105 | static int hit = 0; |
@@ -111,7 +114,6 @@ diffsCallBack (void *cls, const char *section, const char *option, | |||
111 | } | 114 | } |
112 | break; | 115 | break; |
113 | } | 116 | } |
114 | |||
115 | case COMPARE: | 117 | case COMPARE: |
116 | { | 118 | { |
117 | int ret; | 119 | int ret; |
@@ -119,15 +121,32 @@ diffsCallBack (void *cls, const char *section, const char *option, | |||
119 | 121 | ||
120 | diffValue = NULL; | 122 | diffValue = NULL; |
121 | ret = | 123 | ret = |
122 | GNUNET_CONFIGURATION_get_value_string (cbData->cfgDiffs, section, | 124 | GNUNET_CONFIGURATION_get_value_string (cbData->cfgDiffs, |
123 | option, &diffValue); | 125 | section, |
126 | option, | ||
127 | &diffValue); | ||
124 | if (NULL != diffValue) | 128 | if (NULL != diffValue) |
125 | { | 129 | { |
126 | if ((ret == GNUNET_SYSERR) || (strcmp (diffValue, value) != 0) ) | 130 | if ( (ret == GNUNET_SYSERR) || |
131 | (strcmp (diffValue, value) != 0) ) | ||
132 | { | ||
133 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
134 | "Unexpected value %s in %s/%s\n", | ||
135 | diffValue, | ||
136 | section, | ||
137 | option); | ||
127 | cbData->status = 1; | 138 | cbData->status = 1; |
139 | } | ||
128 | } | 140 | } |
129 | else | 141 | else |
142 | { | ||
143 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
144 | "Unexpected value %s in %s/%s\n", | ||
145 | diffValue, | ||
146 | section, | ||
147 | option); | ||
130 | cbData->status = 1; | 148 | cbData->status = 1; |
149 | } | ||
131 | GNUNET_free (diffValue); | 150 | GNUNET_free (diffValue); |
132 | break; | 151 | break; |
133 | } | 152 | } |
@@ -153,7 +172,8 @@ diffsCallBack (void *cls, const char *section, const char *option, | |||
153 | 172 | ||
154 | 173 | ||
155 | static struct GNUNET_CONFIGURATION_Handle * | 174 | static struct GNUNET_CONFIGURATION_Handle * |
156 | editConfiguration (struct GNUNET_CONFIGURATION_Handle *cfg, int option) | 175 | editConfiguration (struct GNUNET_CONFIGURATION_Handle *cfg, |
176 | int option) | ||
157 | { | 177 | { |
158 | struct DiffsCBData diffsCB; | 178 | struct DiffsCBData diffsCB; |
159 | 179 | ||
@@ -244,7 +264,9 @@ checkDiffs (struct GNUNET_CONFIGURATION_Handle *cfg_default, int option) | |||
244 | diffsFileName); | 264 | diffsFileName); |
245 | cbData.callBackOption = COMPARE; | 265 | cbData.callBackOption = COMPARE; |
246 | cbData.cfgDiffs = cfgDiffs; | 266 | cbData.cfgDiffs = cfgDiffs; |
247 | GNUNET_CONFIGURATION_iterate (cfg, diffsCallBack, &cbData); | 267 | GNUNET_CONFIGURATION_iterate (cfg, |
268 | &diffsCallBack, | ||
269 | &cbData); | ||
248 | if (1 == (ret = cbData.status)) | 270 | if (1 == (ret = cbData.status)) |
249 | { | 271 | { |
250 | fprintf (stderr, "%s", | 272 | fprintf (stderr, "%s", |
diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c index ff5021d03..435b70e1a 100644 --- a/src/util/test_os_start_process.c +++ b/src/util/test_os_start_process.c | |||
@@ -118,29 +118,23 @@ read_call (void *cls) | |||
118 | static void | 118 | static void |
119 | run_task (void *cls) | 119 | run_task (void *cls) |
120 | { | 120 | { |
121 | char *fn; | ||
122 | const struct GNUNET_DISK_FileHandle *stdout_read_handle; | 121 | const struct GNUNET_DISK_FileHandle *stdout_read_handle; |
123 | const struct GNUNET_DISK_FileHandle *wh; | 122 | const struct GNUNET_DISK_FileHandle *wh; |
124 | 123 | ||
125 | GNUNET_asprintf (&fn, "cat"); | ||
126 | |||
127 | hello_pipe_stdin = GNUNET_DISK_pipe (GNUNET_DISK_PF_BLOCKING_RW); | 124 | hello_pipe_stdin = GNUNET_DISK_pipe (GNUNET_DISK_PF_BLOCKING_RW); |
128 | hello_pipe_stdout = GNUNET_DISK_pipe (GNUNET_DISK_PF_BLOCKING_RW); | 125 | hello_pipe_stdout = GNUNET_DISK_pipe (GNUNET_DISK_PF_BLOCKING_RW); |
129 | if ((hello_pipe_stdout == NULL) || (hello_pipe_stdin == NULL)) | 126 | if ((hello_pipe_stdout == NULL) || (hello_pipe_stdin == NULL)) |
130 | { | 127 | { |
131 | GNUNET_break (0); | 128 | GNUNET_break (0); |
132 | ok = 1; | 129 | ok = 1; |
133 | GNUNET_free (fn); | ||
134 | return; | 130 | return; |
135 | } | 131 | } |
136 | 132 | ||
137 | proc = | 133 | proc = |
138 | GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ERR, | 134 | GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ERR, |
139 | hello_pipe_stdin, hello_pipe_stdout, NULL, | 135 | hello_pipe_stdin, hello_pipe_stdout, NULL, |
140 | fn, | 136 | "cat", |
141 | "test_gnunet_echo_hello", "-", NULL); | 137 | "cat", "-", NULL); |
142 | GNUNET_free (fn); | ||
143 | |||
144 | /* Close the write end of the read pipe */ | 138 | /* Close the write end of the read pipe */ |
145 | GNUNET_DISK_pipe_close_end (hello_pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); | 139 | GNUNET_DISK_pipe_close_end (hello_pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); |
146 | /* Close the read end of the write pipe */ | 140 | /* Close the read end of the write pipe */ |
diff --git a/src/util/time.c b/src/util/time.c index 5205fe11a..9e41305f1 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -716,6 +716,32 @@ GNUNET_TIME_time_to_year (struct GNUNET_TIME_Absolute at) | |||
716 | } | 716 | } |
717 | 717 | ||
718 | 718 | ||
719 | #ifndef HAVE_TIMEGM | ||
720 | /** | ||
721 | * As suggested in the timegm() man page. | ||
722 | */ | ||
723 | static time_t | ||
724 | my_timegm (struct tm *tm) | ||
725 | { | ||
726 | time_t ret; | ||
727 | char *tz; | ||
728 | |||
729 | tz = getenv ("TZ"); | ||
730 | setenv ("TZ", "", 1); | ||
731 | tzset (); | ||
732 | ret = mktime (tm); | ||
733 | if (tz) | ||
734 | setenv ("TZ", tz, 1); | ||
735 | else | ||
736 | unsetenv ("TZ"); | ||
737 | tzset (); | ||
738 | return ret; | ||
739 | } | ||
740 | |||
741 | |||
742 | #endif | ||
743 | |||
744 | |||
719 | /** | 745 | /** |
720 | * Convert a year to an expiration time of January 1st of that year. | 746 | * Convert a year to an expiration time of January 1st of that year. |
721 | * | 747 | * |
@@ -740,7 +766,11 @@ GNUNET_TIME_year_to_time (unsigned int year) | |||
740 | t.tm_mon = 0; | 766 | t.tm_mon = 0; |
741 | t.tm_wday = 1; | 767 | t.tm_wday = 1; |
742 | t.tm_yday = 1; | 768 | t.tm_yday = 1; |
743 | tp = mktime (&t); | 769 | #ifndef HAVE_TIMEGM |
770 | tp = my_timegm (&t); | ||
771 | #else | ||
772 | tp = timegm (&t); | ||
773 | #endif | ||
744 | GNUNET_break (tp != (time_t) -1); | 774 | GNUNET_break (tp != (time_t) -1); |
745 | ret.abs_value_us = tp * 1000LL * 1000LL; /* seconds to microseconds */ | 775 | ret.abs_value_us = tp * 1000LL * 1000LL; /* seconds to microseconds */ |
746 | return ret; | 776 | return ret; |