Commit Graph
371 Commits
Author SHA1 Message Date
Joachim Nilsson dd651ae791 Call watcher callback as last action for watcher, may delete itself
A watcher callback may be a timeout callback, or similar, that deletes
itself and the watcher.  So we should not dereference anything in the
watcher after the callback.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-28 13:53:10 +01:00
Joachim Nilsson a528405258 Minor, whitespace
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-28 13:50:50 +01:00
Joachim Nilsson 70f04c10e1 Merge pull request #13 from tisyang/master
Fix example code of timer usage not alarm in README.md
2017-11-22 02:33:35 +01:00
tisyang e3dca8255d Fix example code of timer usage not alarm in README.md 2017-11-22 09:25:12 +08:00
Joachim Nilsson dbf8c0dae2 Doc: a timer must have a non-zero timeout value to be armed properly
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-19 11:29:19 +01:00
Joachim Nilsson f75b1d5080 debian/changelog: New upstream release, new .deb package
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 17:41:09 +01:00
Joachim Nilsson 7f16876932 Bump version for v2.1.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
v2.1.0
2017-11-14 13:47:22 +01:00
Joachim Nilsson d7451cadd7 Update ChangeLog for v2.1.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 13:47:00 +01:00
Joachim Nilsson 804218ba44 Travis-CI: Test build with both GCC and Clang (LLVM)
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 13:39:02 +01:00
Joachim Nilsson 4d1875e49c Update, file used by redirect example
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 13:31:47 +01:00
Joachim Nilsson 3b356222cb Travis-CI: Fix missing .sh extension to autogen script
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 13:14:21 +01:00
Joachim Nilsson 9ec5dff692 Travis-CI: Enable examples in both regular and Coverity runs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 13:03:28 +01:00
Joachim Nilsson e35c065d77 uev.c: Stop I/O watcher immediately on EPOLLERR or EPOLLHUP
No need to check fd with fcntl().  On EPOLLERR the descriptor has an
error condition that must bed ACK'ed by the callback.  On EPOLLHUP
we got a hang-up on the remote end, usually a stream or pipe, either
way the callback must ACK this too, regardless.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:56:39 +01:00
Joachim Nilsson 7d97b9f04a Bump version for v2.1.0 release cycle, pre-test
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:56:39 +01:00
Joachim Nilsson 9499052989 Update ChangeLog for upcoming v2.1.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:56:39 +01:00
Joachim Nilsson c77cee19e8 Bullet lists should not end with a period
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:56:39 +01:00
Joachim Nilsson fbcd200fd5 uev.h: Remind hardcore devs about checking common errors in callback
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:56:39 +01:00
Joachim Nilsson 84661a1b12 README: Mention error handling early, and point to API docs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:56:39 +01:00
Joachim Nilsson ed313a1422 Update API documentation, UEV_ERROR and UEV_HUP must be handled
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:56:39 +01:00
Joachim Nilsson 28e735fd81 configure: Add missing --enable-examples option, mentioned in docs
The `examples/` directory was never built.  The documentation however
indicated the existence of an `--enable-examples` option, which didn't
really exist.  This patch adds that option.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:56:39 +01:00
Joachim Nilsson 2bea4192db Handle UEV_HUP properly in examples and unit tests
If an I/O watcher callback fails to read(), returning zero, we check
events for UEV_HUP to detect EOF or socket remote end shutdown().

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:56:39 +01:00
Joachim Nilsson d52254b4ec Make sure to restart the I/O watcher on UEV_ERROR
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:17:41 +01:00
Joachim Nilsson ebb574136b Make sure to restart I/O watcher when event loop returns error
This patch adds UEV_ERROR handling to the test I/O watcher, restarting
the watcher properly.  Also, additional error handling to read(), which
was unchecked and failed when fuzzing the libc read() function.

We also take the opportunity to document the reasons for when using the
w->fd (watcher descriptor) and when *not* to in the test.  Even to the
author this was confusing and looked suspicious.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:17:41 +01:00
Joachim Nilsson d7485c59ec Fix logical error, read before set, found by Valgrind
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:17:41 +01:00
Joachim Nilsson 505a7214a8 tests: Add basic error handling to callbacks, for reference
Many users look at both examples *and* unit tests to learn how to use a
library.  We should pride ourselves in that we have not just working but
also correct and readable tests.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:17:41 +01:00
Joachim Nilsson 9df7cbfc52 uev_timer_stop(): Check if already stopped to prevent double close()
Both cron and regular timers were closed twice on uev_exit(), first
when iterating over all watchers, next after each cb() has run in
uev_run().  This patch adds a check if a watcher is active before
attempting to stop it (again).

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:17:41 +01:00
Joachim Nilsson 6cbeb057b8 uev_timer_init(): Mark fd as uninitialized on error
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:17:41 +01:00
Joachim Nilsson 853604a65a Reorder switch in same order as enum, +minor whitespace
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:17:37 +01:00
Joachim Nilsson 35a54ef75e Follow-up to 2f9cce9, handle I/O watchers similar to timer+signal
This patch is a follow-up to 2f9cce9, and a complete refactor of
fe8f3f1 which first introduced the EPOLLERR and EPOLLHUP handling.
Then mainly for managing errors and hangups on stream sockets.

Now, instead of trying to reopen the epoll() fd, and breaking out
hard from the event loop on catastrophic error,  we now delegate
I/O watcher EPOLLERR and EPOLLHUP to the watcher callback, just
like other watchers.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:16:23 +01:00
Joachim Nilsson 966f29c207 Refactor, multiple if() statements into a switch()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-13 17:01:55 +01:00
Joachim Nilsson 6bc1b88973 Refactor, main event loop cleanup and simplification
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-13 15:38:40 +01:00
Joachim Nilsson 7c86cc31f1 Reorder enum in order of first appearance in libuEv
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-13 15:02:06 +01:00
Joachim Nilsson d9f8caf0e8 Refactor 2f9cce9, stop timers and try to restart signal watchers
In 2f9cce9 the invalidate_watcher() function was introduced to stop
invalid timer/cron and signal watchers.  This patch refactors that
change to instead call the stop method for cron/timer and attempt to
restart failing signal watchers.

The cron/timer and signal watchers are quite different from regular
I/O watchers in that their internal "fd" is hidden from and not under
the control of the user, so we should try to handle them better.  For
the former two we cannot do much other than stop and call the user's
registered callback with UEV_ERROR, but for the latter we can at least
try to restart it.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-13 14:52:16 +01:00
Joachim Nilsson 3e5694cb76 Bump version for v2.0.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
v2.0.0
2017-11-11 16:46:34 +01:00
Joachim Nilsson f5806a28c0 Bump ABI, major change in how uev_run() and callbacks work
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 16:46:03 +01:00
Joachim Nilsson ef57250586 Change release target to run distcheck instead of dist
With distcheck we not only build the distribution files, but also runs
test suite and verifies that the resulting dist file(s) can be built.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 16:43:47 +01:00
Joachim Nilsson febace818b ChangeLog: Finishing touches for v2.0.0
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 16:41:46 +01:00
Joachim Nilsson 5496bf0931 Update debian/changelog for v2 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 16:41:18 +01:00
Joachim Nilsson cb93dd9c9d ChangeLog: Fix GIT diff URL
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 14:19:23 +01:00
Joachim Nilsson 341f7801fd Alert users of ABI breakage
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 14:17:49 +01:00
Joachim Nilsson dd475b5058 Move quote to API.md, need space to warn about ABI breakage in 2.0
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 14:17:49 +01:00
Joachim Nilsson 0a1a0ebffb Preparations for upcoming v2 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 14:17:49 +01:00
Joachim Nilsson 91bfe9faa7 Ignore global index files
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 13:59:55 +01:00
Joachim Nilsson ddfc1460eb redirect: Update example to handle new failure mode
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 13:59:05 +01:00
Joachim Nilsson 71e6d78fdc redirect: Use err.h functions for error handling
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 13:58:35 +01:00
Joachim Nilsson 5929295c37 Update joystick example with new failure mode
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-11 13:57:43 +01:00
Joachim Nilsson 412f04f413 API.md: Document uev_run() failure modes.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-10 23:41:17 +01:00
Joachim Nilsson f78348a92a uev_run(): Return unique error codes in case of actual error.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-10 23:40:49 +01:00
Joachim Nilsson d1f5062e79 Bump major version, for upcoming v2.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-10 22:26:03 +01:00
Joachim Nilsson 1037eed481 Minor simplification, result is never changed
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-10 22:25:12 +01:00