Skip to content

Commit

Permalink
Added locking for set_timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
empyreanx committed Jan 22, 2016
1 parent edb8850 commit 3caf107
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gdnet_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ void GDNetPeer::send_var(const Variant& var, int channel_id, int type) {
}

void GDNetPeer::set_timeout(int limit, int min_timeout, int max_timeout) {
enet_peer_timeout(_peer, limit, min_timeout, max_timeout);
ERR_FAIL_COND(_host->_host == NULL);

while (true) {
if (_host->_mutex->try_lock() == 0) {
enet_peer_timeout(_peer, limit, min_timeout, max_timeout);
_host->_mutex->unlock();
break;
}
}
}

void GDNetPeer::_bind_methods() {
Expand Down

0 comments on commit 3caf107

Please sign in to comment.