Minor code refactoring

This commit is contained in:
topjohnwu
2021-01-12 00:07:48 -08:00
parent 79dfdb29e7
commit d2acd59ea8
12 changed files with 100 additions and 135 deletions

View File

@@ -369,8 +369,8 @@ bool validate_manager(string &pkg, int userid, struct stat *st) {
void exec_sql(int client) {
run_finally f([=]{ close(client); });
char *sql = read_string(client);
char *err = db_exec(sql, [&](db_row &row) -> bool {
string sql = read_string(client);
char *err = db_exec(sql.data(), [client](db_row &row) -> bool {
string out;
bool first = true;
for (auto it : row) {
@@ -380,11 +380,9 @@ void exec_sql(int client) {
out += '=';
out += it.second;
}
write_int(client, out.length());
xwrite(client, out.data(), out.length());
write_string(client, out);
return true;
});
free(sql);
write_int(client, 0);
db_err_cmd(err, return; );
}