From: Alan T. DeKok Date: Tue, 14 May 2024 23:41:59 +0000 (-0400) Subject: handle the case of write blocked due to all IDs being used. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0bb92dedee950a2b2a32a058ca0d004ab2d79f1;p=thirdparty%2Ffreeradius-server.git handle the case of write blocked due to all IDs being used. The next few commits should add and use the various callback functions to actually handle write blocked / resume --- diff --git a/src/protocols/radius/client.c b/src/protocols/radius/client.c index ae32691e1d9..5194b90645f 100644 --- a/src/protocols/radius/client.c +++ b/src/protocols/radius/client.c @@ -85,6 +85,11 @@ fr_radius_client_fd_bio_t *fr_radius_client_fd_bio_alloc(TALLOC_CTX *ctx, size_t return NULL; } + /* + * So that read / write pause / resume callbacks can find us + */ + my->fd->uctx = my; + my->fd_info = fr_bio_fd_info(my->fd); fr_assert(my->fd_info != NULL); @@ -139,6 +144,10 @@ int fr_radius_client_fd_bio_write(fr_radius_client_fd_bio_t *my, void *request_c */ if (fr_bio_retry_entry_cancel(my->retry, NULL) < 1) { all_ids_used: + my->all_ids_used = true; + + if (my->common.write_blocked) my->common.write_blocked(&my->common); + fr_strerror_const("All IDs are in use"); return fr_bio_error(GENERIC); } @@ -296,6 +305,16 @@ static void radius_client_retry_release(fr_bio_t *bio, fr_bio_retry_entry_t *ret */ id_ctx->request_ctx = NULL; id_ctx->retry_ctx = NULL; + + /* + * IO was blocked due to IDs. We now have a free ID, so perhaps we can resume writes. But only + * if the IO handlers didn't mark us as "write blocked". + */ + if (my->all_ids_used) { + my->all_ids_used = false; + + if (!my->write_blocked && my->common.write_resume) my->common.write_resume(&my->common); + } } /** Cancel one packet. diff --git a/src/protocols/radius/client_priv.h b/src/protocols/radius/client_priv.h index c6758e799ca..a0ae5d2a7c7 100644 --- a/src/protocols/radius/client_priv.h +++ b/src/protocols/radius/client_priv.h @@ -45,6 +45,9 @@ typedef struct { fr_bio_t *mem; fr_bio_t *fd; + bool all_ids_used; //!< ALL IDs are used. + bool write_blocked; + fr_radius_client_bio_info_t info; /*