mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 20:05:54 +00:00
libc: add Genode::Lock to File_descriptor class
This lock is needed to prevent multiple threads and/or multiple libc-plugins from using the same file descriptor in p{read,write}. Fixes #948.
This commit is contained in:
parent
607036718c
commit
36f91c2007
@ -16,6 +16,7 @@
|
||||
#define _LIBC_PLUGIN__FD_ALLOC_H_
|
||||
|
||||
#include <base/allocator_avl.h>
|
||||
#include <base/lock.h>
|
||||
#include <base/printf.h>
|
||||
#include <os/path.h>
|
||||
|
||||
@ -42,6 +43,7 @@ namespace Libc {
|
||||
char *fd_path; /* for 'fchdir()' */
|
||||
Plugin *plugin;
|
||||
Plugin_context *context;
|
||||
Genode::Lock lock;
|
||||
|
||||
void path(char const *newpath)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ File_descriptor *File_descriptor_allocator::alloc(Plugin *plugin,
|
||||
|
||||
/* allocate fresh fd if the default value for 'libc_fd' was specified */
|
||||
bool alloc_ok = false;
|
||||
if (addr == ANY_FD)
|
||||
if (addr == ANY_FD)
|
||||
alloc_ok = Allocator_avl_base::alloc(1, reinterpret_cast<void**>(&addr));
|
||||
else
|
||||
alloc_ok = (Allocator_avl_base::alloc_addr(1, addr).is_ok());
|
||||
@ -65,6 +65,7 @@ File_descriptor *File_descriptor_allocator::alloc(Plugin *plugin,
|
||||
fdo->fd_path = 0;
|
||||
fdo->plugin = plugin;
|
||||
fdo->context = context;
|
||||
fdo->lock = Lock(Lock::UNLOCKED);
|
||||
return fdo;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user