uloop: add a flag for keeping the socket blocking
This commit is contained in:
parent
869fc39f50
commit
cd086c7c15
2 changed files with 2 additions and 1 deletions
2
uloop.c
2
uloop.c
|
@ -236,7 +236,7 @@ int uloop_fd_add(struct uloop_fd *sock, unsigned int flags)
|
|||
unsigned int fl;
|
||||
int ret;
|
||||
|
||||
if (!sock->registered) {
|
||||
if (!sock->registered && !(flags & ULOOP_BLOCKING)) {
|
||||
fl = fcntl(sock->fd, F_GETFL, 0);
|
||||
fl |= O_NONBLOCK;
|
||||
fcntl(sock->fd, F_SETFL, fl);
|
||||
|
|
1
uloop.h
1
uloop.h
|
@ -39,6 +39,7 @@ typedef void (*uloop_timeout_handler)(struct uloop_timeout *t);
|
|||
#define ULOOP_READ (1 << 0)
|
||||
#define ULOOP_WRITE (1 << 1)
|
||||
#define ULOOP_EDGE_TRIGGER (1 << 2)
|
||||
#define ULOOP_BLOCKING (1 << 3)
|
||||
|
||||
struct uloop_fd
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue