From: Pavan Deolasee Date: Tue, 31 Jul 2018 06:00:01 +0000 (+0530) Subject: Ensure that bad protocol ERROR message is sent to the frontend X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=3eceb70d92756deaf07ae416dd24540cb63c50fd;p=postgres-xl.git Ensure that bad protocol ERROR message is sent to the frontend In case of receiving bad protocol messages received by the GTM proxy, let the client know about the error messages. --- diff --git a/src/gtm/proxy/proxy_main.c b/src/gtm/proxy/proxy_main.c index 8db81b1e3c..ba976eb938 100644 --- a/src/gtm/proxy/proxy_main.c +++ b/src/gtm/proxy/proxy_main.c @@ -1177,6 +1177,9 @@ GTMProxy_ThreadMain(void *argp) */ if (conninfo->con_disconnected) { + EmitErrorReport(conninfo->con_port); + if (conninfo->con_port->sock > 0) + StreamClose(conninfo->con_port->sock); GTMProxy_ThreadRemoveConnection(thrinfo, conninfo); pfree(conninfo); ii--; @@ -2329,8 +2332,6 @@ GTMProxy_HandshakeConnection(GTMProxy_ConnectionInfo *conninfo) if (startup_type != 'A') { conninfo->con_disconnected = true; - if (conninfo->con_port->sock > 0) - StreamClose(conninfo->con_port->sock); ereport(ERROR, (EPROTO, errmsg("Expecting a startup message, but received %c", @@ -2347,8 +2348,6 @@ GTMProxy_HandshakeConnection(GTMProxy_ConnectionInfo *conninfo) if (pq_getmessage(conninfo->con_port, &inBuf, 0)) { conninfo->con_disconnected = true; - if (conninfo->con_port->sock > 0) - StreamClose(conninfo->con_port->sock); ereport(ERROR, (EPROTO, errmsg("Expecting PGXC Node ID, but received EOF")));