+ for(pq=NULL,q=head;q;) {
+ if(q->identifier == id) {
+ if(pq) {
+ pq->next = q->next;
+ if(q == tail)
+ tail = pq;
+ } else { /* head */
+ head = q->next;
+ if(q == tail)
+ tail = NULL;
+ }
+ sqlite3_finalize(q->statement);
+
+ q->handler(NULL, q->tag);
+ nsfree(POOL_SQLITE, q);
+
+ queuesize--;
+ if(pq) {
+ q = pq->next;
+ } else {
+ q = head;
+ }
+ } else {
+ pq = q;
+ q = q->next;
+ }
+ }
+}
+
+static void sqlitequeueprocessor(void *arg) {
+ struct sqlitequeue *q = peekqueue();
+
+ while(q) {
+ int rc = sqlite3_step(q->statement);
+ if(rc == SQLITE_BUSY)
+ return;
+
+ processstatement(rc, q->statement, q->handler, q->tag, "??");
+ popqueue();
+
+ q = peekqueue();
+ }
+}
+
+static void dbstatus(int hooknum, void *arg) {
+ if((long)arg > 10) {
+ char message[100];
+
+ snprintf(message, sizeof(message), "SQLite : %6d queries queued.", queuesize);
+ triggerhook(HOOK_CORE_STATSREPLY, message);
+ }