Browse Source

Free smsg in constant place in srecv_process

master
Con Kolivas 9 years ago
parent
commit
bd70c7b276
  1. 18
      src/stratifier.c

18
src/stratifier.c

@ -6040,9 +6040,7 @@ static void srecv_process(ckpool_t *ckp, char *buf)
parse_node_msg(ckp, sdata, msg->json_msg, buf); parse_node_msg(ckp, sdata, msg->json_msg, buf);
else else
LOGWARNING("Failed to extract client_id from connector json smsg %s", buf); LOGWARNING("Failed to extract client_id from connector json smsg %s", buf);
json_decref(msg->json_msg); goto out_freemsg;
free(msg);
goto out;
} }
msg->client_id = json_integer_value(val); msg->client_id = json_integer_value(val);
@ -6051,9 +6049,7 @@ static void srecv_process(ckpool_t *ckp, char *buf)
val = json_object_get(msg->json_msg, "address"); val = json_object_get(msg->json_msg, "address");
if (unlikely(!val)) { if (unlikely(!val)) {
LOGWARNING("Failed to extract address from connector json smsg %s", buf); LOGWARNING("Failed to extract address from connector json smsg %s", buf);
json_decref(msg->json_msg); goto out_freemsg;
free(msg);
goto out;
} }
strcpy(address, json_string_value(val)); strcpy(address, json_string_value(val));
json_object_clear(val); json_object_clear(val);
@ -6061,9 +6057,7 @@ static void srecv_process(ckpool_t *ckp, char *buf)
val = json_object_get(msg->json_msg, "server"); val = json_object_get(msg->json_msg, "server");
if (unlikely(!val)) { if (unlikely(!val)) {
LOGWARNING("Failed to extract server from connector json smsg %s", buf); LOGWARNING("Failed to extract server from connector json smsg %s", buf);
json_decref(msg->json_msg); goto out_freemsg;
free(msg);
goto out;
} }
server = json_integer_value(val); server = json_integer_value(val);
json_object_clear(val); json_object_clear(val);
@ -6086,8 +6080,7 @@ static void srecv_process(ckpool_t *ckp, char *buf)
LOGNOTICE("Stratifier skipped dropped instance %"PRId64" message from server %d", LOGNOTICE("Stratifier skipped dropped instance %"PRId64" message from server %d",
msg->client_id, server); msg->client_id, server);
connector_drop_client(ckp, msg->client_id); connector_drop_client(ckp, msg->client_id);
free_smsg(msg); goto out_freemsg;
goto out;
} }
if (unlikely(noid)) if (unlikely(noid))
LOGINFO("Stratifier added instance %"PRId64" server %d", client->id, server); LOGINFO("Stratifier added instance %"PRId64" server %d", client->id, server);
@ -6098,8 +6091,9 @@ static void srecv_process(ckpool_t *ckp, char *buf)
node_client_msg(ckp, msg->json_msg, buf, client); node_client_msg(ckp, msg->json_msg, buf, client);
else else
parse_instance_msg(ckp, sdata, msg, client); parse_instance_msg(ckp, sdata, msg, client);
free_smsg(msg);
dec_instance_ref(sdata, client); dec_instance_ref(sdata, client);
out_freemsg:
free_smsg(msg);
out: out:
free(buf); free(buf);
} }

Loading…
Cancel
Save