mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Add O_NONBLOCK support to sockets.
This commit is contained in:
parent
1052f2c47a
commit
c514dda0b2
2 changed files with 3 additions and 3 deletions
|
@ -63,8 +63,7 @@ static const char* get_socket_factory(int domain, int type, int protocol)
|
|||
extern "C" int socket(int domain, int type, int protocol)
|
||||
{
|
||||
int open_flags = O_RDWR;
|
||||
// TODO: O_NONBLOCK is not supported!
|
||||
//if ( type & SOCK_NONBLOCK ) open_flags |= O_NONBLOCK;
|
||||
if ( type & SOCK_NONBLOCK ) open_flags |= O_NONBLOCK;
|
||||
if ( type & SOCK_CLOEXEC ) open_flags |= O_CLOEXEC;
|
||||
if ( type & SOCK_CLOFORK ) open_flags |= O_CLOFORK;
|
||||
type &= SOCK_TYPE_MASK;
|
||||
|
|
|
@ -630,7 +630,6 @@ static int sys_accept4(int fd, void* addr, size_t* addrlen, int flags)
|
|||
if ( !desc )
|
||||
return -1;
|
||||
int fdflags = 0;
|
||||
// TODO: Support SOCK_NONBLOCK
|
||||
if ( flags & SOCK_CLOEXEC ) fdflags |= FD_CLOEXEC;
|
||||
if ( flags & SOCK_CLOFORK ) fdflags |= FD_CLOFORK;
|
||||
flags &= ~(SOCK_CLOEXEC | SOCK_CLOFORK);
|
||||
|
@ -638,6 +637,8 @@ static int sys_accept4(int fd, void* addr, size_t* addrlen, int flags)
|
|||
Ref<Descriptor> conn = desc->accept(&ctx, (uint8_t*) addr, addrlen, flags);
|
||||
if ( !conn )
|
||||
return -1;
|
||||
if ( flags & SOCK_NONBLOCK )
|
||||
conn->SetFlags(conn->GetFlags() | O_NONBLOCK);
|
||||
return CurrentProcess()->GetDTable()->Allocate(conn, fdflags);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue