diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-11-28 14:34:29 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-11-28 14:34:29 +0000 |
commit | 88d0a41984b0d779d5338eee596ab48c7b92b118 (patch) | |
tree | eeffe3a955cecafffd7d846ae2f8649e395fedea /src/fs/gnunet-service-fs_pr.c | |
parent | 127cb0ece2351d1022039cc0423b077c631bf0c5 (diff) | |
download | gnunet-88d0a41984b0d779d5338eee596ab48c7b92b118.tar.gz gnunet-88d0a41984b0d779d5338eee596ab48c7b92b118.zip |
-add retries, and retry limit (#2659)
Diffstat (limited to 'src/fs/gnunet-service-fs_pr.c')
-rw-r--r-- | src/fs/gnunet-service-fs_pr.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 2b235f9da..76e04f57c 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -64,6 +64,13 @@ | |||
64 | #define INSANE_STATISTICS GNUNET_NO | 64 | #define INSANE_STATISTICS GNUNET_NO |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * If obtaining a block via stream fails, how often do we retry it before | ||
68 | * giving up for good (and sticking to non-anonymous transfer)? | ||
69 | */ | ||
70 | #define STREAM_RETRY_MAX 3 | ||
71 | |||
72 | |||
73 | /** | ||
67 | * An active request. | 74 | * An active request. |
68 | */ | 75 | */ |
69 | struct GSF_PendingRequest | 76 | struct GSF_PendingRequest |
@@ -166,6 +173,12 @@ struct GSF_PendingRequest | |||
166 | uint64_t first_uid; | 173 | uint64_t first_uid; |
167 | 174 | ||
168 | /** | 175 | /** |
176 | * How often have we retried this request via 'stream'? | ||
177 | * (used to bound overall retries). | ||
178 | */ | ||
179 | unsigned int stream_retry_count; | ||
180 | |||
181 | /** | ||
169 | * Number of valid entries in the 'replies_seen' array. | 182 | * Number of valid entries in the 'replies_seen' array. |
170 | */ | 183 | */ |
171 | unsigned int replies_seen_count; | 184 | unsigned int replies_seen_count; |
@@ -1181,11 +1194,16 @@ stream_reply_proc (void *cls, | |||
1181 | GNUNET_break (0 == data_size); | 1194 | GNUNET_break (0 == data_size); |
1182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1183 | "Error retrieiving block via stream\n"); | 1196 | "Error retrieiving block via stream\n"); |
1184 | /* FIXME: maybe we should re-try a few times; but then | 1197 | pr->stream_retry_count++; |
1185 | we MUST bound the number of re-tries to not keep | 1198 | if (pr->stream_retry_count >= STREAM_RETRY_MAX) |
1186 | asking indefinitely with fresh streams; this should | 1199 | return; /* give up on stream */ |
1187 | be implemented if/when the stream code gets its | 1200 | /* retry -- without delay, as this is non-anonymous |
1188 | timeout/parallel-session limits */ | 1201 | and mesh/stream connect will take some time anyway */ |
1202 | pr->stream_request = GSF_stream_query (pr->public_data.target, | ||
1203 | &pr->public_data.query, | ||
1204 | pr->public_data.type, | ||
1205 | &stream_reply_proc, | ||
1206 | pr); | ||
1189 | return; | 1207 | return; |
1190 | } | 1208 | } |
1191 | if (GNUNET_YES != | 1209 | if (GNUNET_YES != |