From 6abe2a418a44078159344e03da11603054d84240 Mon Sep 17 00:00:00 2001 From: kanoi Date: Mon, 22 Dec 2014 12:37:49 +1100 Subject: [PATCH] ckdb/php - add a 'sync' value to the page footer - shows how many outstanding socket requests have been queued --- pool/page.php | 19 ++++++++++++++++--- src/ckdb.h | 2 +- src/ckdb_cmd.c | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pool/page.php b/pool/page.php index 64b095eb..02bdda33 100644 --- a/pool/page.php +++ b/pool/page.php @@ -137,6 +137,8 @@ h1 {margin-top: 20px; float:middle; font-size: 20px;} .st1 {color:red; font-weight:bold; } .st2 {color:green; font-weight:bold; } .st3 {color:blue; font-weight:bold; } +.fthi {color:red; font-size:7px; } +.ftlo {color:green; font-size:7px; } .ft {color:blue; font-size:7px; } \n"; @@ -420,14 +422,25 @@ function pgbody($info, $page, $menu, $dotop, $user, $douser) return $body; } # -function pgfoot() +function pgfoot($info) { $foot = ''; $foot .= ''; $foot .= ''; $foot .= ''; $foot .= '
'; - $foot .= '

Copyright © Kano 2014'; + $foot .= '

'; + if (is_array($info) && isset($info['sync'])) + { + $sync = $info['sync']; + if ($sync > 1000) + $syc = 'hi'; + else + $syc = 'lo'; + $syncd = number_format($sync); + $foot .= "sync: $syncd "; + } + $foot .= 'Copyright © Kano 2014'; $now = date('Y'); if ($now != '2014') $foot .= "-$now"; @@ -466,7 +479,7 @@ function gopage($info, $data, $pagefun, $page, $menu, $name, $user, $ispage = tr $head = pghead($script_marker, $name); $body = pgbody($info, $page, $menu, $dotop, $user, $douser); - $foot = pgfoot(); + $foot = pgfoot($info); if ($dbg === true) $pg = str_replace($dbg_marker, cvtdbg(), $pg); diff --git a/src/ckdb.h b/src/ckdb.h index 18da3190..b0dec28d 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.6" -#define CKDB_VERSION DB_VERSION"-0.780" +#define CKDB_VERSION DB_VERSION"-0.781" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index c0aaeeaa..7e2dc96d 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -2618,6 +2618,10 @@ static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id, APPEND_REALLOC(buf, off, len, tmp); } + // Don't bother with locking - it's just an FYI web stat + snprintf(tmp, sizeof(tmp), "sync=%d%c", workqueue_store->count, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + u_item = NULL; if (i_username) { K_RLOCK(users_free);