*/
struct GNUNET_MESH_queue *queue_head;
struct GNUNET_MESH_queue *queue_tail;
+
+ /**
+ * Have we started the task to receive messages from the service
+ * yet? We do this after we send the 'MESH_LOCAL_CONNECT' message.
+ */
+ int in_receive;
};
/**
}
}
}
- return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: received a message from MESH\n");
if (msg == NULL)
{
- GNUNET_break_op (0);
+ GNUNET_break (0);
+ h->in_receive = GNUNET_NO;
+ // rather: do_reconnect () -- and set 'in_receive' to NO there...
+ // FIXME: service disconnect, handle!
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: message processed\n");
GNUNET_CLIENT_receive (h->client, &msg_received, h,
GNUNET_TIME_UNIT_FOREVER_REL);
- return;
}
if (0 == size || NULL == buf)
{
// FIXME: disconnect, reconnect, retry?
+ // do_reconnect ();
return 0;
}
q = h->queue_head;
GNUNET_YES, &send_raw, h);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: Send packet() END\n");
-
+ if (GNUNET_NO == h->in_receive)
+ {
+ h->in_receive = GNUNET_YES;
+ GNUNET_CLIENT_receive (h->client, &msg_received, h,
+ GNUNET_TIME_UNIT_FOREVER_REL);
+ }
return size;
}
q->size = size;
q->data = data;
GNUNET_CONTAINER_DLL_insert_tail (h->queue_head, h->queue_tail, q);
- if (NULL == h->th)
- {
- h->th =
- GNUNET_CLIENT_notify_transmit_ready (h->client, size,
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_YES, &send_raw, h);
- }
+ if (NULL != h->th)
+ return;
+ h->th =
+ GNUNET_CLIENT_notify_transmit_ready (h->client, size,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_YES, &send_raw, h);
}
/******************************************************************************/
send_packet (h, size, msg);
- GNUNET_CLIENT_receive (h->client, &msg_received, h,
- GNUNET_TIME_UNIT_FOREVER_REL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: GNUNET_MESH_connect() END\n");