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)
|
||||
{
|
||||
|
|
|
@ -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…
Reference in New Issue
Block a user