drop message, rather than asserting, if device id isn't in db.

This commit is contained in:
Eric House 2013-06-17 07:52:58 -07:00
parent 3e9dfb9a9d
commit ecef687471

View file

@ -727,15 +727,16 @@ DBMgr::readArray( const char* const connName, const char* column, int arr[] ) /
DevIDRelay
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'";
string query;
string_printf( query, fmt, hid, connName );
logf( XW_LOGINFO, "%s: query: %s", __func__, 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 );
}
PQclear( result );
return devID;
}
@ -839,7 +840,9 @@ DBMgr::StoreMessage( const char* const connName, int hid,
const unsigned char* buf, int len )
{
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;
const char* fmt = "INSERT INTO " MSGS_TABLE
" (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() );
execSql( query );
}
}
void
DBMgr::decodeMessage( PGresult* result, bool useB64, int b64indx, int byteaIndex,