mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 21:57:55 +00:00
Noux: add cleanup_socket_descriptors() function
When a child exists it makes sure that all remaining socket descriptors are closed.
This commit is contained in:
parent
2010a74fba
commit
8dfb3d5d81
@ -31,6 +31,8 @@
|
||||
#include <cpu_session_component.h>
|
||||
#include <child_policy.h>
|
||||
|
||||
extern void (*cleanup_socket_descriptors)();
|
||||
|
||||
namespace Noux {
|
||||
|
||||
/**
|
||||
@ -338,6 +340,10 @@ namespace Noux {
|
||||
|
||||
~Child()
|
||||
{
|
||||
/* short-cut to close all remaining open sd's if the child exits */
|
||||
if (cleanup_socket_descriptors)
|
||||
cleanup_socket_descriptors();
|
||||
|
||||
_sig_rec->dissolve(&_execve_cleanup_dispatcher);
|
||||
_sig_rec->dissolve(&_exit_dispatcher);
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
void (*close_socket)(int) = 0;
|
||||
|
||||
void (*cleanup_socket_descriptors)() = 0;
|
||||
|
||||
void init_network() { }
|
||||
|
||||
bool Noux::Child::_syscall_net(Noux::Session::Syscall sc) { return false; }
|
||||
|
@ -33,6 +33,7 @@ using namespace Noux;
|
||||
|
||||
void (*libc_select_notify)();
|
||||
void (*close_socket)(int);
|
||||
void (*cleanup_socket_descriptors)();
|
||||
|
||||
/* set select() timeout to lwip's lowest possible value */
|
||||
struct timeval timeout = { 0, 10000 };
|
||||
@ -95,7 +96,15 @@ static void select_notify()
|
||||
|
||||
static void _close_socket(int sd)
|
||||
{
|
||||
Socket_descriptor_registry<Socket_io_channel>::instance()->remove_io_channel(sd);
|
||||
if (Socket_descriptor_registry<Socket_io_channel>::instance()->sd_in_use(sd)) {
|
||||
Socket_descriptor_registry<Socket_io_channel>::instance()->remove_io_channel(sd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void _cleanup_socket_descriptors()
|
||||
{
|
||||
Socket_descriptor_registry<Socket_io_channel>::instance()->reset_all();
|
||||
}
|
||||
|
||||
|
||||
@ -121,6 +130,9 @@ void init_network()
|
||||
|
||||
if (!close_socket)
|
||||
close_socket = _close_socket;
|
||||
|
||||
if (!cleanup_socket_descriptors)
|
||||
cleanup_socket_descriptors = _cleanup_socket_descriptors;
|
||||
}
|
||||
|
||||
/*********************************
|
||||
|
Loading…
Reference in New Issue
Block a user