|
|
@ -91,6 +91,8 @@ static void invalidate_client(client_instance_t *client) |
|
|
|
client->fd = -1; |
|
|
|
client->fd = -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void send_client(conn_instance_t *ci, int id, const char *buf); |
|
|
|
|
|
|
|
|
|
|
|
static void parse_client_msg(conn_instance_t *ci, client_instance_t *client) |
|
|
|
static void parse_client_msg(conn_instance_t *ci, client_instance_t *client) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ckpool_t *ckp = ci->pi->ckp; |
|
|
|
ckpool_t *ckp = ci->pi->ckp; |
|
|
@ -144,9 +146,12 @@ reparse: |
|
|
|
client->bufofs -= buflen; |
|
|
|
client->bufofs -= buflen; |
|
|
|
memmove(client->buf, client->buf + buflen, client->bufofs); |
|
|
|
memmove(client->buf, client->buf + buflen, client->bufofs); |
|
|
|
val = json_loads(msg, 0, NULL); |
|
|
|
val = json_loads(msg, 0, NULL); |
|
|
|
if (!val) |
|
|
|
if (!val) { |
|
|
|
LOGWARNING("Client fd %d sent invalid json message %s", client->fd, msg); |
|
|
|
LOGINFO("Client id %d sent invalid json message %s", client->id, msg); |
|
|
|
else { |
|
|
|
send_client(ci, client->id, "Invalid JSON, disconnecting\n"); |
|
|
|
|
|
|
|
invalidate_client(client); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} else { |
|
|
|
char *s; |
|
|
|
char *s; |
|
|
|
|
|
|
|
|
|
|
|
json_object_set_new_nocheck(val, "client_id", json_integer(client->id)); |
|
|
|
json_object_set_new_nocheck(val, "client_id", json_integer(client->id)); |
|
|
|