Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e2f32d05 authored by Dmitry Shmidt's avatar Dmitry Shmidt
Browse files

libnl: Add nl_socket_set_nonblocking() function



Change-Id: I80fad954f588baf1af216ca6fe659d295233bbe5
Signed-off-by: default avatarDmitry Shmidt <dimitrysh@google.com>
parent fd4d0de5
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <malloc.h>
#include <sys/time.h>
#include <sys/socket.h>
@@ -139,3 +140,14 @@ struct nl_cb *nl_socket_get_cb(struct nl_sock *sk)
{
	return nl_cb_get(sk->s_cb);
}

int nl_socket_set_nonblocking(struct nl_sock *sk)
{
	if (sk->s_fd == -1)
		return -NLE_BAD_SOCK;

	if (fcntl(sk->s_fd, F_SETFL, O_NONBLOCK) < 0)
		return -errno;

	return 0;
}