Skip to content

Commit 0897208

Browse files
committed
更新至4.27
1 parent e9eebd7 commit 0897208

12 files changed

+196
-59
lines changed

Changes

+6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
Revision history for libev, a high-performance and full-featured event loop.
22

3+
4.27 Thu Jun 27 22:43:44 CEST 2019
34
- linux aio backend almost complete rewritten to work around its
45
limitations.
56
- epoll backend now mandatory for linux aio backend.
7+
- fail assertions more aggressively on invalid fd's detected
8+
in the event loop, do not just silently fd_kill in case of
9+
user error.
10+
- ev_io_start/ev_io_stop now verify the watcher fd using
11+
a syscall when EV_VERIFY is 2 or higher.
612

713
4.26 (EV only)
814
- update to libecb 0x00010006.

config.h.in

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
/* Define to 1 if you have the `rt' library (-lrt). */
3131
#undef HAVE_LIBRT
3232

33+
/* Define to 1 if you have the <linux/aio_abi.h> header file. */
34+
#undef HAVE_LINUX_AIO_ABI_H
35+
3336
/* Define to 1 if you have the <memory.h> header file. */
3437
#undef HAVE_MEMORY_H
3538

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl also update ev.h!
2-
AC_INIT([libev], [4.25])
2+
AC_INIT([libev], [4.27])
33

44
orig_CFLAGS="$CFLAGS"
55

ev.3

