libnl: Add nl_socket_set_nonblocking() function

Change-Id: I80fad954f588baf1af216ca6fe659d295233bbe5
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
This commit is contained in:
Dmitry Shmidt 2013-10-28 17:55:16 -07:00
parent fd4d0de575
commit e2f32d05e6
1 changed files with 12 additions and 0 deletions

View File

@ -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;
}