libc_fs: Handle Packet_alloc_failed exception

This commit is contained in:
Norman Feske 2013-12-05 16:10:00 +01:00 committed by Christian Helmuth
parent 28c6763a7d
commit 2e6f281cf0

View File

@ -563,6 +563,7 @@ class Plugin : public Libc::Plugin
ssize_t read(Libc::File_descriptor *fd, void *buf, ::size_t count)
{
try {
File_system::Session::Tx::Source &source = *file_system()->tx();
size_t const max_packet_size = source.bulk_buffer_size() / 2;
@ -578,9 +579,8 @@ class Plugin : public Libc::Plugin
size_t curr_packet_size = Genode::min(remaining_count, max_packet_size);
/*
* XXX handle 'Packet_alloc_failed' exception'
*/
off_t const seek_offset = context(fd)->seek_offset();
File_system::Packet_descriptor
packet(source.alloc_packet(curr_packet_size),
static_cast<File_system::Packet_ref *>(context(fd)),
@ -598,9 +598,11 @@ class Plugin : public Libc::Plugin
do {
packet = source.get_acked_packet();
static_cast<Plugin_context *>(packet.ref())->in_flight = false;
} while (context(fd)->in_flight);
context(fd)->in_flight = false;
if (packet.operation() == File_system::Packet_descriptor::WRITE)
source.release_packet(packet);
} while (context(fd)->in_flight);
/*
* XXX check if acked packet belongs to request,
@ -626,8 +628,13 @@ class Plugin : public Libc::Plugin
if (read_num_bytes < curr_packet_size)
break;
}
return count - remaining_count;
} catch (File_system::Session::Tx::Source::Packet_alloc_failed) {
PERR("Packet_alloc_failed during read (count=%zd)", count);
return -1;
}
}
ssize_t readlink(const char *path, char *buf, size_t bufsiz)