mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 18:06:50 +00:00
parent
5a2ac73b69
commit
d266f44ef3
@ -563,7 +563,20 @@ extern "C" int socket_fs_accept(int libc_fd, sockaddr *addr, socklen_t *addrlen)
|
|||||||
Libc::Allocator alloc { };
|
Libc::Allocator alloc { };
|
||||||
accept_context = new (alloc)
|
accept_context = new (alloc)
|
||||||
Socket_fs::Context(listen_context->proto(), handle_fd);
|
Socket_fs::Context(listen_context->proto(), handle_fd);
|
||||||
} catch (New_socket_failed) { return Errno(EACCES); }
|
} catch (New_socket_failed) {
|
||||||
|
close(handle_fd);
|
||||||
|
return Errno(EACCES);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addr && addrlen) {
|
||||||
|
Socket_fs::Remote_functor func(*accept_context, false);
|
||||||
|
int ret = read_sockaddr_in(func, (sockaddr_in *)addr, addrlen);
|
||||||
|
if (ret == -1) {
|
||||||
|
Libc::Allocator alloc { };
|
||||||
|
destroy(alloc, accept_context);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
File_descriptor *accept_fd =
|
File_descriptor *accept_fd =
|
||||||
file_descriptor_allocator()->alloc(&plugin(), accept_context);
|
file_descriptor_allocator()->alloc(&plugin(), accept_context);
|
||||||
@ -571,12 +584,6 @@ extern "C" int socket_fs_accept(int libc_fd, sockaddr *addr, socklen_t *addrlen)
|
|||||||
/* inherit the O_NONBLOCK flag if set */
|
/* inherit the O_NONBLOCK flag if set */
|
||||||
accept_context->fd_flags(listen_context->fd_flags());
|
accept_context->fd_flags(listen_context->fd_flags());
|
||||||
|
|
||||||
if (addr && addrlen) {
|
|
||||||
Socket_fs::Remote_functor func(*accept_context, false);
|
|
||||||
int ret = read_sockaddr_in(func, (sockaddr_in *)addr, addrlen);
|
|
||||||
if (ret == -1) return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return accept_fd->libc_fd;
|
return accept_fd->libc_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user