+10-3
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,13 @@ it will print a diagnostic message and abort (via the \f(CW\*(C`assert\*(C'\fR m
293293
so \f(CW\*(C`NDEBUG\*(C'\fR will disable this checking): these are programming errors in
294294
the libev caller and need to be fixed there.
295295
.PP
296-
Libev also has a few internal error-checking \f(CW\*(C`assert\*(C'\fRions, and also has
297-
extensive consistency checking code. These do not trigger under normal
298-
circumstances, as they indicate either a bug in libev or worse.
296+
Via the \f(CW\*(C`EV_FREQUENT\*(C'\fR macro you can compile in and/or enable extensive
297+
consistency checking code inside libev that can be used to check for
298+
internal inconsistencies, suually caused by application bugs.
299+
.PP
300+
Libev also has a few internal error-checking \f(CW\*(C`assert\*(C'\fRions. These do not
301+
trigger under normal circumstances, as they indicate either a bug in libev
302+
or worse.
299303
.SH "GLOBAL FUNCTIONS"
300304
.IX Header "GLOBAL FUNCTIONS"
301305
These functions can be called anytime, even before initialising the
@@ -5084,6 +5088,9 @@ called once per loop, which can slow down libev. If set to \f(CW3\fR, then the
50845088
verification code will be called very frequently, which will slow down
50855089
libev considerably.
50865090
.Sp
5091+
Verification errors are reported via C's \f(CW\*(C`assert\*(C'\fR mechanism, so if you
5092+
disable that (e.g. by defining \f(CW\*(C`NDEBUG\*(C'\fR) then no errors will be reported.
5093+
.Sp
50875094
The default is \f(CW1\fR, unless \f(CW\*(C`EV_FEATURES\*(C'\fR overrides it, in which case it
50885095
will be \f(CW0\fR.
50895096
.IP "\s-1EV_COMMON\s0" 4

ev.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -3751,7 +3751,6 @@ ev_run (EV_P_ int flags)
37513751
ev_feed_event (EV_A_ &pipe_w, EV_CUSTOM);
37523752
}
37533753

3754-
37553754
/* update ev_rt_now, do magic */
37563755
time_update (EV_A_ waittime + sleeptime);
37573756
}
@@ -3925,6 +3924,9 @@ ev_io_start (EV_P_ ev_io *w) EV_NOEXCEPT
39253924
assert (("libev: ev_io_start called with negative fd", fd >= 0));
39263925
assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
39273926

3927+
#if EV_VERIFY >= 2
3928+
assert (("libev: ev_io_start called on watcher with invalid fd", fd_valid (fd)));
3929+
#endif
39283930
EV_FREQUENT_CHECK;
39293931

39303932
ev_start (EV_A_ (W)w, 1);
@@ -3950,6 +3952,9 @@ ev_io_stop (EV_P_ ev_io *w) EV_NOEXCEPT
39503952

39513953
assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
39523954

3955+
#if EV_VERIFY >= 2
3956+
assert (("libev: ev_io_stop called on watcher with invalid fd", fd_valid (w->fd)));
3957+
#endif
39533958
EV_FREQUENT_CHECK;
39543959

39553960
wlist_del (&anfds[w->fd].head, (WL)w);

ev.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ struct ev_loop;
212212
/*****************************************************************************/
213213

214214
#define EV_VERSION_MAJOR 4
215-
#define EV_VERSION_MINOR 26
215+
#define EV_VERSION_MINOR 27
216216

217217
/* eventmask, revents, events... */
218218
enum {

ev.pod

+10-3
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,13 @@ it will print a diagnostic message and abort (via the C<assert> mechanism,
161161
so C<NDEBUG> will disable this checking): these are programming errors in
162162
the libev caller and need to be fixed there.
163163

164-
Libev also has a few internal error-checking C<assert>ions, and also has
165-
extensive consistency checking code. These do not trigger under normal
166-
circumstances, as they indicate either a bug in libev or worse.
164+
Via the C<EV_FREQUENT> macro you can compile in and/or enable extensive
165+
consistency checking code inside libev that can be used to check for
166+
internal inconsistencies, suually caused by application bugs.
167+
168+
Libev also has a few internal error-checking C<assert>ions. These do not
169+
trigger under normal circumstances, as they indicate either a bug in libev
170+
or worse.
167171

168172

169173
=head1 GLOBAL FUNCTIONS
@@ -4975,6 +4979,9 @@ called once per loop, which can slow down libev. If set to C<3>, then the
49754979
verification code will be called very frequently, which will slow down
49764980
libev considerably.
49774981

4982+
Verification errors are reported via C's C<assert> mechanism, so if you
4983+
disable that (e.g. by defining C<NDEBUG>) then no errors will be reported.
4984+
49784985
The default is C<1>, unless C<EV_FEATURES> overrides it, in which case it
49794986
will be C<0>.
49804987

ev_epoll.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ epoll_modify (EV_P_ int fd, int oev, int nev)
130130

131131
return;
132132
}
133+
else
134+
assert (("libev: I/O watcher with invalid fd found in epoll_ctl", errno != EBADF && errno != ELOOP && errno != EINVAL));
133135

134136
fd_kill (EV_A_ fd);
135137

@@ -236,7 +238,7 @@ epoll_poll (EV_P_ ev_tstamp timeout)
236238
}
237239

238240
static int
239-
ev_epoll_create (void)
241+
epoll_epoll_create (void)
240242
{
241243
int fd;
242244

@@ -259,7 +261,7 @@ inline_size
259261
int
260262
epoll_init (EV_P_ int flags)
261263
{
262-
if ((backend_fd = ev_epoll_create ()) < 0)
264+
if ((backend_fd = epoll_epoll_create ()) < 0)
263265
return 0;
264266

265267
backend_mintime = 1e-3; /* epoll does sometimes return early, this is just to avoid the worst */
@@ -286,7 +288,7 @@ epoll_fork (EV_P)
286288
{
287289
close (backend_fd);
288290

289-
while ((backend_fd = ev_epoll_create ()) < 0)
291+
while ((backend_fd = epoll_epoll_create ()) < 0)
290292
ev_syserr ("(libev) epoll_create");
291293

292294
fd_rearm_all (EV_A);

ev_kqueue.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,16 @@ kqueue_poll (EV_P_ ev_tstamp timeout)
129129
if (fd_valid (fd))
130130
kqueue_modify (EV_A_ fd, 0, anfds [fd].events);
131131
else
132-
fd_kill (EV_A_ fd);
132+
{
133+
assert (("libev: kqueue found invalid fd", 0));
134+
fd_kill (EV_A_ fd);
135+
}
133136
}
134137
else /* on all other errors, we error out on the fd */
135-
fd_kill (EV_A_ fd);
138+
{
139+
assert (("libev: kqueue found invalid fd", 0));
140+
fd_kill (EV_A_ fd);
141+
}
136142
}
137143
}
138144
else

0 commit comments

Comments
 (0)