Various fixes

Various fixes for initialisation and packet size allocation
This commit is contained in:
MassimilianoPinto 2015-09-21 08:44:33 +02:00
parent 601eac5a5d
commit 2c12ba3d16
2 changed files with 6 additions and 5 deletions

View File

@ -334,7 +334,7 @@ BLFILE *file;
return file;
}
if ((file = (BLFILE *)malloc(sizeof(BLFILE))) == NULL)
if ((file = (BLFILE *)calloc(1, sizeof(BLFILE))) == NULL)
{
spinlock_release(&router->fileslock);
return NULL;

View File

@ -463,8 +463,9 @@ int query_len;
"%s: Expected DISCONNECT SERVER $server_id",
router->service->name)));
} else {
int serverid = atoi(word);
free(query_text);
return blr_slave_disconnect_server(router, slave, atoi(word));
return blr_slave_disconnect_server(router, slave, serverid);
}
}
}
@ -1075,7 +1076,7 @@ ROUTER_SLAVE *sptr;
sprintf(port, "%d", sptr->port);
sprintf(master_id, "%d", router->serverid);
sprintf(slave_uuid, "%s", sptr->uuid ? sptr->uuid : "");
len = 5 + strlen(server_id) + strlen(host) + strlen(port)
len = 4 + strlen(server_id) + strlen(host) + strlen(port)
+ strlen(master_id) + strlen(slave_uuid) + 5;
if ((pkt = gwbuf_alloc(len)) == NULL)
return 0;
@ -1907,7 +1908,7 @@ int len, id_len, seqno = 2;
strcpy(state, "not found");
id_len = strlen(serverid);
len = 5 + id_len + strlen(state) + 1;
len = 4 + (1 + id_len) + (1 + strlen(state));
if ((pkt = gwbuf_alloc(len)) == NULL)
return 0;
@ -1918,7 +1919,7 @@ int len, id_len, seqno = 2;
blr_slave_send_eof(router, slave, seqno++);
ptr = GWBUF_DATA(pkt);
encode_value(ptr, id_len + 2 + strlen(state), 24); // Add length of data packet
encode_value(ptr, len - 4), 24); // Add length of data packet
ptr += 3;
*ptr++ = seqno++; // Sequence number in response