/*
This file is part of GNUnet.
- Copyright (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009, 2010, 2011 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
{
unsigned int i;
- if (c->tcnt == 0)
- return GNUNET_YES; /* peer without handlers matches ALL */
+ if (c->tcnt == 0 && c->options != 0)
+ return GNUNET_YES; /* peer without handlers and inbound/outbond
+ callbacks matches ALL */
for (i = 0; i < c->tcnt; i++)
if (type == c->types[i])
return GNUNET_YES;
{
/* dequeue and recycle memory from pending request, there can only
be at most one per client and peer */
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop
+ ("# dequeuing CAR (duplicate request)"), 1,
+ GNUNET_NO);
GSC_SESSIONS_dequeue_request (car);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmission request to `%s' was a duplicate!\n",
+ GNUNET_i2s (&req->peer));
}
car->target = req->peer;
car->received_time = GNUNET_TIME_absolute_get ();
/**
- * Handle #GNUNET_MESSAGE_TYPE_CORE_CORE_SEND request.
+ * Handle #GNUNET_MESSAGE_TYPE_CORE_SEND request.
*
* @param cls unused
* @param client the client issuing the request
struct TokenizerContext tc;
uint16_t msize;
struct GNUNET_TIME_Relative delay;
+ struct GNUNET_TIME_Relative overdue;
msize = ntohs (message->size);
- if (msize <
- sizeof (struct SendMessage) + sizeof (struct GNUNET_MessageHeader))
+ if (msize < sizeof (struct SendMessage))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
delay = GNUNET_TIME_absolute_get_duration (tc.car->received_time);
+ overdue = GNUNET_TIME_absolute_get_duration (tc.car->deadline);
tc.cork = ntohl (sm->cork);
tc.priority = (enum GNUNET_CORE_Priority) ntohl (sm->priority);
- if (delay.rel_value_us > GNUNET_TIME_UNIT_SECONDS.rel_value_us)
+ if (overdue.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Client waited %s for transmission of %u bytes to `%s'%s, CORE queue is %u entries\n",
+ "Client waited %s for transmission of %u bytes to `%s'%s\n",
GNUNET_STRINGS_relative_time_to_string (delay,
GNUNET_YES),
msize,
GNUNET_i2s (&sm->peer),
- tc.cork ? "" : " (corked)",
- GSC_NEIGHBOURS_get_queue_size (&sm->peer));
+ tc.cork ? "" : " (corked)");
else
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client waited %s for transmission of %u bytes to `%s'%s, CORE queue is %u entries\n",
+ "Client waited %s for transmission of %u bytes to `%s'%s\n",
GNUNET_STRINGS_relative_time_to_string (delay,
GNUNET_YES),
msize,
GNUNET_i2s (&sm->peer),
- tc.cork ? "" : " (corked)",
- GSC_NEIGHBOURS_get_queue_size (&sm->peer));
+ tc.cork ? "" : " (corked)");
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_remove (c->requests,
msize,
GNUNET_YES,
GNUNET_NO);
- if (0 !=
- memcmp (&tc.car->target,
- &GSC_my_identity,
- sizeof (struct GNUNET_PeerIdentity)))
- GSC_SESSIONS_dequeue_request (tc.car);
+ GSC_SESSIONS_dequeue_request (tc.car);
GNUNET_free (tc.car);
GNUNET_SERVER_receive_done (client,
GNUNET_OK);
&GSC_my_identity,
sizeof (struct GNUNET_PeerIdentity)));
GSC_SESSIONS_dequeue_request (car);
- GSC_CLIENTS_reject_request (car);
+ GSC_CLIENTS_reject_request (car,
+ GNUNET_NO);
return;
}
delay = GNUNET_TIME_absolute_get_duration (car->received_time);
- left = GNUNET_TIME_absolute_get_remaining (car->deadline);
- if ( (delay.rel_value_us > GNUNET_TIME_UNIT_SECONDS.rel_value_us) ||
- (0 == left.rel_value_us) )
+ left = GNUNET_TIME_absolute_get_duration (car->deadline);
+ if (left.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Client waited %s for permission to transmit to `%s'%s (priority %u)\n",
GNUNET_STRINGS_relative_time_to_string (delay,
/**
- * Tell a client that we will never be ready to receive the
- * given message in time (disconnect or timeout).
+ * We will never be ready to transmit the given message in (disconnect
+ * or invalid request). Frees resources associated with @a car. We
+ * don't explicitly tell the client, he'll learn with the disconnect
+ * (or violated the protocol).
*
* @param car request that now permanently failed; the
* responsibility for the handle is now returned
* to CLIENTS (SESSIONS is done with it).
+ * @param drop_client #GNUNET_YES if the client violated the protocol
+ * and we should thus drop the connection
*/
void
-GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car)
+GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car,
+ int drop_client)
{
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_remove (car->
client_handle->requests,
&car->target,
car));
+ if (GNUNET_YES == drop_client)
+ GNUNET_SERVER_client_disconnect (car->client_handle->client_handle);
GNUNET_free (car);
}
(0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) ))
return; /* no client cares about this message notification */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core service passes message from `%4s' of type %u to client.\n",
+ "Core service passes message from `%s' of type %u to client.\n",
GNUNET_i2s (sender),
(unsigned int) ntohs (msg->type));
GSC_SESSIONS_add_to_typemap (sender, ntohs (msg->type));