From 3f39b56dbf230d7c10b6d21993ca4f142953dec9 Mon Sep 17 00:00:00 2001
From: "Stephen R. van den Berg" <srb@cuci.nl>
Date: Sat, 1 Jul 2017 23:02:21 +0200
Subject: [PATCH] pgsql: Stashflushmode is now managed consistently.

---
 lib/modules/Sql.pmod/pgsql_util.pmod | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/lib/modules/Sql.pmod/pgsql_util.pmod b/lib/modules/Sql.pmod/pgsql_util.pmod
index 7c33a8272d..82ef4f6907 100644
--- a/lib/modules/Sql.pmod/pgsql_util.pmod
+++ b/lib/modules/Sql.pmod/pgsql_util.pmod
@@ -152,12 +152,6 @@ final int oidformat(int oid) {
   return 0;	// text
 }
 
-private int mergemode(conxion realbuffer,int mode) {
-  if(mode>realbuffer->stashflushmode)
-    realbuffer->stashflushmode=mode;
-  return realbuffer->stashflushmode;
-}
-
 private inline mixed callout(function(mixed ...:void) f,
  float|int delay,mixed ... args) {
   return local_backend->call_out(f,delay,@args);
@@ -204,7 +198,10 @@ class bufcon {
       }
     }
     realbuffer->stash->add(this);
-    mergemode(realbuffer, mode);
+    PD("%d>Got stash mode %d > %d\n",
+     realbuffer->socket->query_fd(), mode, realbuffer->stashflushmode);
+    if (mode > realbuffer->stashflushmode)
+      realbuffer->stashflushmode = mode;
     if(!--realbuffer->stashcount)
       realbuffer->stashavail.signal();
     lock=0;
@@ -349,7 +346,10 @@ class conxion {
           qportals->write(synctransact++);
         else
           queueup(portal);
-      mode = mergemode(this, mode);
+      PD("%d>Got stash mode %d > %d\n",
+       socket->query_fd(), stashflushmode, mode);
+      if (stashflushmode > mode)
+        mode = stashflushmode;
       stashflushmode = KEEP;
     }
     return mode;
@@ -391,7 +391,6 @@ outer:
           case FLUSHSEND:
             PD("Flush\n");
             add(PGFLUSH);
-          case SYNCSEND:
           case SENDOUT:;
         }
         if(towrite=sizeof(this)) {
-- 
GitLab