mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
drop message, rather than asserting, if device id isn't in db.
This commit is contained in:
parent
3e9dfb9a9d
commit
ecef687471
1 changed files with 30 additions and 26 deletions
|
@ -727,15 +727,16 @@ DBMgr::readArray( const char* const connName, const char* column, int arr[] ) /
|
||||||
DevIDRelay
|
DevIDRelay
|
||||||
DBMgr::getDevID( const char* connName, int hid )
|
DBMgr::getDevID( const char* connName, int hid )
|
||||||
{
|
{
|
||||||
DevIDRelay devID;
|
DevIDRelay devID = DEVID_NONE;
|
||||||
const char* fmt = "SELECT devids[%d] FROM " GAMES_TABLE " WHERE connName='%s'";
|
const char* fmt = "SELECT devids[%d] FROM " GAMES_TABLE " WHERE connName='%s'";
|
||||||
string query;
|
string query;
|
||||||
string_printf( query, fmt, hid, connName );
|
string_printf( query, fmt, hid, connName );
|
||||||
logf( XW_LOGINFO, "%s: query: %s", __func__, query.c_str() );
|
logf( XW_LOGINFO, "%s: query: %s", __func__, query.c_str() );
|
||||||
|
|
||||||
PGresult* result = PQexec( getThreadConn(), query.c_str() );
|
PGresult* result = PQexec( getThreadConn(), query.c_str() );
|
||||||
assert( 1 == PQntuples( result ) );
|
if ( 1 == PQntuples( result ) ) {
|
||||||
devID = (DevIDRelay)strtoul( PQgetvalue( result, 0, 0 ), NULL, 10 );
|
devID = (DevIDRelay)strtoul( PQgetvalue( result, 0, 0 ), NULL, 10 );
|
||||||
|
}
|
||||||
PQclear( result );
|
PQclear( result );
|
||||||
return devID;
|
return devID;
|
||||||
}
|
}
|
||||||
|
@ -839,7 +840,9 @@ DBMgr::StoreMessage( const char* const connName, int hid,
|
||||||
const unsigned char* buf, int len )
|
const unsigned char* buf, int len )
|
||||||
{
|
{
|
||||||
DevIDRelay devID = getDevID( connName, hid );
|
DevIDRelay devID = getDevID( connName, hid );
|
||||||
|
if ( DEVID_NONE == devID ) {
|
||||||
|
logf( XW_LOGERROR, "%s: devid not found for connName=%s, hid=%d", __func__, connName, hid );
|
||||||
|
} else {
|
||||||
size_t newLen;
|
size_t newLen;
|
||||||
const char* fmt = "INSERT INTO " MSGS_TABLE
|
const char* fmt = "INSERT INTO " MSGS_TABLE
|
||||||
" (connname, hid, devid, token, %s, msglen)"
|
" (connname, hid, devid, token, %s, msglen)"
|
||||||
|
@ -866,6 +869,7 @@ DBMgr::StoreMessage( const char* const connName, int hid,
|
||||||
logf( XW_LOGINFO, "%s: query: %s", __func__, query.c_str() );
|
logf( XW_LOGINFO, "%s: query: %s", __func__, query.c_str() );
|
||||||
execSql( query );
|
execSql( query );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DBMgr::decodeMessage( PGresult* result, bool useB64, int b64indx, int byteaIndex,
|
DBMgr::decodeMessage( PGresult* result, bool useB64, int b64indx, int byteaIndex,
|
||||||
|
|
Loading…
Reference in a new issue