diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-07-11 14:44:03 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-07-11 14:44:03 +0000 |
commit | 73e51ecfd8c30f6b7f103ebd60dfc800ab5d6717 (patch) | |
tree | 63db9f1dd5afb3943f19be71f3ee8a83b37e7a4a /src/ats | |
parent | 471b156c8bbd7d9f9ba2aae6637d6354a39a9153 (diff) | |
download | gnunet-73e51ecfd8c30f6b7f103ebd60dfc800ab5d6717.tar.gz gnunet-73e51ecfd8c30f6b7f103ebd60dfc800ab5d6717.zip |
new function to check if session is known to ats
required for two reasons:
we cannot update metrics for validation sessions since these are not known to ats
a remote peer can decide to use an inbound validation session to transmit data, so we have to add the session to ats if we receive payload on a session
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/ats_api_scheduling.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 410d4880b..8a9791811 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -1134,6 +1134,32 @@ GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SchedulingHandle *sh, | |||
1134 | 1134 | ||
1135 | 1135 | ||
1136 | /** | 1136 | /** |
1137 | * Test if a address and a session is known to ATS | ||
1138 | * | ||
1139 | * @param sh the scheduling handle | ||
1140 | * @param address the address | ||
1141 | * @param session the session | ||
1142 | * @return GNUNET_YES or GNUNET_NO | ||
1143 | */ | ||
1144 | int | ||
1145 | GNUNET_ATS_session_known (struct GNUNET_ATS_SchedulingHandle *sh, | ||
1146 | const struct GNUNET_HELLO_Address *address, | ||
1147 | struct Session *session) | ||
1148 | { | ||
1149 | int s; | ||
1150 | if (NULL != session) | ||
1151 | { | ||
1152 | if (NOT_FOUND != (s = find_session_id (sh, session, &address->peer))) | ||
1153 | { | ||
1154 | /* Existing */ | ||
1155 | return GNUNET_YES; | ||
1156 | } | ||
1157 | return GNUNET_NO; | ||
1158 | } | ||
1159 | return GNUNET_NO; | ||
1160 | } | ||
1161 | |||
1162 | /** | ||
1137 | * We have a new address ATS should know. Addresses have to be added with this | 1163 | * We have a new address ATS should know. Addresses have to be added with this |
1138 | * function before they can be: updated, set in use and destroyed | 1164 | * function before they can be: updated, set in use and destroyed |
1139 | * | 1165 | * |
@@ -1184,14 +1210,9 @@ GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh, | |||
1184 | 1210 | ||
1185 | if (NULL != session) | 1211 | if (NULL != session) |
1186 | { | 1212 | { |
1187 | s = find_session_id (sh, session, &address->peer); | 1213 | if (NOT_FOUND != (s = find_session_id (sh, session, &address->peer))) |
1188 | if (NOT_FOUND != s) | ||
1189 | { | 1214 | { |
1190 | /* Already existing, nothing todo */ | 1215 | /* Already existing, nothing todo */ |
1191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1192 | "Adding duplicate address for peer `%s', plugin `%s', session %p id %u\n", | ||
1193 | GNUNET_i2s (&address->peer), | ||
1194 | address->transport_name, session, s); | ||
1195 | return GNUNET_SYSERR; | 1216 | return GNUNET_SYSERR; |
1196 | } | 1217 | } |
1197 | s = find_empty_session_slot (sh, session, &address->peer); | 1218 | s = find_empty_session_slot (sh, session, &address->peer); |