diff options
author | Michael Brown | 2008-03-25 22:10:21 +0100 |
---|---|---|
committer | Michael Brown | 2008-03-25 22:10:21 +0100 |
commit | 96edbd128f596f34c5af3c5a730402043360a0e3 (patch) | |
tree | 7de60178afa84214a7d0ddb1d08f2763f4eeb7f4 | |
parent | [Settings] Remove assumption that all settings have DHCP tag values (diff) | |
download | ipxe-96edbd128f596f34c5af3c5a730402043360a0e3.tar.gz ipxe-96edbd128f596f34c5af3c5a730402043360a0e3.tar.xz ipxe-96edbd128f596f34c5af3c5a730402043360a0e3.zip |
[PXEXT] Avoid queueing zero-length buffers in posix_io.c
read_user() assumes that zero-length buffers don't exist, and optimises
around this.
-rw-r--r-- | src/core/posix_io.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/core/posix_io.c b/src/core/posix_io.c index b48c1f80..e0459bdf 100644 --- a/src/core/posix_io.c +++ b/src/core/posix_io.c @@ -114,7 +114,7 @@ static void posix_file_xfer_close ( struct xfer_interface *xfer, int rc ) { static int posix_file_xfer_deliver_iob ( struct xfer_interface *xfer, struct io_buffer *iobuf, - struct xfer_metadata *meta __unused ) { + struct xfer_metadata *meta ) { struct posix_file *file = 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 ) file->filesize = file->pos; - list_add_tail ( &iobuf->list, &file->data ); + if ( iob_len ( iobuf ) ) { + list_add_tail ( &iobuf->list, &file->data ); + } else { + free_iob ( iobuf ); + } + 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 ); } file->pos += len; - if ( len ) - return len; - break; + assert ( len != 0 ); + return len; } /* 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; + } /* No data ready and file still in progress; return -WOULDBLOCK */ return -EWOULDBLOCK; |