1
0
Fork 0
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:
Jonas 'Sortie' Termansen 2013-07-08 13:03:53 +02:00
parent 1052f2c47a
commit c514dda0b2
2 changed files with 3 additions and 3 deletions

View file

@ -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) extern "C" int socket(int domain, int type, int protocol)
{ {
int open_flags = O_RDWR; 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_CLOEXEC ) open_flags |= O_CLOEXEC;
if ( type & SOCK_CLOFORK ) open_flags |= O_CLOFORK; if ( type & SOCK_CLOFORK ) open_flags |= O_CLOFORK;
type &= SOCK_TYPE_MASK; type &= SOCK_TYPE_MASK;

View file

@ -630,7 +630,6 @@ static int sys_accept4(int fd, void* addr, size_t* addrlen, int flags)
if ( !desc ) if ( !desc )
return -1; return -1;
int fdflags = 0; int fdflags = 0;
// TODO: Support SOCK_NONBLOCK
if ( flags & SOCK_CLOEXEC ) fdflags |= FD_CLOEXEC; if ( flags & SOCK_CLOEXEC ) fdflags |= FD_CLOEXEC;
if ( flags & SOCK_CLOFORK ) fdflags |= FD_CLOFORK; if ( flags & SOCK_CLOFORK ) fdflags |= FD_CLOFORK;
flags &= ~(SOCK_CLOEXEC | SOCK_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); Ref<Descriptor> conn = desc->accept(&ctx, (uint8_t*) addr, addrlen, flags);
if ( !conn ) if ( !conn )
return -1; return -1;
if ( flags & SOCK_NONBLOCK )
conn->SetFlags(conn->GetFlags() | O_NONBLOCK);
return CurrentProcess()->GetDTable()->Allocate(conn, fdflags); return CurrentProcess()->GetDTable()->Allocate(conn, fdflags);
} }