Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/share/examples/puffs/pgfs setlabel: save SQL statements by c...



details:   https://anonhg.NetBSD.org/src/rev/da163d86763f
branches:  trunk
changeset: 778737:da163d86763f
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Apr 11 14:27:43 2012 +0000

description:
setlabel: save SQL statements by caching the last label

diffstat:

 share/examples/puffs/pgfs/pgfs_db.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (63 lines):

diff -r bc7372fc2751 -r da163d86763f share/examples/puffs/pgfs/pgfs_db.c
--- a/share/examples/puffs/pgfs/pgfs_db.c       Wed Apr 11 14:27:15 2012 +0000
+++ b/share/examples/puffs/pgfs/pgfs_db.c       Wed Apr 11 14:27:43 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pgfs_db.c,v 1.2 2012/04/11 14:26:44 yamt Exp $ */
+/*     $NetBSD: pgfs_db.c,v 1.3 2012/04/11 14:27:43 yamt Exp $ */
 
 /*-
  * Copyright (c)2010,2011 YAMAMOTO Takashi,
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: pgfs_db.c,v 1.2 2012/04/11 14:26:44 yamt Exp $");
+__RCSID("$NetBSD: pgfs_db.c,v 1.3 2012/04/11 14:27:43 yamt Exp $");
 #endif /* not lint */
 
 #include <assert.h>
@@ -61,6 +61,7 @@
        struct puffs_cc *owner;
        bool in_trans;
        int id;
+       const char *label;
 };
 
 static void
@@ -652,6 +653,11 @@
        return error;
 }
 
+/*
+ * setlabel: set the descriptive label for the connection.
+ *
+ * we use simple pointer comparison for label equality check.
+ */
 static void
 setlabel(struct Xconn *xc, const char *label)
 {
@@ -667,7 +673,7 @@
         *      WHERE state <> 'idle'
         */
 
-       if (label != NULL) {
+       if (label != NULL && label != xc->label) {
                struct cmd *c;
                char cmd_str[1024];
 
@@ -677,6 +683,7 @@
                error = simplecmd(xc, c);
                freecmd(c);
                assert(error == 0);
+               xc->label = label;
        } else {
 #if 0 /* don't bother to clear label */
                static struct cmd *c;
@@ -878,6 +885,7 @@
                xc->owner = NULL;
                xc->in_trans = false;
                xc->id = xcid++;
+               xc->label = NULL;
                assert(xc->id < 32);
                PQsetNoticeReceiver(conn, pgfs_notice_receiver, xc);
                TAILQ_INSERT_HEAD(&xclist, xc, list);



Home | Main Index | Thread Index | Old Index