diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-10-29 18:08:08 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-10-29 18:08:08 +0900 |
commit | 0c673248ab51517532cb5782f4999bd870b7023e (patch) | |
tree | d06a06400bf6c7e239a25310595a7a370c66a983 | |
parent | 0f2da4636e108c70697c589d9e38781f2bafefba (diff) | |
parent | a98fecfbfa095ceee45b963c07480ed9331c48e2 (diff) | |
download | gnunet-0c673248ab51517532cb5782f4999bd870b7023e.tar.gz gnunet-0c673248ab51517532cb5782f4999bd870b7023e.zip |
Merge branch 'master' of git+ssh://git.gnunet.org/gnunet
-rw-r--r-- | src/fs/fs_api.c | 38 | ||||
-rw-r--r-- | src/fs/fs_list_indexed.c | 6 | ||||
-rw-r--r-- | src/fs/gnunet-fs.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_mst_lib.h | 2 | ||||
-rw-r--r-- | src/util/client.c | 7 | ||||
-rw-r--r-- | src/util/mq.c | 1 | ||||
-rw-r--r-- | src/util/mst.c | 21 |
7 files changed, 34 insertions, 43 deletions
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index c1b5ef84b..6e97a3812 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c | |||
@@ -3190,16 +3190,20 @@ deserialize_download_file (void *cls, const char *filename) | |||
3190 | if (NULL == rh) | 3190 | if (NULL == rh) |
3191 | { | 3191 | { |
3192 | if (0 != unlink (filename)) | 3192 | if (0 != unlink (filename)) |
3193 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); | 3193 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
3194 | "unlink", | ||
3195 | filename); | ||
3194 | GNUNET_free (set); | 3196 | GNUNET_free (set); |
3195 | return GNUNET_OK; | 3197 | return GNUNET_OK; |
3196 | } | 3198 | } |
3197 | deserialize_download (h, rh, NULL, NULL, set); | 3199 | deserialize_download (h, rh, NULL, NULL, set); |
3198 | GNUNET_free (set); | 3200 | GNUNET_free (set); |
3199 | if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) | 3201 | if (GNUNET_OK != |
3202 | GNUNET_BIO_read_close (rh, | ||
3203 | &emsg)) | ||
3200 | { | 3204 | { |
3201 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3205 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3202 | _ ("Failure while resuming download operation `%s': %s\n"), | 3206 | "Failure while resuming download operation `%s': %s\n", |
3203 | filename, | 3207 | filename, |
3204 | emsg); | 3208 | emsg); |
3205 | GNUNET_free (emsg); | 3209 | GNUNET_free (emsg); |
@@ -3225,23 +3229,16 @@ deserialization_master (const char *master_path, | |||
3225 | dn = get_serialization_file_name (h, master_path, ""); | 3229 | dn = get_serialization_file_name (h, master_path, ""); |
3226 | if (NULL == dn) | 3230 | if (NULL == dn) |
3227 | return; | 3231 | return; |
3228 | if (GNUNET_YES == GNUNET_DISK_directory_test (dn, GNUNET_YES)) | 3232 | if (GNUNET_YES == |
3229 | GNUNET_DISK_directory_scan (dn, proc, h); | 3233 | GNUNET_DISK_directory_test (dn, |
3234 | GNUNET_YES)) | ||
3235 | GNUNET_DISK_directory_scan (dn, | ||
3236 | proc, | ||
3237 | h); | ||
3230 | GNUNET_free (dn); | 3238 | GNUNET_free (dn); |
3231 | } | 3239 | } |
3232 | 3240 | ||
3233 | 3241 | ||
3234 | /** | ||
3235 | * Setup a connection to the file-sharing service. | ||
3236 | * | ||
3237 | * @param cfg configuration to use | ||
3238 | * @param client_name unique identifier for this client | ||
3239 | * @param upcb function to call to notify about FS actions | ||
3240 | * @param upcb_cls closure for @a upcb | ||
3241 | * @param flags specific attributes for fs-operations | ||
3242 | * @param ... list of optional options, terminated with #GNUNET_FS_OPTIONS_END | ||
3243 | * @return NULL on error | ||
3244 | */ | ||
3245 | struct GNUNET_FS_Handle * | 3242 | struct GNUNET_FS_Handle * |
3246 | GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 3243 | GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
3247 | const char *client_name, | 3244 | const char *client_name, |
@@ -3308,15 +3305,6 @@ GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
3308 | } | 3305 | } |
3309 | 3306 | ||
3310 | 3307 | ||
3311 | /** | ||
3312 | * Close our connection with the file-sharing service. | ||
3313 | * The callback given to #GNUNET_FS_start() will no longer be | ||
3314 | * called after this function returns. | ||
3315 | * This function MUST NOT be called from within the | ||
3316 | * callback itself. | ||
3317 | * | ||
3318 | * @param h handle that was returned from #GNUNET_FS_start() | ||
3319 | */ | ||
3320 | void | 3308 | void |
3321 | GNUNET_FS_stop (struct GNUNET_FS_Handle *h) | 3309 | GNUNET_FS_stop (struct GNUNET_FS_Handle *h) |
3322 | { | 3310 | { |
diff --git a/src/fs/fs_list_indexed.c b/src/fs/fs_list_indexed.c index 7cd6161e3..eaee4ce55 100644 --- a/src/fs/fs_list_indexed.c +++ b/src/fs/fs_list_indexed.c | |||
@@ -148,10 +148,12 @@ mq_error_handler (void *cls, | |||
148 | struct GNUNET_FS_GetIndexedContext *gic = cls; | 148 | struct GNUNET_FS_GetIndexedContext *gic = cls; |
149 | 149 | ||
150 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 150 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
151 | _ ("Failed to receive response from `%s' service (error code is %d).\n"), | 151 | "Failed to receive response from `%s' service (error code is %d).\n", |
152 | "fs", | 152 | "fs", |
153 | error); | 153 | error); |
154 | (void) gic->iterator (gic->iterator_cls, NULL, NULL); | 154 | (void) gic->iterator (gic->iterator_cls, |
155 | NULL, | ||
156 | NULL); | ||
155 | GNUNET_FS_get_indexed_files_cancel (gic); | 157 | GNUNET_FS_get_indexed_files_cancel (gic); |
156 | } | 158 | } |
157 | 159 | ||
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c index f9d63e101..0f8f02a1c 100644 --- a/src/fs/gnunet-fs.c +++ b/src/fs/gnunet-fs.c | |||
@@ -57,7 +57,7 @@ static unsigned int verbose; | |||
57 | * @param cls closure | 57 | * @param cls closure |
58 | * @param filename the name of the file | 58 | * @param filename the name of the file |
59 | * @param file_id hash of the contents of the indexed file | 59 | * @param file_id hash of the contents of the indexed file |
60 | * @return GNUNET_OK to continue iteration | 60 | * @return #GNUNET_OK to continue iteration |
61 | */ | 61 | */ |
62 | static enum GNUNET_GenericReturnValue | 62 | static enum GNUNET_GenericReturnValue |
63 | print_indexed (void *cls, | 63 | print_indexed (void *cls, |
diff --git a/src/include/gnunet_mst_lib.h b/src/include/gnunet_mst_lib.h index 43a8ab838..ec82ce357 100644 --- a/src/include/gnunet_mst_lib.h +++ b/src/include/gnunet_mst_lib.h | |||
@@ -103,7 +103,7 @@ GNUNET_MST_create (GNUNET_MessageTokenizerCallback cb, | |||
103 | * #GNUNET_NO if one_shot was set and we have another message ready | 103 | * #GNUNET_NO if one_shot was set and we have another message ready |
104 | * #GNUNET_SYSERR if the data stream is corrupt | 104 | * #GNUNET_SYSERR if the data stream is corrupt |
105 | */ | 105 | */ |
106 | int | 106 | enum GNUNET_GenericReturnValue |
107 | GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | 107 | GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, |
108 | const char *buf, | 108 | const char *buf, |
109 | size_t size, | 109 | size_t size, |
diff --git a/src/util/client.c b/src/util/client.c index 686e0562a..91e0c1a85 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -267,7 +267,7 @@ transmit_ready (void *cls) | |||
267 | cstate->sock, | 267 | cstate->sock, |
268 | cstate->mq); | 268 | cstate->mq); |
269 | 269 | ||
270 | RETRY: | 270 | RETRY: |
271 | ret = GNUNET_NETWORK_socket_send (cstate->sock, | 271 | ret = GNUNET_NETWORK_socket_send (cstate->sock, |
272 | &pos[cstate->msg_off], | 272 | &pos[cstate->msg_off], |
273 | len - cstate->msg_off); | 273 | len - cstate->msg_off); |
@@ -330,7 +330,7 @@ transmit_ready (void *cls) | |||
330 | * #GNUNET_NO to stop further processing due to disconnect (no error) | 330 | * #GNUNET_NO to stop further processing due to disconnect (no error) |
331 | * #GNUNET_SYSERR to stop further processing due to error | 331 | * #GNUNET_SYSERR to stop further processing due to error |
332 | */ | 332 | */ |
333 | static int | 333 | static enum GNUNET_GenericReturnValue |
334 | recv_message (void *cls, | 334 | recv_message (void *cls, |
335 | const struct GNUNET_MessageHeader *msg) | 335 | const struct GNUNET_MessageHeader *msg) |
336 | { | 336 | { |
@@ -439,7 +439,7 @@ static void | |||
439 | receive_ready (void *cls) | 439 | receive_ready (void *cls) |
440 | { | 440 | { |
441 | struct ClientState *cstate = cls; | 441 | struct ClientState *cstate = cls; |
442 | int ret; | 442 | enum GNUNET_GenericReturnValue ret; |
443 | 443 | ||
444 | cstate->recv_task = NULL; | 444 | cstate->recv_task = NULL; |
445 | cstate->in_destroy = GNUNET_SYSERR; | 445 | cstate->in_destroy = GNUNET_SYSERR; |
@@ -464,6 +464,7 @@ receive_ready (void *cls) | |||
464 | return; | 464 | return; |
465 | } | 465 | } |
466 | cstate->in_destroy = GNUNET_NO; | 466 | cstate->in_destroy = GNUNET_NO; |
467 | GNUNET_assert (NULL == cstate->recv_task); | ||
467 | cstate->recv_task | 468 | cstate->recv_task |
468 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 469 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
469 | cstate->sock, | 470 | cstate->sock, |
diff --git a/src/util/mq.c b/src/util/mq.c index 8749d5d21..585389ce8 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -192,6 +192,7 @@ GNUNET_MQ_inject_message (struct GNUNET_MQ_Handle *mq, | |||
192 | mh); | 192 | mh); |
193 | if (GNUNET_SYSERR == ret) | 193 | if (GNUNET_SYSERR == ret) |
194 | { | 194 | { |
195 | GNUNET_break_op (0); | ||
195 | GNUNET_MQ_inject_error (mq, | 196 | GNUNET_MQ_inject_error (mq, |
196 | GNUNET_MQ_ERROR_MALFORMED); | 197 | GNUNET_MQ_ERROR_MALFORMED); |
197 | return; | 198 | return; |
diff --git a/src/util/mst.c b/src/util/mst.c index 264fdb979..18f144906 100644 --- a/src/util/mst.c +++ b/src/util/mst.c | |||
@@ -96,7 +96,7 @@ GNUNET_MST_create (GNUNET_MessageTokenizerCallback cb, | |||
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | int | 99 | enum GNUNET_GenericReturnValue |
100 | GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | 100 | GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, |
101 | const char *buf, | 101 | const char *buf, |
102 | size_t size, | 102 | size_t size, |
@@ -107,8 +107,6 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | |||
107 | size_t delta; | 107 | size_t delta; |
108 | uint16_t want; | 108 | uint16_t want; |
109 | char *ibuf; | 109 | char *ibuf; |
110 | int need_align; | ||
111 | unsigned long offset; | ||
112 | int ret; | 110 | int ret; |
113 | int cbret; | 111 | int cbret; |
114 | 112 | ||
@@ -124,7 +122,7 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | |||
124 | ibuf = (char *) mst->hdr; | 122 | ibuf = (char *) mst->hdr; |
125 | while (mst->pos > 0) | 123 | while (mst->pos > 0) |
126 | { | 124 | { |
127 | do_align: | 125 | do_align: |
128 | GNUNET_assert (mst->pos >= mst->off); | 126 | GNUNET_assert (mst->pos >= mst->off); |
129 | if ((mst->curr_buf - mst->off < sizeof(struct GNUNET_MessageHeader)) || | 127 | if ((mst->curr_buf - mst->off < sizeof(struct GNUNET_MessageHeader)) || |
130 | (0 != (mst->off % ALIGN_FACTOR))) | 128 | (0 != (mst->off % ALIGN_FACTOR))) |
@@ -240,14 +238,15 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | |||
240 | GNUNET_assert (0 == mst->pos); | 238 | GNUNET_assert (0 == mst->pos); |
241 | while (size > 0) | 239 | while (size > 0) |
242 | { | 240 | { |
241 | unsigned long offset = (unsigned long) buf; | ||
242 | bool need_align = (0 != (offset % ALIGN_FACTOR)); | ||
243 | |||
243 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 244 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
244 | "Server-mst has %u bytes left in inbound buffer\n", | 245 | "Server-mst has %u bytes left in inbound buffer\n", |
245 | (unsigned int) size); | 246 | (unsigned int) size); |
246 | if (size < sizeof(struct GNUNET_MessageHeader)) | 247 | if (size < sizeof(struct GNUNET_MessageHeader)) |
247 | break; | 248 | break; |
248 | offset = (unsigned long) buf; | 249 | if (! need_align) |
249 | need_align = (0 != (offset % ALIGN_FACTOR)) ? GNUNET_YES : GNUNET_NO; | ||
250 | if (GNUNET_NO == need_align) | ||
251 | { | 250 | { |
252 | /* can try to do zero-copy and process directly from original buffer */ | 251 | /* can try to do zero-copy and process directly from original buffer */ |
253 | hdr = (const struct GNUNET_MessageHeader *) buf; | 252 | hdr = (const struct GNUNET_MessageHeader *) buf; |
@@ -267,7 +266,7 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | |||
267 | ret = GNUNET_NO; | 266 | ret = GNUNET_NO; |
268 | goto copy; | 267 | goto copy; |
269 | } | 268 | } |
270 | if (one_shot == GNUNET_YES) | 269 | if (GNUNET_YES == one_shot) |
271 | one_shot = GNUNET_SYSERR; | 270 | one_shot = GNUNET_SYSERR; |
272 | if (GNUNET_OK != | 271 | if (GNUNET_OK != |
273 | (cbret = mst->cb (mst->cb_cls, | 272 | (cbret = mst->cb (mst->cb_cls, |
@@ -290,7 +289,7 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | |||
290 | goto do_align; | 289 | goto do_align; |
291 | } | 290 | } |
292 | } | 291 | } |
293 | copy: | 292 | copy: |
294 | if ((size > 0) && (! purge)) | 293 | if ((size > 0) && (! purge)) |
295 | { | 294 | { |
296 | if (size + mst->pos > mst->curr_buf) | 295 | if (size + mst->pos > mst->curr_buf) |
@@ -334,7 +333,7 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | |||
334 | * #GNUNET_NO if one_shot was set and we have another message ready | 333 | * #GNUNET_NO if one_shot was set and we have another message ready |
335 | * #GNUNET_SYSERR if the data stream is corrupt | 334 | * #GNUNET_SYSERR if the data stream is corrupt |
336 | */ | 335 | */ |
337 | int | 336 | enum GNUNET_GenericReturnValue |
338 | GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst, | 337 | GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst, |
339 | struct GNUNET_NETWORK_Handle *sock, | 338 | struct GNUNET_NETWORK_Handle *sock, |
340 | int purge, | 339 | int purge, |
@@ -383,7 +382,7 @@ GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst, | |||
383 | * #GNUNET_NO if one_shot was set and we have another message ready | 382 | * #GNUNET_NO if one_shot was set and we have another message ready |
384 | * #GNUNET_SYSERR if the data stream is corrupt | 383 | * #GNUNET_SYSERR if the data stream is corrupt |
385 | */ | 384 | */ |
386 | int | 385 | enum GNUNET_GenericReturnValue |
387 | GNUNET_MST_next (struct GNUNET_MessageStreamTokenizer *mst, | 386 | GNUNET_MST_next (struct GNUNET_MessageStreamTokenizer *mst, |
388 | int one_shot) | 387 | int one_shot) |
389 | { | 388 | { |