diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-26 13:00:30 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-26 13:00:30 +0000 |
commit | 2095d68fba01bb7e24d6eaa102ca5e628a478dce (patch) | |
tree | 0ee0ecb860343891d4d0f207bfa4876b4529c81e | |
parent | a0401360a9b8a78e6b7976f6dd50c50573aa1a7b (diff) | |
download | gnunet-2095d68fba01bb7e24d6eaa102ca5e628a478dce.tar.gz gnunet-2095d68fba01bb7e24d6eaa102ca5e628a478dce.zip |
send multiple messages to peer if possible
-rw-r--r-- | src/dht/gnunet-service-dht.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index f96722ff7..2733fa844 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -1145,6 +1145,7 @@ core_transmit_notify (void *cls, | |||
1145 | 1145 | ||
1146 | off = 0; | 1146 | off = 0; |
1147 | pending = peer->head; | 1147 | pending = peer->head; |
1148 | #if DUMB | ||
1148 | reply_times[reply_counter] = GNUNET_TIME_absolute_get_difference(pending->scheduled, GNUNET_TIME_absolute_get()); | 1149 | reply_times[reply_counter] = GNUNET_TIME_absolute_get_difference(pending->scheduled, GNUNET_TIME_absolute_get()); |
1149 | msize = ntohs(pending->msg->size); | 1150 | msize = ntohs(pending->msg->size); |
1150 | if (msize <= size) | 1151 | if (msize <= size) |
@@ -1159,13 +1160,14 @@ core_transmit_notify (void *cls, | |||
1159 | pending); | 1160 | pending); |
1160 | GNUNET_free (pending); | 1161 | GNUNET_free (pending); |
1161 | } | 1162 | } |
1162 | #if SMART | 1163 | #else |
1163 | while (NULL != pending && | 1164 | while (NULL != pending && |
1164 | (size - off >= (msize = ntohs (pending->msg->size)))) | 1165 | (size - off >= (msize = ntohs (pending->msg->size)))) |
1165 | { | 1166 | { |
1166 | memcpy (&cbuf[off], pending->msg, msize); | 1167 | memcpy (&cbuf[off], pending->msg, msize); |
1167 | off += msize; | 1168 | off += msize; |
1168 | peer->pending_count--; | 1169 | peer->pending_count--; |
1170 | increment_stats("# pending messages sent"); | ||
1169 | GNUNET_assert(peer->pending_count >= 0); | 1171 | GNUNET_assert(peer->pending_count >= 0); |
1170 | GNUNET_CONTAINER_DLL_remove (peer->head, | 1172 | GNUNET_CONTAINER_DLL_remove (peer->head, |
1171 | peer->tail, | 1173 | peer->tail, |
@@ -1175,7 +1177,7 @@ core_transmit_notify (void *cls, | |||
1175 | } | 1177 | } |
1176 | #endif | 1178 | #endif |
1177 | if ((peer->head != NULL) && (peer->send_task == GNUNET_SCHEDULER_NO_TASK)) | 1179 | if ((peer->head != NULL) && (peer->send_task == GNUNET_SCHEDULER_NO_TASK)) |
1178 | peer->send_task = GNUNET_SCHEDULER_add_now(&try_core_send, peer); | 1180 | peer->send_task = GNUNET_SCHEDULER_add_now (&try_core_send, peer); |
1179 | 1181 | ||
1180 | return off; | 1182 | return off; |
1181 | } | 1183 | } |
@@ -1541,6 +1543,7 @@ static void delete_peer (struct PeerInfo *peer, | |||
1541 | pos = peer->head; | 1543 | pos = peer->head; |
1542 | while (pos != NULL) /* Remove any pending messages for this peer */ | 1544 | while (pos != NULL) /* Remove any pending messages for this peer */ |
1543 | { | 1545 | { |
1546 | increment_stats("# dht pending messages discarded (due to disconnect/shutdown)"); | ||
1544 | next = pos->next; | 1547 | next = pos->next; |
1545 | GNUNET_free(pos); | 1548 | GNUNET_free(pos); |
1546 | pos = next; | 1549 | pos = next; |
@@ -4430,7 +4433,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
4430 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4431 | "%s:%s Removing peer %s from bucket %d!\n", my_short_id, "DHT", GNUNET_i2s(&pos->id), bucket_count); | 4434 | "%s:%s Removing peer %s from bucket %d!\n", my_short_id, "DHT", GNUNET_i2s(&pos->id), bucket_count); |
4432 | #endif | 4435 | #endif |
4433 | delete_peer(pos, bucket_count); | 4436 | delete_peer (pos, bucket_count); |
4434 | } | 4437 | } |
4435 | } | 4438 | } |
4436 | if (coreAPI != NULL) | 4439 | if (coreAPI != NULL) |