mirror of
https://github.com/ipxe/ipxe
synced 2026-02-28 03:11:18 +03:00
[PXEXT] Avoid queueing zero-length buffers in posix_io.c
read_user() assumes that zero-length buffers don't exist, and optimises around this.
This commit is contained in:
@@ -114,7 +114,7 @@ static void posix_file_xfer_close ( struct xfer_interface *xfer, int rc ) {
|
|||||||
static int
|
static int
|
||||||
posix_file_xfer_deliver_iob ( struct xfer_interface *xfer,
|
posix_file_xfer_deliver_iob ( struct xfer_interface *xfer,
|
||||||
struct io_buffer *iobuf,
|
struct io_buffer *iobuf,
|
||||||
struct xfer_metadata *meta __unused ) {
|
struct xfer_metadata *meta ) {
|
||||||
struct posix_file *file =
|
struct posix_file *file =
|
||||||
container_of ( xfer, struct posix_file, xfer );
|
container_of ( xfer, struct posix_file, xfer );
|
||||||
|
|
||||||
@@ -125,7 +125,12 @@ posix_file_xfer_deliver_iob ( struct xfer_interface *xfer,
|
|||||||
if ( file->filesize < file->pos )
|
if ( file->filesize < file->pos )
|
||||||
file->filesize = file->pos;
|
file->filesize = file->pos;
|
||||||
|
|
||||||
|
if ( iob_len ( iobuf ) ) {
|
||||||
list_add_tail ( &iobuf->list, &file->data );
|
list_add_tail ( &iobuf->list, &file->data );
|
||||||
|
} else {
|
||||||
|
free_iob ( iobuf );
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,14 +298,15 @@ ssize_t read_user ( int fd, userptr_t buffer, off_t offset, size_t max_len ) {
|
|||||||
free_iob ( iobuf );
|
free_iob ( iobuf );
|
||||||
}
|
}
|
||||||
file->pos += len;
|
file->pos += len;
|
||||||
if ( len )
|
assert ( len != 0 );
|
||||||
return len;
|
return len;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If file has completed, return (after returning all data) */
|
/* If file has completed, return (after returning all data) */
|
||||||
if ( file->rc != -EINPROGRESS )
|
if ( file->rc != -EINPROGRESS ) {
|
||||||
|
assert ( list_empty ( &file->data ) );
|
||||||
return file->rc;
|
return file->rc;
|
||||||
|
}
|
||||||
|
|
||||||
/* No data ready and file still in progress; return -WOULDBLOCK */
|
/* No data ready and file still in progress; return -WOULDBLOCK */
|
||||||
return -EWOULDBLOCK;
|
return -EWOULDBLOCK;
|
||||||
|
|||||||
Reference in New Issue
Block a user