|
|
@ -3872,8 +3872,6 @@ static char *cmd_setatts(PGconn *conn, char *cmd, char *id, |
|
|
|
__maybe_unused tv_t *notcd, K_TREE *trf_root, |
|
|
|
__maybe_unused tv_t *notcd, K_TREE *trf_root, |
|
|
|
__maybe_unused bool reload_data) |
|
|
|
__maybe_unused bool reload_data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ExecStatusType rescode; |
|
|
|
|
|
|
|
PGresult *res; |
|
|
|
|
|
|
|
bool conned = false; |
|
|
|
bool conned = false; |
|
|
|
K_ITEM *t_item, *u_item, *ua_item = NULL; |
|
|
|
K_ITEM *t_item, *u_item, *ua_item = NULL; |
|
|
|
INTRANSIENT *in_username; |
|
|
|
INTRANSIENT *in_username; |
|
|
@ -3921,21 +3919,13 @@ static char *cmd_setatts(PGconn *conn, char *cmd, char *id, |
|
|
|
*(dot++) = '\0'; |
|
|
|
*(dot++) = '\0'; |
|
|
|
// If we already had a different one, save it to the DB
|
|
|
|
// If we already had a different one, save it to the DB
|
|
|
|
if (ua_item && strcmp(useratts->attname, attname) != 0) { |
|
|
|
if (ua_item && strcmp(useratts->attname, attname) != 0) { |
|
|
|
if (conn == NULL) { |
|
|
|
conned = CKPQConn(&conn); |
|
|
|
conn = dbconnect(); |
|
|
|
|
|
|
|
conned = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!begun) { |
|
|
|
if (!begun) { |
|
|
|
// Beginning of a write txn
|
|
|
|
begun = CKPQBegin(conn); |
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
if (!begun) { |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
if (!PGOK(rescode)) { |
|
|
|
|
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
|
|
|
|
reason = "DBERR"; |
|
|
|
reason = "DBERR"; |
|
|
|
goto bats; |
|
|
|
goto bats; |
|
|
|
} |
|
|
|
} |
|
|
|
begun = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (useratts_item_add(conn, ua_item, now, begun)) { |
|
|
|
if (useratts_item_add(conn, ua_item, now, begun)) { |
|
|
|
ua_item = NULL; |
|
|
|
ua_item = NULL; |
|
|
@ -3983,21 +3973,13 @@ static char *cmd_setatts(PGconn *conn, char *cmd, char *id, |
|
|
|
t_item = next_in_ktree(ctx); |
|
|
|
t_item = next_in_ktree(ctx); |
|
|
|
} |
|
|
|
} |
|
|
|
if (ua_item) { |
|
|
|
if (ua_item) { |
|
|
|
if (conn == NULL) { |
|
|
|
conned = CKPQConn(&conn); |
|
|
|
conn = dbconnect(); |
|
|
|
|
|
|
|
conned = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!begun) { |
|
|
|
if (!begun) { |
|
|
|
// Beginning of a write txn
|
|
|
|
begun = CKPQBegin(conn); |
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
if (!begun) { |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
if (!PGOK(rescode)) { |
|
|
|
|
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
|
|
|
|
reason = "DBERR"; |
|
|
|
reason = "DBERR"; |
|
|
|
goto bats; |
|
|
|
goto bats; |
|
|
|
} |
|
|
|
} |
|
|
|
begun = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (!useratts_item_add(conn, ua_item, now, begun)) { |
|
|
|
if (!useratts_item_add(conn, ua_item, now, begun)) { |
|
|
|
reason = "DBERR"; |
|
|
|
reason = "DBERR"; |
|
|
@ -4007,15 +3989,11 @@ static char *cmd_setatts(PGconn *conn, char *cmd, char *id, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
rollback: |
|
|
|
rollback: |
|
|
|
if (!reason) |
|
|
|
|
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
CKPQEnd(conn, (reason == NULL)); |
|
|
|
|
|
|
|
|
|
|
|
bats: |
|
|
|
bats: |
|
|
|
if (conned) |
|
|
|
conned = CKPQDisco(&conn, conned); |
|
|
|
PQfinish(conn); |
|
|
|
|
|
|
|
if (reason) { |
|
|
|
if (reason) { |
|
|
|
if (ua_item) { |
|
|
|
if (ua_item) { |
|
|
|
K_WLOCK(useratts_free); |
|
|
|
K_WLOCK(useratts_free); |
|
|
@ -4207,8 +4185,6 @@ static char *cmd_setopts(PGconn *conn, char *cmd, char *id, |
|
|
|
__maybe_unused tv_t *notcd, K_TREE *trf_root, |
|
|
|
__maybe_unused tv_t *notcd, K_TREE *trf_root, |
|
|
|
__maybe_unused bool reload_data) |
|
|
|
__maybe_unused bool reload_data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ExecStatusType rescode; |
|
|
|
|
|
|
|
PGresult *res; |
|
|
|
|
|
|
|
bool conned = false; |
|
|
|
bool conned = false; |
|
|
|
K_ITEM *t_item, *oc_item = NULL, *ok = NULL; |
|
|
|
K_ITEM *t_item, *oc_item = NULL, *ok = NULL; |
|
|
|
K_TREE_CTX ctx[1]; |
|
|
|
K_TREE_CTX ctx[1]; |
|
|
@ -4242,21 +4218,13 @@ static char *cmd_setopts(PGconn *conn, char *cmd, char *id, |
|
|
|
reason = "Missing value"; |
|
|
|
reason = "Missing value"; |
|
|
|
goto rollback; |
|
|
|
goto rollback; |
|
|
|
} |
|
|
|
} |
|
|
|
if (conn == NULL) { |
|
|
|
conned = CKPQConn(&conn); |
|
|
|
conn = dbconnect(); |
|
|
|
|
|
|
|
conned = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!begun) { |
|
|
|
if (!begun) { |
|
|
|
// Beginning of a write txn
|
|
|
|
begun = CKPQBegin(conn); |
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
if (!begun) { |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
if (!PGOK(rescode)) { |
|
|
|
|
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
|
|
|
|
reason = "DBERR"; |
|
|
|
reason = "DBERR"; |
|
|
|
goto rollback; |
|
|
|
goto rollback; |
|
|
|
} |
|
|
|
} |
|
|
|
begun = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
ok = optioncontrol_item_add(conn, oc_item, now, begun); |
|
|
|
ok = optioncontrol_item_add(conn, oc_item, now, begun); |
|
|
|
oc_item = NULL; |
|
|
|
oc_item = NULL; |
|
|
@ -4299,21 +4267,13 @@ static char *cmd_setopts(PGconn *conn, char *cmd, char *id, |
|
|
|
reason = "Missing value"; |
|
|
|
reason = "Missing value"; |
|
|
|
goto rollback; |
|
|
|
goto rollback; |
|
|
|
} |
|
|
|
} |
|
|
|
if (conn == NULL) { |
|
|
|
conned = CKPQConn(&conn); |
|
|
|
conn = dbconnect(); |
|
|
|
|
|
|
|
conned = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!begun) { |
|
|
|
if (!begun) { |
|
|
|
// Beginning of a write txn
|
|
|
|
begun = CKPQBegin(conn); |
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
if (!begun) { |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
if (!PGOK(rescode)) { |
|
|
|
|
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
|
|
|
|
reason = "DBERR"; |
|
|
|
reason = "DBERR"; |
|
|
|
goto rollback; |
|
|
|
goto rollback; |
|
|
|
} |
|
|
|
} |
|
|
|
begun = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
ok = optioncontrol_item_add(conn, oc_item, now, begun); |
|
|
|
ok = optioncontrol_item_add(conn, oc_item, now, begun); |
|
|
|
oc_item = NULL; |
|
|
|
oc_item = NULL; |
|
|
@ -4325,17 +4285,10 @@ static char *cmd_setopts(PGconn *conn, char *cmd, char *id, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
rollback: |
|
|
|
rollback: |
|
|
|
if (begun) { |
|
|
|
if (begun) |
|
|
|
if (reason) |
|
|
|
CKPQEnd(conn, (reason == NULL)); |
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
conned = CKPQDisco(&conn, conned); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (conned) |
|
|
|
|
|
|
|
PQfinish(conn); |
|
|
|
|
|
|
|
if (reason) { |
|
|
|
if (reason) { |
|
|
|
snprintf(reply, siz, "ERR.%s", reason); |
|
|
|
snprintf(reply, siz, "ERR.%s", reason); |
|
|
|
LOGERR("%s.%s.%s", cmd, id, reply); |
|
|
|
LOGERR("%s.%s.%s", cmd, id, reply); |
|
|
@ -8386,10 +8339,7 @@ static char *cmd_high(PGconn *conn, char *cmd, char *id, |
|
|
|
if (strcasecmp(action, "store") == 0) { |
|
|
|
if (strcasecmp(action, "store") == 0) { |
|
|
|
/* Store the shares_hi_root list in the db now,
|
|
|
|
/* Store the shares_hi_root list in the db now,
|
|
|
|
* rather than wait for a shift process to do it */ |
|
|
|
* rather than wait for a shift process to do it */ |
|
|
|
if (!conn) { |
|
|
|
conned = CKPQConn(&conn); |
|
|
|
conn = dbconnect(); |
|
|
|
|
|
|
|
conned = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
count = 0; |
|
|
|
count = 0; |
|
|
|
do { |
|
|
|
do { |
|
|
|
did = false; |
|
|
|
did = false; |
|
|
@ -8404,8 +8354,7 @@ static char *cmd_high(PGconn *conn, char *cmd, char *id, |
|
|
|
count++; |
|
|
|
count++; |
|
|
|
} |
|
|
|
} |
|
|
|
} while (did); |
|
|
|
} while (did); |
|
|
|
if (conned) |
|
|
|
conned = CKPQDisco(&conn, conned); |
|
|
|
PQfinish(conn); |
|
|
|
|
|
|
|
if (count) { |
|
|
|
if (count) { |
|
|
|
LOGWARNING("%s() Stored: %d high shares", |
|
|
|
LOGWARNING("%s() Stored: %d high shares", |
|
|
|
__func__, count); |
|
|
|
__func__, count); |
|
|
|