Browse Source

Don't keep any json references around with stratum structures.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
d416d22381
  1. 18
      util.c

18
util.c

@ -992,10 +992,9 @@ static bool parse_stratum(struct pool *pool, char *s)
} }
out: out:
if (!ret) {
if (val) if (val)
json_decref(val); json_decref(val);
}
return ret; return ret;
} }
@ -1020,11 +1019,8 @@ bool auth_stratum(struct pool *pool)
goto out; goto out;
out: out:
if (!ret) {
if (val) if (val)
json_decref(val); json_decref(val);
} else
pool->stratum_val = val;
return ret; return ret;
} }
@ -1098,13 +1094,13 @@ bool initiate_stratum(struct pool *pool)
applog(LOG_WARNING, "Failed to get mining notify in initiate_stratum"); applog(LOG_WARNING, "Failed to get mining notify in initiate_stratum");
goto out; goto out;
} }
pool->subscription = (char *)json_string_value(json_array_get(notify_val, 1)); pool->subscription = strdup(json_string_value(json_array_get(notify_val, 1)));
if (!pool->subscription) { if (!pool->subscription) {
applog(LOG_WARNING, "Failed to get a subscription in initiate_stratum"); applog(LOG_WARNING, "Failed to get a subscription in initiate_stratum");
goto out; goto out;
} }
pool->nonce1 = (char *)json_string_value(json_array_get(res_val, 1)); pool->nonce1 = strdup(json_string_value(json_array_get(res_val, 1)));
if (!pool->nonce1) { if (!pool->nonce1) {
applog(LOG_WARNING, "Failed to get nonce1 in initiate_stratum"); applog(LOG_WARNING, "Failed to get nonce1 in initiate_stratum");
goto out; goto out;
@ -1117,18 +1113,18 @@ bool initiate_stratum(struct pool *pool)
ret = true; ret = true;
out: out:
if (!ret) {
CLOSESOCKET(pool->sock);
if (val) if (val)
json_decref(val); json_decref(val);
} else {
if (ret) {
pool->stratum_active = true; pool->stratum_active = true;
pool->stratum_val = val; pool->stratum_val = val;
if (opt_protocol) { if (opt_protocol) {
applog(LOG_DEBUG, "Pool %d confirmed mining.notify with subscription %s extranonce1 %s extranonce2 %d", applog(LOG_DEBUG, "Pool %d confirmed mining.notify with subscription %s extranonce1 %s extranonce2 %d",
pool->pool_no, pool->subscription, pool->nonce1, pool->nonce2); pool->pool_no, pool->subscription, pool->nonce1, pool->nonce2);
} }
} } else
CLOSESOCKET(pool->sock);
return ret; return ret;
} }

Loading…
Cancel
Save