Skip to content

Commit c637586

Browse files
committed
Removed configurable receive timeout
1 parent a789819 commit c637586

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

game.project

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ include_dirs = websocket
1717

1818
[websocket]
1919
debug = verbose
20-
receive_timeout = 1000
2120

websocket/ext.properties

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,3 @@ debug.default = disabled
1919
socket_timeout.type = integer
2020
socket_timeout.default = 500000
2121
socket_timeout.help = Timeout for the underlying socket connection, in microseconds
22-
23-
receive_timeout.type = integer
24-
receive_timeout.help = Socket receive timeout in microseconds
25-
receive_timeout.default = 1000

websocket/src/websocket.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ struct WebsocketContext
3030
{
3131
uint64_t m_BufferSize;
3232
int m_Timeout;
33-
int m_ReceiveTimeout;
3433
dmArray<WebsocketConnection*> m_Connections;
3534
dmConnectionPool::HPool m_Pool;
3635
uint32_t m_Initialized:1;
@@ -271,10 +270,13 @@ static void ConnectionWorker(void* _conn)
271270
conn->m_SSLSocket = dmConnectionPool::GetSSLSocket(g_Websocket.m_Pool, conn->m_Connection);
272271
dmSocket::SetNoDelay(conn->m_Socket, true);
273272
dmSocket::SetBlocking(conn->m_Socket, false);
274-
dmSocket::SetReceiveTimeout(conn->m_Socket, g_Websocket.m_ReceiveTimeout);
273+
// Don't go lower than 1000 microseconds since this value will be divided by 1000
274+
// in the socket code and we'll then get a timeout of 0 which means the socket
275+
// will block indefinitely
276+
dmSocket::SetReceiveTimeout(conn->m_Socket, 1000);
275277
if (conn->m_SSLSocket)
276278
{
277-
dmSSLSocket::SetReceiveTimeout(conn->m_SSLSocket, g_Websocket.m_ReceiveTimeout);
279+
dmSSLSocket::SetReceiveTimeout(conn->m_SSLSocket, 1000);
278280
}
279281

280282
// send handshake
@@ -714,11 +716,6 @@ static dmExtension::Result AppInitialize(dmExtension::AppParams* params)
714716
g_Websocket.m_Pool = 0;
715717
g_Websocket.m_Initialized = 0;
716718

717-
// do not go below 1000 microseconds since the value is divided by 1000
718-
// in dmSocket
719-
// this will result in a timeout of 0 which blocks indefinitely
720-
g_Websocket.m_ReceiveTimeout = dmMath::Max(1000, dmConfigFile::GetInt(params->m_ConfigFile, "websocket.receive_timeout", 1000));
721-
722719
dmConnectionPool::Params pool_params;
723720
pool_params.m_MaxConnections = dmConfigFile::GetInt(params->m_ConfigFile, "websocket.max_connections", 2);
724721
dmConnectionPool::Result result = dmConnectionPool::New(&pool_params, &g_Websocket.m_Pool);

0 commit comments

Comments
 (0)