summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 30985af)
raw | patch | inline | side by side (parent: 30985af)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 15 Nov 2012 12:42:29 +0000 (13:42 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 15 Nov 2012 12:42:29 +0000 (13:42 +0100) |
Don't set any next commit time after committing a transaction but only when
starting a new transaction. This way, db->next_commit == 0 always means that
we're outside of a transaction. Also, this removes the need to restart a
transaction right away. Rather, the write callback will take care of that the
next time it gets any data.
starting a new transaction. This way, db->next_commit == 0 always means that
we're outside of a transaction. Also, this removes the need to restart a
transaction right away. Rather, the write callback will take care of that the
next time it gets any data.
src/postgresql.c | patch | blob | history |
diff --git a/src/postgresql.c b/src/postgresql.c
index 9f4894ca83b0f206a5901f441ce05d44e2c3f4d4..eeb036fe27d329cf47dcd1ed54af49c6c4d1c9df 100644 (file)
--- a/src/postgresql.c
+++ b/src/postgresql.c
if (r != NULL) {
if (PGRES_COMMAND_OK == PQresultStatus (r)) {
- db->next_commit = cdtime () + db->commit_interval;
+ db->next_commit = 0;
log_debug ("Successfully committed transaction.");
status = 0;
}
/* this will abort any current transaction -> restart */
if (db->next_commit > 0)
- if (c_psql_commit (db) == 0)
- c_psql_begin (db);
+ c_psql_commit (db);
pthread_mutex_unlock (&db->db_lock);
return -1;
if ((db->next_commit > 0)
&& (cdtime () > db->next_commit))
- if (c_psql_commit (db) == 0)
- c_psql_begin (db);
+ c_psql_commit (db);
pthread_mutex_unlock (&db->db_lock);
* interval as in that case all requested data has already been
* committed */
if ((db->next_commit > 0) && (db->commit_interval > timeout))
- if (c_psql_commit (db) == 0)
- c_psql_begin (db);
+ c_psql_commit (db);
}
return 0;
} /* c_psql_flush */