[xferbuf] Simplify and generalise data transfer buffers

Since all data transfer buffer contents are now accessible via direct
pointer dereferences, remove the unnecessary abstractions for read and
write operations and create two new data transfer buffer types: a
fixed-size buffer, and a void buffer that records its size but can
never receive non-zero lengths of data.  These replace the custom data
buffer types currently implemented for EFI PXE TFTP downloads and for
block device translations.

A new operation xferbuf_detach() is required to take ownership of the
data accumulated in the data transfer buffer, since we no longer rely
on the existence of an independently owned external data pointer for
data transfer buffers allocated via umalloc().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-04-29 09:16:41 +01:00
parent 43fc516298
commit 837b77293b
7 changed files with 130 additions and 245 deletions

View File

@@ -129,6 +129,7 @@ static int peermux_info_deliver ( struct peerdist_multiplexer *peermux,
* @v rc Reason for close
*/
static void peermux_info_close ( struct peerdist_multiplexer *peermux, int rc ){
struct xfer_buffer *buffer = &peermux->buffer;
struct peerdist_info *info = &peermux->cache.info;
size_t len;
@@ -145,8 +146,7 @@ static void peermux_info_close ( struct peerdist_multiplexer *peermux, int rc ){
intf_shutdown ( &peermux->info, rc );
/* Parse content information */
if ( ( rc = peerdist_info ( info->raw.data, peermux->buffer.len,
info ) ) != 0 ) {
if ( ( rc = peerdist_info ( buffer->data, buffer->len, info ) ) != 0 ) {
DBGC ( peermux, "PEERMUX %p could not parse content info: %s\n",
peermux, strerror ( rc ) );
goto err;
@@ -422,8 +422,7 @@ int peermux_filter ( struct interface *xfer, struct interface *info,
intf_init ( &peermux->xfer, &peermux_xfer_desc, &peermux->refcnt );
intf_init ( &peermux->info, &peermux_info_desc, &peermux->refcnt );
peermux->uri = uri_get ( uri );
xferbuf_umalloc_init ( &peermux->buffer,
&peermux->cache.info.raw.data );
xferbuf_umalloc_init ( &peermux->buffer );
process_init_stopped ( &peermux->process, &peermux_process_desc,
&peermux->refcnt );
INIT_LIST_HEAD ( &peermux->busy );