|
@@ -114,7 +114,7 @@ static void posix_file_xfer_close ( struct xfer_interface *xfer, int rc ) {
|
114
|
114
|
static int
|
115
|
115
|
posix_file_xfer_deliver_iob ( struct xfer_interface *xfer,
|
116
|
116
|
struct io_buffer *iobuf,
|
117
|
|
- struct xfer_metadata *meta __unused ) {
|
|
117
|
+ struct xfer_metadata *meta ) {
|
118
|
118
|
struct posix_file *file =
|
119
|
119
|
container_of ( xfer, struct posix_file, xfer );
|
120
|
120
|
|
|
@@ -125,7 +125,12 @@ posix_file_xfer_deliver_iob ( struct xfer_interface *xfer,
|
125
|
125
|
if ( file->filesize < file->pos )
|
126
|
126
|
file->filesize = file->pos;
|
127
|
127
|
|
128
|
|
- list_add_tail ( &iobuf->list, &file->data );
|
|
128
|
+ if ( iob_len ( iobuf ) ) {
|
|
129
|
+ list_add_tail ( &iobuf->list, &file->data );
|
|
130
|
+ } else {
|
|
131
|
+ free_iob ( iobuf );
|
|
132
|
+ }
|
|
133
|
+
|
129
|
134
|
return 0;
|
130
|
135
|
}
|
131
|
136
|
|
|
@@ -293,14 +298,15 @@ ssize_t read_user ( int fd, userptr_t buffer, off_t offset, size_t max_len ) {
|
293
|
298
|
free_iob ( iobuf );
|
294
|
299
|
}
|
295
|
300
|
file->pos += len;
|
296
|
|
- if ( len )
|
297
|
|
- return len;
|
298
|
|
- break;
|
|
301
|
+ assert ( len != 0 );
|
|
302
|
+ return len;
|
299
|
303
|
}
|
300
|
304
|
|
301
|
305
|
/* If file has completed, return (after returning all data) */
|
302
|
|
- if ( file->rc != -EINPROGRESS )
|
|
306
|
+ if ( file->rc != -EINPROGRESS ) {
|
|
307
|
+ assert ( list_empty ( &file->data ) );
|
303
|
308
|
return file->rc;
|
|
309
|
+ }
|
304
|
310
|
|
305
|
311
|
/* No data ready and file still in progress; return -WOULDBLOCK */
|
306
|
312
|
return -EWOULDBLOCK;
|