mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-27 07:58:49 +01:00
when we get a fatal error from postgres server, try killing then
recreating the connection. This is untested, as fatal errors are rare.
This commit is contained in:
parent
3364dcbf46
commit
8e12a8ef84
2 changed files with 14 additions and 0 deletions
|
@ -762,6 +762,7 @@ DBMgr::execSql( const char* const query )
|
|||
logf( XW_LOGERROR, "%s: PQexec=>%s;%s", __func__,
|
||||
PQresStatus(PQresultStatus(result)),
|
||||
PQresultErrorMessage(result) );
|
||||
clearThreadConn();
|
||||
usleep( 20000 );
|
||||
}
|
||||
PQclear( result );
|
||||
|
@ -1143,6 +1144,18 @@ destr_function( void* conn )
|
|||
PQfinish( pgconn );
|
||||
}
|
||||
|
||||
void
|
||||
DBMgr::clearThreadConn()
|
||||
{
|
||||
logf( XW_LOGERROR, "%s called()", __func__ );
|
||||
PGconn* conn = (PGconn*)pthread_getspecific( m_conn_key );
|
||||
if ( NULL != conn ) {
|
||||
PQfinish( conn );
|
||||
int result = pthread_setspecific( m_conn_key, NULL );
|
||||
assert( 0 == result );
|
||||
}
|
||||
}
|
||||
|
||||
PGconn*
|
||||
DBMgr::getThreadConn( void )
|
||||
{
|
||||
|
|
|
@ -135,6 +135,7 @@ class DBMgr {
|
|||
int byteaIndex, unsigned char* buf, size_t* buflen );
|
||||
|
||||
PGconn* getThreadConn( void );
|
||||
void clearThreadConn();
|
||||
|
||||
void conn_key_alloc();
|
||||
pthread_key_t m_conn_key;
|
||||
|
|
Loading…
Add table
Reference in a new issue