Browse Source

ckdb - blocks_add fix early abort before db I/O

master
kanoi 11 years ago
parent
commit
6f9f4527eb
  1. 8
      src/ckdb.c

8
src/ckdb.c

@ -2796,13 +2796,13 @@ static bool blocks_add(PGconn *conn, char *height, char *blockhash,
tv_t *now, char *by, char *code, char *inet) tv_t *now, char *by, char *code, char *inet)
{ {
ExecStatusType rescode; ExecStatusType rescode;
PGresult *res; PGresult *res = NULL;
K_ITEM *item, *u_item; K_ITEM *item, *u_item;
BLOCKS *row; BLOCKS *row;
char *upd, *ins; char *upd, *ins;
char *params[11 + HISTORYDATECOUNT]; char *params[11 + HISTORYDATECOUNT];
bool ok = false; bool ok = false;
int par; int par = 0;
int n; int n;
LOGDEBUG("%s(): add", __func__); LOGDEBUG("%s(): add", __func__);
@ -2823,7 +2823,7 @@ static bool blocks_add(PGconn *conn, char *height, char *blockhash,
case BLOCKS_NEW: case BLOCKS_NEW:
u_item = find_users(username); u_item = find_users(username);
if (!u_item) if (!u_item)
goto unparam; goto early;
TXT_TO_BIGINT("workinfoid", workinfoid, row->workinfoid); TXT_TO_BIGINT("workinfoid", workinfoid, row->workinfoid);
STRNCPY(row->workername, workername); STRNCPY(row->workername, workername);
@ -2919,7 +2919,7 @@ unparam:
PQclear(res); PQclear(res);
for (n = 0; n < par; n++) for (n = 0; n < par; n++)
free(params[n]); free(params[n]);
early:
K_WLOCK(blocks_list); K_WLOCK(blocks_list);
if (!ok) if (!ok)
k_add_head(blocks_list, item); k_add_head(blocks_list, item);

Loading…
Cancel
Save