summaryrefslogtreecommitdiff
path: root/src/modules/rkt/rkt.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-07-17 13:54:46 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-07-17 13:54:46 -0700
commiteb0a0bac1f8a78e5164aa07c2e0157d34733cec8 (patch)
tree0429b893260d1bf9f061985da1f0cff40d6fe3a6 /src/modules/rkt/rkt.c
parentb9450fa1b2baba41a912d3d57682df9e14b02530 (diff)
modules/rkt: limit Rocket reconnect frequency to 2HZ
On Linux I don't notice a significant affect on anything letting rkt try connect every frame when offline but in creative mode. On Windows however, Dan reported significant latencies in the Scener prompt responsiveness and visible slowdowns in this condition. I suspect the WIN32 Rocket library's sync_tcp_connect() code is the real problem here. But for now I can ameliorate things a bit by just hammering on that code path less when unconnected.
Diffstat (limited to 'src/modules/rkt/rkt.c')
-rw-r--r--src/modules/rkt/rkt.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/modules/rkt/rkt.c b/src/modules/rkt/rkt.c
index 9aa18ee..4caa9ba 100644
--- a/src/modules/rkt/rkt.c
+++ b/src/modules/rkt/rkt.c
@@ -222,8 +222,13 @@ static void rkt_update_rocket(rkt_context_t *ctxt, unsigned ticks)
if (!s->connect)
return;
- if (!ctxt->connected || sync_update(ctxt->sync_device, ctxt->rocket_row, &rkt_sync_cb, ctxt) < 0)
- ctxt->connected = !sync_tcp_connect(ctxt->sync_device, s->host, s->port);
+ if (!ctxt->connected || sync_update(ctxt->sync_device, ctxt->rocket_row, &rkt_sync_cb, ctxt) < 0) {
+ /* limit connect attempts to 2HZ */
+ if (ticks - ctxt->last_connect >= 500) {
+ ctxt->connected = !sync_tcp_connect(ctxt->sync_device, s->host, s->port);
+ ctxt->last_connect = ticks;
+ }
+ }
}
© All Rights Reserved