Browse Source

Free messages sent to stratifier in passthrough mode, fixing memory leak

master
Con Kolivas 9 years ago
parent
commit
658af3faec
  1. 13
      src/stratifier.c

13
src/stratifier.c

@ -5448,7 +5448,7 @@ static void parse_instance_msg(ckpool_t *ckp, sdata_t *sdata, smsg_t *msg, strat
LOGINFO("Dropping client %"PRId64" %s tagged for lazy invalidation", LOGINFO("Dropping client %"PRId64" %s tagged for lazy invalidation",
client_id, client->address); client_id, client->address);
connector_drop_client(ckp, client_id); connector_drop_client(ckp, client_id);
goto out; return;
} }
/* Return back the same id_val even if it's null or not existent. */ /* Return back the same id_val even if it's null or not existent. */
@ -5467,19 +5467,19 @@ static void parse_instance_msg(ckpool_t *ckp, sdata_t *sdata, smsg_t *msg, strat
else else
LOGDEBUG("Received spurious response %s from client %"PRId64, LOGDEBUG("Received spurious response %s from client %"PRId64,
result ? result : "", client_id); result ? result : "", client_id);
goto out; return;
} }
send_json_err(sdata, client_id, id_val, "-3:method not found"); send_json_err(sdata, client_id, id_val, "-3:method not found");
goto out; return;
} }
if (unlikely(!json_is_string(method))) { if (unlikely(!json_is_string(method))) {
send_json_err(sdata, client_id, id_val, "-1:method is not string"); send_json_err(sdata, client_id, id_val, "-1:method is not string");
goto out; return;
} }
params = json_object_get(val, "params"); params = json_object_get(val, "params");
if (unlikely(!params)) { if (unlikely(!params)) {
send_json_err(sdata, client_id, id_val, "-1:params not found"); send_json_err(sdata, client_id, id_val, "-1:params not found");
goto out; return;
} }
/* At startup we block until there's a current workbase otherwise we /* At startup we block until there's a current workbase otherwise we
* will reject miners with the initialising message. A slightly delayed * will reject miners with the initialising message. A slightly delayed
@ -5490,8 +5490,6 @@ static void parse_instance_msg(ckpool_t *ckp, sdata_t *sdata, smsg_t *msg, strat
LOGWARNING("%d Second delay waiting for bitcoind at startup", delays / 10); LOGWARNING("%d Second delay waiting for bitcoind at startup", delays / 10);
} }
parse_method(ckp, sdata, client, client_id, id_val, method, params); parse_method(ckp, sdata, client, client_id, id_val, method, params);
out:
free_smsg(msg);
} }
static void srecv_process(ckpool_t *ckp, char *buf) static void srecv_process(ckpool_t *ckp, char *buf)
@ -5573,6 +5571,7 @@ 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: out:
free(buf); free(buf);

Loading…
Cancel
Save