static void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t length)
{
struct ctdb_req_header *hdr;
+
if (length < sizeof(*hdr)) {
ctdb_set_error(ctdb, "Bad packet length %d\n", length);
return;
}
/*
- called by the transport layer when a node is dead
+ called by the transport layer when a node is connected
*/
static void ctdb_node_connected(struct ctdb_node *node)
{
struct ctdb_tcp_node *tnode = talloc_get_type(node->private,
struct ctdb_tcp_node);
- /* flush the queue */
- while (tnode->queue) {
- struct ctdb_tcp_packet *pkt = tnode->queue;
- DLIST_REMOVE(tnode->queue, pkt);
- talloc_free(pkt);
- }
-
/* start a new connect cycle to try to re-establish the
link */
talloc_free(tnode->fde);
always an error, as we have separate read and write
sockets. In future we may combine them, but for now it must
mean that the socket is dead, so we try to reconnect */
+ node->ctdb->upcalls->node_dead(node);
talloc_free(tnode->fde);
close(tnode->fd);
tnode->fd = -1;
in->ctdb->upcalls->recv_pkt(in->ctdb, d2, len);
data += len;
nread -= len;
- return;
}
- if (nread < 4 || *(uint32_t *)data > nread) {
+ if (nread > 0) {
/* we have only part of a packet */
if (data_base == data) {
in->partial.data = data;