From: Marko Kreen Date: Wed, 17 Apr 2013 16:07:28 +0000 (+0300) Subject: console: rename backend_pid to remote_pid X-Git-Tag: pgbouncer_1_6_rc1~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ff381ccde731d3e13dd2ffa6772599d2a9c691e;p=pgbouncer console: rename backend_pid to remote_pid This corresponds better to current implementation, as now client pid is also shown correctly. --- diff --git a/doc/usage.txt b/doc/usage.txt index 3c53f75..fd0942e 100644 --- a/doc/usage.txt +++ b/doc/usage.txt @@ -231,9 +231,12 @@ ptr:: link:: Address of client connection the server is paired with. -backend_pid:: - Pid of backend server process. In case the server is another PgBouncer, - it will be a random number associated with this connection. +remote_pid:: + Pid of backend server process. In case connection is made over + unix socket and OS supports getting process ID info, it's + OS pid. Otherwise it's extracted from cancel packet server sent, + which should be PID in case server is Postgres, but it's a random + number in case server it another PgBouncer. ==== SHOW CLIENTS; ==== @@ -275,9 +278,9 @@ ptr:: link:: Address of server connection the client is paired with. -backend_pid:: - Random number sent to client as "backend process pid". - Usually unique, but not quaranteed. +remote_pid:: + Process ID, in case client connects over UNIX socket + and OS supports getting it. ==== SHOW POOLS; ==== diff --git a/src/admin.c b/src/admin.c index ee6a999..dafcfa4 100644 --- a/src/admin.c +++ b/src/admin.c @@ -523,7 +523,7 @@ static void socket_header(PktBuf *buf, bool debug) "type", "user", "database", "state", "addr", "port", "local_addr", "local_port", "connect_time", "request_time", - "ptr", "link", "backend_pid", + "ptr", "link", "remote_pid", "recv_pos", "pkt_pos", "pkt_remain", "send_pos", "send_remain", "pkt_avail", "send_avail"); @@ -537,7 +537,7 @@ static void adr2txt(const PgAddr *adr, char *dst, unsigned dstlen) static void socket_row(PktBuf *buf, PgSocket *sk, const char *state, bool debug) { int pkt_avail = 0, send_avail = 0; - int backend_pid; + int remote_pid; char ptrbuf[128], linkbuf[128]; char l_addr[PGADDR_BUF], r_addr[PGADDR_BUF]; IOBuf *io = sk->sbuf.io; @@ -558,12 +558,12 @@ static void socket_row(PktBuf *buf, PgSocket *sk, const char *state, bool debug) /* get pid over unix socket */ if (pga_is_unix(&sk->remote_addr)) - backend_pid = sk->remote_addr.scred.pid; + remote_pid = sk->remote_addr.scred.pid; else - backend_pid = 0; + remote_pid = 0; /* if that failed, get it from cancel key */ - if (is_server_socket(sk) && backend_pid == 0) - backend_pid = be32dec(sk->cancel_key); + if (is_server_socket(sk) && remote_pid == 0) + remote_pid = be32dec(sk->cancel_key); pktbuf_write_DataRow(buf, debug ? SKF_DBG : SKF_STD, is_server_socket(sk) ? "S" :"C", @@ -573,7 +573,7 @@ static void socket_row(PktBuf *buf, PgSocket *sk, const char *state, bool debug) l_addr, pga_port(&sk->local_addr), sk->connect_time, sk->request_time, - ptrbuf, linkbuf, backend_pid, + ptrbuf, linkbuf, remote_pid, io ? io->recv_pos : 0, io ? io->parse_pos : 0, sk->sbuf.pkt_remain,