mirror of
https://github.com/samba-team/samba.git
synced 2025-01-25 06:04:04 +03:00
s3: Add poll_one_fd()
This commit is contained in:
parent
cf7d331511
commit
deb58b2e94
@ -1333,6 +1333,7 @@ struct tevent_req *getaddrinfo_send(TALLOC_CTX *mem_ctx,
|
|||||||
const char *service,
|
const char *service,
|
||||||
const struct addrinfo *hints);
|
const struct addrinfo *hints);
|
||||||
int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res);
|
int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res);
|
||||||
|
int poll_one_fd(int fd, int events, int timeout, int *revents);
|
||||||
struct tevent_req *tstream_read_packet_send(TALLOC_CTX *mem_ctx,
|
struct tevent_req *tstream_read_packet_send(TALLOC_CTX *mem_ctx,
|
||||||
struct tevent_context *ev,
|
struct tevent_context *ev,
|
||||||
struct tstream_context *stream,
|
struct tstream_context *stream,
|
||||||
|
@ -1766,3 +1766,30 @@ int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res)
|
|||||||
}
|
}
|
||||||
return state->ret;
|
return state->ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int poll_one_fd(int fd, int events, int timeout, int *revents)
|
||||||
|
{
|
||||||
|
struct pollfd *fds;
|
||||||
|
int ret;
|
||||||
|
int saved_errno;
|
||||||
|
|
||||||
|
fds = TALLOC_ZERO_ARRAY(talloc_tos(), struct pollfd, 2);
|
||||||
|
if (fds == NULL) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
fds[0].fd = fd;
|
||||||
|
fds[0].events = events;
|
||||||
|
|
||||||
|
ret = sys_poll(fds, 1, timeout);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assign whatever poll did, even in the ret<=0 case.
|
||||||
|
*/
|
||||||
|
*revents = fds[0].revents;
|
||||||
|
saved_errno = errno;
|
||||||
|
TALLOC_FREE(fds);
|
||||||
|
errno = saved_errno;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user