From 3d18e5832eb96aaaa0d2714781b5df330290ba56 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 2 Jul 2013 05:46:48 -0700 Subject: [PATCH] specify server's port in conf file since at least on one of my machines it's not what libpq expects. (Required by upgrade from 8.4 to 9.1.) --- xwords4/relay/dbmgr.cpp | 19 ++++++++++++++----- xwords4/relay/xwrelay.conf_tmplate | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/xwords4/relay/dbmgr.cpp b/xwords4/relay/dbmgr.cpp index 0e02a4334..e80efde06 100644 --- a/xwords4/relay/dbmgr.cpp +++ b/xwords4/relay/dbmgr.cpp @@ -757,7 +757,9 @@ DBMgr::execSql( const char* const query ) PGresult* result = PQexec( getThreadConn(), query ); bool ok = PGRES_COMMAND_OK == PQresultStatus(result); if ( !ok ) { - logf( XW_LOGERROR, "PQexec=>%s;%s", PQresStatus(PQresultStatus(result)), PQresultErrorMessage(result) ); + logf( XW_LOGERROR, "PQexec=>%s;%s", PQresStatus(PQresultStatus(result)), + PQresultErrorMessage(result) ); + assert( 0 ); } PQclear( result ); return ok; @@ -1143,12 +1145,19 @@ DBMgr::getThreadConn( void ) if ( NULL == conn ) { char buf[128]; - int len = snprintf( buf, sizeof(buf), "dbname = " ); - if ( !RelayConfigs::GetConfigs()-> - GetValueFor( "DB_NAME", &buf[len], sizeof(buf)-len ) ) { + int port; + if ( !RelayConfigs::GetConfigs()->GetValueFor( "DB_NAME", buf, + sizeof(buf) ) ) { assert( 0 ); } - conn = PQconnectdb( buf ); + if ( !RelayConfigs::GetConfigs()->GetValueFor( "DB_PORT", &port ) ) { + assert( 0 ); + } + string params; + string_printf( params, "dbname = %s ", buf ); + string_printf( params, "port = %d ", port ); + + conn = PQconnectdb( params.c_str() ); pthread_setspecific( m_conn_key, conn ); } return conn; diff --git a/xwords4/relay/xwrelay.conf_tmplate b/xwords4/relay/xwrelay.conf_tmplate index 2773342e0..2a491c0c2 100644 --- a/xwords4/relay/xwrelay.conf_tmplate +++ b/xwords4/relay/xwrelay.conf_tmplate @@ -56,6 +56,8 @@ SERVERNAME=eehouse.org # name of the database. (Table names are hard-coded.) DB_NAME=xwgames +# UDP port postgres server is listening on +DB_PORT=5433 # Initial level of logging. See xwrelay_priv.h for values. Currently # 0 means errors only, 1 info, 2 verbose and 3 very verbose.