1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

lws_struct: sqlite: order defaults to _lws_idx but may be overridden

The internal order that a dll2 of structs was written might or might not be
what the guy deserializing it cares about
This commit is contained in:
Andy Green 2020-03-20 19:44:10 +00:00
parent 5c657e0865
commit 54029c4896
2 changed files with 22 additions and 16 deletions

View file

@ -185,6 +185,9 @@ lws_struct_sq3_deserialize(sqlite3 *pdb, const char *filter, const char *order,
lws_struct_args_t a;
int limit = _limit < 0 ? -_limit : _limit;
if (!order)
order = "_lws_idx";
memset(&a, 0, sizeof(a));
a.cb_arg = o; /* lws_dll2_owner tracking query result objects */
a.map_st[0] = schema->child_map;
@ -199,8 +202,8 @@ lws_struct_sq3_deserialize(sqlite3 *pdb, const char *filter, const char *order,
(unsigned long long)start, filter ? filter : "");
lws_snprintf(s, sizeof(s) - 1, "select * "
"from %s %s order by _lws_idx%s %slimit %d;",
schema->colname, where, order ? order : "",
"from %s %s order by %s %slimit %d;",
schema->colname, where, order,
_limit < 0 ? "desc " : "", limit);
if (sqlite3_exec(pdb, s, lws_struct_sq3_deser_cb, &a, NULL) != SQLITE_OK) {

View file

@ -265,25 +265,28 @@ __lws_threadpool_reap(struct lws_threadpool_task *task)
/* remove the task from the done queue */
c = &tp->task_done_head;
if (tp) {
c = &tp->task_done_head;
while (*c) {
if ((*c) == task) {
t = *c;
*c = t->task_queue_next;
t->task_queue_next = NULL;
tp->done_queue_depth--;
while (*c) {
if ((*c) == task) {
t = *c;
*c = t->task_queue_next;
t->task_queue_next = NULL;
tp->done_queue_depth--;
lwsl_thread("%s: tp %s: reaped task wsi %p\n", __func__,
tp->name, task_to_wsi(task));
lwsl_thread("%s: tp %s: reaped task wsi %p\n", __func__,
tp->name, task_to_wsi(task));
break;
break;
}
c = &(*c)->task_queue_next;
}
c = &(*c)->task_queue_next;
}
if (!t)
lwsl_err("%s: task %p not in done queue\n", __func__, task);
if (!t)
lwsl_err("%s: task %p not in done queue\n", __func__, task);
} else
lwsl_err("%s: task->tp NULL already\n", __func__);
/* call the task's cleanup and delete the task itself */