diff options
Diffstat (limited to 'src/fragmentation/fragmentation_new.c')
-rw-r--r-- | src/fragmentation/fragmentation_new.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/fragmentation/fragmentation_new.c b/src/fragmentation/fragmentation_new.c index 17b4bb0ab..dbbaa859b 100644 --- a/src/fragmentation/fragmentation_new.c +++ b/src/fragmentation/fragmentation_new.c | |||
@@ -127,7 +127,7 @@ transmit_next (void *cls, | |||
127 | 127 | ||
128 | /* calculate delay */ | 128 | /* calculate delay */ |
129 | wrap = 0; | 129 | wrap = 0; |
130 | while (0 == (fc->acks & (1 << fc->next_transmission))) | 130 | while (0 == (fc->acks & (1LL << fc->next_transmission))) |
131 | { | 131 | { |
132 | fc->next_transmission = (fc->next_transmission + 1) % 64; | 132 | fc->next_transmission = (fc->next_transmission + 1) % 64; |
133 | wrap |= (fc->next_transmission == 0); | 133 | wrap |= (fc->next_transmission == 0); |
@@ -160,13 +160,12 @@ transmit_next (void *cls, | |||
160 | fh->header.type = htons (GNUNET_MESSAGE_TYPE_FRAGMENT); | 160 | fh->header.type = htons (GNUNET_MESSAGE_TYPE_FRAGMENT); |
161 | fh->fragment_id = htonl (fc->fragment_id); | 161 | fh->fragment_id = htonl (fc->fragment_id); |
162 | fh->total_size = fc->msg->size; /* already in big-endian */ | 162 | fh->total_size = fc->msg->size; /* already in big-endian */ |
163 | fh->offset = htons (fc->mtu * bit); | 163 | fh->offset = htons ((fc->mtu - sizeof (struct FragmentHeader)) * bit); |
164 | memcpy (&fc[1], | 164 | memcpy (&fh[1], |
165 | &mbuf[bit * (fc->mtu - sizeof (struct FragmentHeader))], | 165 | &mbuf[bit * (fc->mtu - sizeof (struct FragmentHeader))], |
166 | fsize - sizeof (struct FragmentHeader)); | 166 | fsize - sizeof (struct FragmentHeader)); |
167 | fc->proc (fc->proc_cls, &fh->header); | ||
168 | if (NULL != fc->tracker) | 167 | if (NULL != fc->tracker) |
169 | GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize); | 168 | GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize); |
170 | GNUNET_STATISTICS_update (fc->stats, | 169 | GNUNET_STATISTICS_update (fc->stats, |
171 | _("Fragments transmitted"), | 170 | _("Fragments transmitted"), |
172 | 1, GNUNET_NO); | 171 | 1, GNUNET_NO); |
@@ -198,6 +197,7 @@ transmit_next (void *cls, | |||
198 | fc->task = GNUNET_SCHEDULER_add_delayed (delay, | 197 | fc->task = GNUNET_SCHEDULER_add_delayed (delay, |
199 | &transmit_next, | 198 | &transmit_next, |
200 | fc); | 199 | fc); |
200 | fc->proc (fc->proc_cls, &fh->header); | ||
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
@@ -252,12 +252,12 @@ GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, | |||
252 | fc->fragment_id = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 252 | fc->fragment_id = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
253 | UINT32_MAX); | 253 | UINT32_MAX); |
254 | memcpy (&fc[1], msg, size); | 254 | memcpy (&fc[1], msg, size); |
255 | bits = (size + mtu - 1) / (mtu - sizeof (struct FragmentHeader)); | 255 | bits = (size + mtu - sizeof (struct FragmentHeader) - 1) / (mtu - sizeof (struct FragmentHeader)); |
256 | GNUNET_assert (bits <= 64); | 256 | GNUNET_assert (bits <= 64); |
257 | if (bits == 64) | 257 | if (bits == 64) |
258 | fc->acks = UINT64_MAX; /* set all 64 bit */ | 258 | fc->acks = UINT64_MAX; /* set all 64 bit */ |
259 | else | 259 | else |
260 | fc->acks = (1 << bits) - 1; /* set lowest 'bits' bit */ | 260 | fc->acks = (1LL << bits) - 1; /* set lowest 'bits' bit */ |
261 | fc->task = GNUNET_SCHEDULER_add_now (&transmit_next, | 261 | fc->task = GNUNET_SCHEDULER_add_now (&transmit_next, |
262 | fc); | 262 | fc); |
263 | return fc; | 263 | return fc; |
@@ -300,8 +300,14 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, | |||
300 | ndelay = GNUNET_TIME_absolute_get_duration (fc->last_round); | 300 | ndelay = GNUNET_TIME_absolute_get_duration (fc->last_round); |
301 | fc->delay.rel_value = (ndelay.rel_value + 3 * fc->delay.rel_value) / 4; | 301 | fc->delay.rel_value = (ndelay.rel_value + 3 * fc->delay.rel_value) / 4; |
302 | } | 302 | } |
303 | 303 | if (abits != (fc->acks & abits)) | |
304 | fc->acks &= abits; | 304 | { |
305 | /* ID collission or message reordering, count! This should be rare! */ | ||
306 | GNUNET_STATISTICS_update (fc->stats, | ||
307 | _("Bits removed from ACK"), | ||
308 | 1, GNUNET_NO); | ||
309 | } | ||
310 | fc->acks = abits; | ||
305 | if (0 != fc->acks) | 311 | if (0 != fc->acks) |
306 | { | 312 | { |
307 | /* more to transmit, do so right now (if tracker permits...) */ | 313 | /* more to transmit, do so right now (if tracker permits...) */ |