#include "gnunet_ats_service.h"
#include "ats.h"
+#define DEBUG_ATS GNUNET_EXTRA_LOGGING
/**
* Message in linked list we should send to the ATS service. The
find_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
const struct GNUNET_PeerIdentity *peer)
{
+#if DEBUG_ATS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Find session %u from peer %s in %p\n",
+ (unsigned int) session_id,
+ GNUNET_i2s (peer),
+ sh);
+#endif
if (session_id >= sh->session_array_size)
{
GNUNET_break (0);
}
if (0 == session_id)
return NULL;
- /* Check if this session was:
- * removed by remove_session (transport service)
- * released by release_session (ATS)
- * */
if (sh->session_array[session_id].session == NULL)
+ {
+ GNUNET_break (0 ==
+ memcmp (peer, &sh->session_array[session_id].peer,
+ sizeof (struct GNUNET_PeerIdentity)));
return NULL;
+ }
+ if (0 !=
+ memcmp (peer, &sh->session_array[session_id].peer,
+ sizeof (struct GNUNET_PeerIdentity)))
+ {
+ GNUNET_break (0);
+ sh->reconnect = GNUNET_YES;
+ return NULL;
+ }
return sh->session_array[session_id].session;
}
unsigned int i;
unsigned int f;
+#if DEBUG_ATS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Get session ID for session %p from peer %s in %p\n",
+ session,
+ GNUNET_i2s (peer),
+ sh);
+#endif
if (NULL == session)
return 0;
f = 0;
{
if (session == sh->session_array[i].session)
{
- if (0 != memcmp (peer, &sh->session_array[i].peer,
- sizeof (struct GNUNET_PeerIdentity)))
- continue;
- else
- return i;
+ GNUNET_assert (0 == memcmp (peer, &sh->session_array[i].peer,
+ sizeof (struct GNUNET_PeerIdentity)));
+ return i;
}
if ((f == 0) && (sh->session_array[i].slot_used == GNUNET_NO))
f = i;
sh->session_array[f].session = session;
sh->session_array[f].peer = *peer;
sh->session_array[f].slot_used = GNUNET_YES;
+#if DEBUG_ATS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Assigning session ID %u for session %p of peer %s in %p\n",
+ f,
+ session,
+ GNUNET_i2s (peer),
+ sh);
+#endif
return f;
}
remove_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
const struct GNUNET_PeerIdentity *peer)
{
+#if DEBUG_ATS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Remove sessionID %u from peer %s in %p\n",
+ (unsigned int) session_id,
+ GNUNET_i2s (peer),
+ sh);
+#endif
if (0 == session_id)
return;
GNUNET_assert (session_id < sh->session_array_size);
release_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
const struct GNUNET_PeerIdentity *peer)
{
+#if DEBUG_ATS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Release sessionID %u from peer %s in %p\n",
+ (unsigned int) session_id,
+ GNUNET_i2s (peer),
+ sh);
+#endif
if (session_id >= sh->session_array_size)
{
GNUNET_break (0);
uint16_t plugin_name_length;
uint32_t ats_count;
struct GNUNET_HELLO_Address address;
+ struct Session * s;
if (NULL == msg)
{
}
uint32_t session_id = ntohl (m->session_id);
- struct Session * s = NULL;
if (session_id == 0)
s = NULL;
else
s = find_session (sh, session_id, &m->peer);
if (s == NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS tries to use outdated session `%s'\n", GNUNET_i2s(&m->peer));
- //GNUNET_break (0);
+#if DEBUG_ATS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "ATS tries to use outdated session `%s'\n",
+ GNUNET_i2s(&m->peer));
+#endif
return;
}
}
return;
}
-
p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
p->size = msize;
p->is_init = GNUNET_NO;