aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libev/ev_poll.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-03-24 16:36:43 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-03-24 16:36:43 +0000
commit4610fcee939fb6646703285d2da3b47a111d58eb (patch)
tree6b01864ccea44b37e6efc2553691b9e9dc6a1fa8 /contrib/libev/ev_poll.c
parent47ecc8cf045b157ed8b7f9cc74ba08516ccc6164 (diff)
downloadrspamd-4610fcee939fb6646703285d2da3b47a111d58eb.tar.gz
rspamd-4610fcee939fb6646703285d2da3b47a111d58eb.zip
[Feature] Update libev to 4.33
Changelog: http://cvs.schmorp.de/libev/Changes?pathrev=rel-4_33
Diffstat (limited to 'contrib/libev/ev_poll.c')
-rw-r--r--contrib/libev/ev_poll.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/contrib/libev/ev_poll.c b/contrib/libev/ev_poll.c
index bd742b07f..e5508ddb0 100644
--- a/contrib/libev/ev_poll.c
+++ b/contrib/libev/ev_poll.c
@@ -1,7 +1,7 @@
/*
* libev poll fd activity backend
*
- * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
+ * Copyright (c) 2007,2008,2009,2010,2011,2016,2019 Marc Alexander Lehmann <libev@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
@@ -41,10 +41,12 @@
inline_size
void
-pollidx_init (int *base, int count)
+array_needsize_pollidx (int *base, int offset, int count)
{
- /* consider using memset (.., -1, ...), which is practically guaranteed
- * to work on all systems implementing poll */
+ /* using memset (.., -1, ...) is tempting, we we try
+ * to be ultraportable
+ */
+ base += offset;
while (count--)
*base++ = -1;
}
@@ -57,14 +59,14 @@ poll_modify (EV_P_ int fd, int oev, int nev)
if (oev == nev)
return;
- array_needsize (int, pollidxs, pollidxmax, fd + 1, pollidx_init);
+ array_needsize (int, pollidxs, pollidxmax, fd + 1, array_needsize_pollidx);
idx = pollidxs [fd];
if (idx < 0) /* need to allocate a new pollfd */
{
pollidxs [fd] = idx = pollcnt++;
- array_needsize (struct pollfd, polls, pollmax, pollcnt, EMPTY2);
+ array_needsize (struct pollfd, polls, pollmax, pollcnt, array_needsize_noinit);
polls [idx].fd = fd;
}
@@ -78,7 +80,7 @@ poll_modify (EV_P_ int fd, int oev, int nev)
{
pollidxs [fd] = -1;
- if (expect_true (idx < --pollcnt))
+ if (ecb_expect_true (idx < --pollcnt))
{
polls [idx] = polls [pollcnt];
pollidxs [polls [idx].fd] = idx;
@@ -93,10 +95,10 @@ poll_poll (EV_P_ ev_tstamp timeout)
int res;
EV_RELEASE_CB;
- res = poll (polls, pollcnt, timeout * 1e3);
+ res = poll (polls, pollcnt, EV_TS_TO_MSEC (timeout));
EV_ACQUIRE_CB;
- if (expect_false (res < 0))
+ if (ecb_expect_false (res < 0))
{
if (errno == EBADF)
fd_ebadf (EV_A);
@@ -108,14 +110,17 @@ poll_poll (EV_P_ ev_tstamp timeout)
else
for (p = polls; res; ++p)
{
- assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
+ assert (("libev: poll returned illegal result, broken BSD kernel?", p < polls + pollcnt));
- if (expect_false (p->revents)) /* this expect is debatable */
+ if (ecb_expect_false (p->revents)) /* this expect is debatable */
{
--res;
- if (expect_false (p->revents & POLLNVAL))
- fd_kill (EV_A_ p->fd);
+ if (ecb_expect_false (p->revents & POLLNVAL))
+ {
+ assert (("libev: poll found invalid fd in poll set", 0));
+ fd_kill (EV_A_ p->fd);
+ }
else
fd_event (
EV_A_
@@ -131,7 +136,7 @@ inline_size
int
poll_init (EV_P_ int flags)
{
- backend_mintime = 1e-3;
+ backend_mintime = EV_TS_CONST (1e-3);
backend_modify = poll_modify;
backend_poll = poll_poll;