aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_normalization.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-11-19 12:40:04 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-11-19 12:40:04 +0000
commitf2554d328813646fe2bf6771ea269578b9961622 (patch)
tree04e82cd9bb13dac95b91ed9bcaad228ae66d3dcc /src/ats/gnunet-service-ats_normalization.c
parent8dda13088674ec864e3133e8a5770e01704e8409 (diff)
downloadgnunet-f2554d328813646fe2bf6771ea269578b9961622.tar.gz
gnunet-f2554d328813646fe2bf6771ea269578b9961622.zip
- reduce debug level in proportional
- store pref client in DLL - remove disconnected clients
Diffstat (limited to 'src/ats/gnunet-service-ats_normalization.c')
-rw-r--r--src/ats/gnunet-service-ats_normalization.c54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/ats/gnunet-service-ats_normalization.c b/src/ats/gnunet-service-ats_normalization.c
index 954f2b5f5..96936332a 100644
--- a/src/ats/gnunet-service-ats_normalization.c
+++ b/src/ats/gnunet-service-ats_normalization.c
@@ -404,6 +404,7 @@ preference_aging (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
404 404
405} 405}
406 406
407
407/** 408/**
408 * Normalize an updated preference value 409 * Normalize an updated preference value
409 * 410 *
@@ -502,7 +503,7 @@ GAS_normalization_normalize_preference (void *src,
502 * default preferences if peer does not exist 503 * default preferences if peer does not exist
503 */ 504 */
504const double * 505const double *
505GAS_normalization_get_preferences (const struct GNUNET_PeerIdentity *id) 506GAS_normalization_get_preferences_by_peer (const struct GNUNET_PeerIdentity *id)
506{ 507{
507 GNUNET_assert(NULL != preference_peers); 508 GNUNET_assert(NULL != preference_peers);
508 GNUNET_assert(NULL != id); 509 GNUNET_assert(NULL != id);
@@ -809,6 +810,48 @@ GAS_normalization_normalize_property (struct GNUNET_CONTAINER_MultiPeerMap *addr
809 } 810 }
810} 811}
811 812
813
814static void
815free_client (struct PreferenceClient *pc)
816{
817 struct PreferencePeer *next_p;
818 struct PreferencePeer *p;
819 next_p = pc->p_head;
820 while (NULL != (p = next_p))
821 {
822 next_p = p->next;
823 GNUNET_CONTAINER_DLL_remove(pc->p_head, pc->p_tail, p);
824 GNUNET_free(p);
825 }
826 GNUNET_free(pc);
827}
828
829
830/**
831 * A performance client disconnected
832 *
833 * @param client the client
834 */
835
836void
837GAS_normalization_preference_client_disconnect (void *client)
838{
839 struct PreferenceClient *c_cur;
840 /* Find preference client */
841
842 for (c_cur = pc_head; NULL != c_cur; c_cur = c_cur->next)
843 {
844 if (client == c_cur->client)
845 break;
846 }
847 if (NULL == c_cur)
848 return;
849
850 GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, c_cur);
851 free_client (c_cur);
852}
853
854
812/** 855/**
813 * Start the normalization component 856 * Start the normalization component
814 * 857 *
@@ -893,14 +936,7 @@ GAS_normalization_stop ()
893 { 936 {
894 next_pc = pc->next; 937 next_pc = pc->next;
895 GNUNET_CONTAINER_DLL_remove(pc_head, pc_tail, pc); 938 GNUNET_CONTAINER_DLL_remove(pc_head, pc_tail, pc);
896 next_p = pc->p_head; 939 free_client (pc);
897 while (NULL != (p = next_p))
898 {
899 next_p = p->next;
900 GNUNET_CONTAINER_DLL_remove(pc->p_head, pc->p_tail, p);
901 GNUNET_free(p);
902 }
903 GNUNET_free(pc);
904 } 940 }
905 941
906 GNUNET_CONTAINER_multipeermap_iterate (preference_peers, &free_peer, NULL ); 942 GNUNET_CONTAINER_multipeermap_iterate (preference_peers, &free_peer, NULL );