#define LOG(kind,...) GNUNET_log_from (kind, "util-mq",__VA_ARGS__)
-//#if HAVE_EXECINFO_H
-//#include "execinfo.h"
-
-///**
-// * Use lsof to generate file descriptor reports on select error?
-// * (turn off for stable releases).
-// */
-//#define USE_LSOF GNUNET_NO
-
-///**
-// * Obtain trace information for all scheduler calls that schedule tasks.
-// */
-//#define EXECINFO GNUNET_NO
-
-///**
-// * Check each file descriptor before adding
-// */
-//#define DEBUG_FDS GNUNET_NO
-
-///**
-// * Depth of the traces collected via EXECINFO.
-// */
-//#define MAX_TRACE_DEPTH 50
-//#endif
struct GNUNET_MQ_Envelope
{
GNUNET_SCHEDULER_TaskCallback sent_cb;
/**
- * Closure for @e sent_cb
+ * Closure for @e send_cb
*/
void *sent_cls;
uint16_t mtype = ntohs (mh->type);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Queue %p received message of type %u and size %u\n",
- mq,
- mtype,
- msize);
+ "Received message of type %u and size %u\n",
+ mtype, msize);
if (NULL == mq->handlers)
goto done;
GNUNET_assert (NULL == mq->envelope_head);
mq->current_envelope = ev;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "mq: sending message of type %u, queue empty (MQ: %p)\n",
- ntohs(ev->mh->type),
- mq);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "sending message of type %u, queue empty (MQ: %p)\n",
+ ntohs(ev->mh->type),
+ mq);
mq->send_impl (mq,
ev->mh,
mq->envelope_tail,
mq->current_envelope);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "mq: sending message of type %u from queue\n",
- ntohs(mq->current_envelope->mh->type));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "sending message of type %u from queue\n",
+ ntohs(mq->current_envelope->mh->type));
mq->send_impl (mq,
mq->current_envelope->mh,
GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq,
void *handlers_cls)
{
- unsigned int i;
-
if (NULL == mq->handlers)
return;
- for (i=0;NULL != mq->handlers[i].cb; i++)
+ for (unsigned int i=0;NULL != mq->handlers[i].cb; i++)
mq->handlers[i].cls = handlers_cls;
}
GNUNET_SCHEDULER_TaskCallback cb,
void *cb_cls)
{
- GNUNET_assert (NULL == ev->sent_cb);
+ /* allow setting *OR* clearing callback */
+ GNUNET_assert ( (NULL == ev->sent_cb) ||
+ (NULL == cb) );
ev->sent_cb = cb;
ev->sent_cls = cb_cls;
}
ev);
GNUNET_assert (0 < mq->queue_length);
mq->queue_length--;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "MQ destroy drops message of type %u\n",
- ntohs (ev->mh->type));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "MQ destroy drops message of type %u\n",
+ ntohs (ev->mh->type));
GNUNET_MQ_discard (ev);
}
if (NULL != mq->current_envelope)
/* we can only discard envelopes that
* are not queued! */
mq->current_envelope->parent_queue = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "MQ destroy drops current message of type %u\n",
- ntohs (mq->current_envelope->mh->type));
-//#if EXECINFO
-// void *backtrace_array[MAX_TRACE_DEPTH];
-// int num_backtrace_strings = backtrace (backtrace_array, MAX_TRACE_DEPTH);
-// char **backtrace_strings =
-// backtrace_symbols (backtrace_array,
-// t->num_backtrace_strings);
-// for (unsigned int i = 0; i < num_backtrace_strings; i++)
-// LOG (GNUNET_ERROR_TYPE_DEBUG,
-// "client drop trace %u: %s\n",
-// i,
-// backtrace_strings[i]);
-//#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "MQ destroy drops current message of type %u\n",
+ ntohs (mq->current_envelope->mh->type));
GNUNET_MQ_discard (mq->current_envelope);
mq->current_envelope = NULL;
GNUNET_assert (0 < mq->queue_length);
mq->envelope_tail,
mq->current_envelope);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "mq: sending canceled message of type %u queue\n",
- ntohs(ev->mh->type));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "sending canceled message of type %u queue\n",
+ ntohs(ev->mh->type));
mq->send_impl (mq,
mq->current_envelope->mh,