From: Alan T. DeKok Date: Sun, 11 Aug 2024 13:44:40 +0000 (-0400) Subject: clean up API and simplify X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=457252013e13dbfe9586a3f6bdc03bac4d9fa111;p=thirdparty%2Ffreeradius-server.git clean up API and simplify no need to pass buffer / size twice to the receive function, it's already in the dedup_ctx --- diff --git a/src/lib/bio/dedup.c b/src/lib/bio/dedup.c index 471a0191f11..9e1dda3efe4 100644 --- a/src/lib/bio/dedup.c +++ b/src/lib/bio/dedup.c @@ -35,6 +35,9 @@ * like src/dst ip/port, and therefore can't always be an #fr_bio_dedup_entry_t. The caller should associate * the #fr_bio_dedup_entry_t with the packet_ctx for the reply. The get_item() routine can then return the entry. * + * For simplicity, the next bio should be a memory one. That way the read() can read more than one packet if + * necessary. And the write() can cache a partial packet if it blocks. + * * The entry needs to be cached in order to maintain the internal tracking used by the dedup BIO. * * On client retransmit, the #fr_bio_dedup_receive_t callback is run, just as if it is a new packet. The @@ -901,7 +904,7 @@ static ssize_t fr_bio_dedup_read(fr_bio_t *bio, void *packet_ctx, void *buffer, * The caller should cancel any conflicting packets by calling fr_bio_dedup_entry_cancel(). Note * that for sanity, we don't re-use the previous #fr_bio_dedup_entry_t. */ - if (!my->receive(bio, item, packet_ctx, buffer, rcode)) { + if (!my->receive(bio, item, packet_ctx)) { item->state = FR_BIO_DEDUP_STATE_FREE; fr_bio_dedup_list_insert_head(&my->free, item); return 0; diff --git a/src/lib/bio/dedup.h b/src/lib/bio/dedup.h index 1860730646f..56f6a2bcd2b 100644 --- a/src/lib/bio/dedup.h +++ b/src/lib/bio/dedup.h @@ -50,6 +50,8 @@ struct fr_bio_dedup_entry_s { void *reply_ctx; //!< reply ctx uint8_t *reply; //!< reply cached by the application size_t reply_size; //!< size of the cached reply + + fr_rb_node_t dedup; //!< user managed dedup node }; #endif @@ -69,13 +71,11 @@ typedef enum { * @param bio the binary IO handler * @param dedup_ctx new dedup_ctx assigned to this potential packet * @param packet_ctx per-packet context for the response - * @param buffer raw data for the request - * @param size size of the raw request data * @return * - false - discard the packet * - true - create a new entry for the packet */ -typedef bool (*fr_bio_dedup_receive_t)(fr_bio_t *bio, fr_bio_dedup_entry_t *dedup_ctx, void *packet_ctx, const void *buffer, size_t size); +typedef bool (*fr_bio_dedup_receive_t)(fr_bio_t *bio, fr_bio_dedup_entry_t *dedup_ctx, void *packet_ctx); /** Callback on release the packet (timeout, or cancelled by the application) *