]> granicus.if.org Git - vnstat/commitdiff
remove duplicated database transaction rollback
authorTeemu Toivola <git@humdi.net>
Mon, 12 Aug 2019 20:55:46 +0000 (23:55 +0300)
committerTeemu Toivola <git@humdi.net>
Mon, 12 Aug 2019 20:55:46 +0000 (23:55 +0300)
src/daemon.c
src/dbsql.c

index 7491f436e66273abb61691a3382fcd03a7d9a065..3f79b04e58c2e3b99ae1682de89adb0981eeb74b 100644 (file)
@@ -666,7 +666,6 @@ void flushcachetodisk(DSTATE *s)
        if (db_intransaction && !db_errcode) {
                if (!db_committransaction()) {
                        handledatabaseerror(s);
-                       db_rollbacktransaction();
                } else {
                        /* clear xferlog now that everything is in database */
                        iterator = s->dcache;
index 988d1822e5cd6e1a344ad798f6e46d04575a3184..f0681d068cb67680187cb24674d4edc1542c4950 100644 (file)
@@ -1056,6 +1056,8 @@ int db_committransaction(void)
                printf("db: commit transaction\n");
        }
 
+       db_intransaction = 0;
+
        rc = sqlite3_exec(db, "COMMIT", 0, 0, 0);
        if (rc) {
                snprintf(errorstring, 1024, "Commit transaction to database failed (%d): %s", rc, sqlite3_errmsg(db));
@@ -1065,10 +1067,8 @@ int db_committransaction(void)
                        db_rollbacktransaction();
                }
                db_errcode = rc;
-               db_intransaction = 0;
                return 0;
        }
-       db_intransaction = 0;
        return 1;
 }
 
@@ -1080,15 +1080,15 @@ int db_rollbacktransaction(void)
                printf("db: rollback transaction\n");
        }
 
+       db_intransaction = 0;
+
        rc = sqlite3_exec(db, "ROLLBACK", 0, 0, 0);
        if (rc) {
                db_errcode = rc;
                snprintf(errorstring, 1024, "Transaction rollback failed (%d): %s", rc, sqlite3_errmsg(db));
                printe(PT_Error);
-               db_intransaction = 0;
                return 0;
        }
-       db_intransaction = 0;
        return 1;
 }