mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-09 22:00:39 +01:00
add option, off by default, to stall each message forward by some time
to better simulate network conditions when testing against local relay.
This commit is contained in:
parent
603462fc33
commit
f4b64fe97d
3 changed files with 16 additions and 0 deletions
|
@ -96,6 +96,12 @@ CookieRef::ReInit( const char* cookie, const char* connName, CookieID id )
|
||||||
m_nHostMsgs = 0;
|
m_nHostMsgs = 0;
|
||||||
m_in_handleEvents = false;
|
m_in_handleEvents = false;
|
||||||
|
|
||||||
|
if ( RelayConfigs::GetConfigs()->GetValueFor( "SEND_DELAY_MILLIS",
|
||||||
|
&m_delayMicros ) ) {
|
||||||
|
m_delayMicros *= 1000; /* millis->micros */
|
||||||
|
} else {
|
||||||
|
m_delayMicros = 0;
|
||||||
|
}
|
||||||
RelayConfigs::GetConfigs()->GetValueFor( "HEARTBEAT", &m_heatbeat );
|
RelayConfigs::GetConfigs()->GetValueFor( "HEARTBEAT", &m_heatbeat );
|
||||||
logf( XW_LOGINFO, "initing cref for cookie %s, connName %s",
|
logf( XW_LOGINFO, "initing cref for cookie %s, connName %s",
|
||||||
m_cookie.c_str(), m_connName.c_str() );
|
m_cookie.c_str(), m_connName.c_str() );
|
||||||
|
@ -882,6 +888,10 @@ CookieRef::forward_or_store( const CRefEvent* evt )
|
||||||
/* This is an ugly hack!!!! */
|
/* This is an ugly hack!!!! */
|
||||||
*buf = XWRELAY_MSG_FROMRELAY;
|
*buf = XWRELAY_MSG_FROMRELAY;
|
||||||
|
|
||||||
|
if ( 0 < m_delayMicros && destSocket != -1 ) {
|
||||||
|
usleep( m_delayMicros );
|
||||||
|
}
|
||||||
|
|
||||||
if ( (destSocket == -1)
|
if ( (destSocket == -1)
|
||||||
|| !send_with_length( destSocket, buf, buflen, true ) ) {
|
|| !send_with_length( destSocket, buf, buflen, true ) ) {
|
||||||
store_message( dest, buf, buflen );
|
store_message( dest, buf, buflen );
|
||||||
|
|
|
@ -256,6 +256,8 @@ class CookieRef {
|
||||||
|
|
||||||
pthread_t m_locking_thread; /* for debugging only */
|
pthread_t m_locking_thread; /* for debugging only */
|
||||||
bool m_in_handleEvents; /* for debugging only */
|
bool m_in_handleEvents; /* for debugging only */
|
||||||
|
|
||||||
|
int m_delayMicros;
|
||||||
}; /* CookieRef */
|
}; /* CookieRef */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,3 +42,7 @@ SERVERNAME=eehouse.org
|
||||||
# 0 means errors only, 1 info, 2 verbose and 3 very verbose.
|
# 0 means errors only, 1 info, 2 verbose and 3 very verbose.
|
||||||
LOGLEVEL=0
|
LOGLEVEL=0
|
||||||
LOGFILE_PATH=./xwrelay.log
|
LOGFILE_PATH=./xwrelay.log
|
||||||
|
|
||||||
|
# Delay sending packets so devices/emulators on the same machine as
|
||||||
|
# relay have a bit more natural experience
|
||||||
|
# SEND_DELAY_MILLIS=500
|
||||||
|
|
Loading…
Add table
Reference in a new issue