From 756ab80daa05a0d2f0d777d364164df94cb552c2 Mon Sep 17 00:00:00 2001 From: David Timber Date: Sun, 20 Sep 2020 20:48:48 +0930 Subject: * Fix bug in htbt: set client socket non-block * htbt: enforce HTBT_LBD_MAX_CLIENTS * Fix bug: wrong use of pth_poll_ev() in * prne_mbedtls_pth_handle() * lssh2_handle() --- src/htbt.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/htbt.c') diff --git a/src/htbt.c b/src/htbt.c index c24d07d..5bd4edc 100644 --- a/src/htbt.c +++ b/src/htbt.c @@ -26,6 +26,7 @@ #define HTBT_CNCP_INT_VAR 1800000 // half an hour variance #define HTBT_LBD_PORT prne_htobe16(PRNE_HTBT_PROTO_PORT) #define HTBT_LBD_BACKLOG 4 +#define HTBT_LBD_MAX_CLIENTS 5 // CNCP TXT Record Data Transfer Timeout static const struct timespec HTBT_CNCP_STREAM_TIMEOUT = { 1800, 0 }; // 30m @@ -2362,6 +2363,13 @@ static void htbt_lbd_serve_loop (prne_htbt_t *ctx) { client = NULL; ent = NULL; do { // TRY + if (!prne_sck_fcntl(fret)) { + goto CATCH; + } + if (ctx->lbd.conn_list.size >= HTBT_LBD_MAX_CLIENTS) { + goto CATCH; + } + client = (htbt_lbd_client_t*)prne_malloc( sizeof(htbt_lbd_client_t), 1); -- cgit