18 Commits
Author SHA1 Message Date
Joachim Nilsson de89b6647d Update ChangeLog and bump ABI + release version for v2.1.3 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-06 22:03:16 +02:00
Joachim Nilsson 7eee63e5eb debian: The bare .so symlink should go in the -dev package [Policy]
Clarify rules: libuev.a and libuev.so are for initial linking.  See
Debian Policy sect. 8.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-06 22:02:56 +02:00
Joachim Nilsson c780b82929 Update ChangeLog for upcoming bug fix release v2.1.3
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-05 17:48:50 +02:00
Joachim Nilsson cccaabfad5 Don't call uev_timer_set() when stopping timer, just close() it
The semantics for timerfd in Linux is to use close() to stop,
so no need for the extra overhead with uev_timer_set().

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-04 21:22:33 +02:00
Joachim Nilsson 6d33c56d0f Return early and OK if signal watcher is already stopped
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-04 07:16:01 +02:00
Joachim Nilsson 6ae98d135c tests: Restart stopped timer before calling uev_exit()
There's an issue with uftpd not exiting properly.  Cannot nail it down
properly but it seems to be related to the stopping of active timers.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-04 07:11:23 +02:00
Joachim Nilsson d3e5900f73 Refactor, use LIST_FOREACH_SAFE() instead of while() in uev_exit()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-01 18:55:22 +02:00
Joachim Nilsson 2ff15101ae New API test to verify uev_exit() terminates properly
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-01 18:54:56 +02:00
Joachim Nilsson 04d9e1c80a Bump version for next bugfix release cycle
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-01 18:50:30 +02:00
Joachim Nilsson 0674fb8db4 Reminder to investigate for next release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-01 18:50:18 +02:00
Joachim Nilsson c4ac2eae5d Update example, use /dev/input/js0, the first joystick
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-05-31 23:37:39 +02:00
Joachim Nilsson 951f959549 Bump version for v2.1.2 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-02-27 00:08:54 +01:00
Joachim Nilsson a2900279f6 Update ChangeLog for v2.1.2 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-02-27 00:06:26 +01:00
Joachim Nilsson f9c9f24afb debian/: Fix minor packaging issues between base and -dev .debs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-02-27 00:05:45 +01:00
Joachim Nilsson ab05f71bbc Fix #17: Check for existence of AM_PROG_AR macro
This patch facilitates building newer versions of libuEv on systems with
older versions of autoconf and automake.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-02-26 22:30:44 +01:00
Joachim Nilsson 856546f4c7 Refactor, simplify
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-28 21:36:47 +01:00
Joachim Nilsson 748ebc998c Minor, whitespace
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-28 21:17:43 +01:00
Joachim Nilsson 0e97bfdc5a tests/: Return result of tests, not return value of uev_run()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-28 16:32:38 +01:00
18 changed files with 160 additions and 48 deletions

No files matched your search

+1 -1
View File
@@ -312,7 +312,7 @@ int main(void)
uev_t watcher;
uev_ctx_t ctx;
fd = open("/dev/input/js1", O_RDONLY, O_NONBLOCK);
fd = open("/dev/input/js0", O_RDONLY, O_NONBLOCK);
if (fd < 0)
errx(errno, "Cannot find a joystick attached.");
+33 -1
View File
@@ -3,6 +3,36 @@ Change Log
All notable changes to the project are documented in this file.
[v2.1.3][] - 2018-09-06
-----------------------
### Changes
- Update joystick example, use first device, `/dev/input/js0`
- Minor refactor of `uev_exit()`, use `_SAFE` macros to traverse
list of watchers instead of `while()`
- New API test to verify that `uev_exit()` terminates properly
- Make `uev_signal_stop()` idempotent
### Fixes
- Let `uev_timer_stop()` call `close()` on the timerfd directly, do not
call `uev_timer_set()` since that may cause lockups or hangs
[v2.1.2][] - 2018-02-27
-----------------------
### Changes
- Minor refactor of event loop after fixing the nasty use-after-free bug
in v2.1.1. Code can now be collapsed and noticeably simplified
### Fixes
- Issue #17: Check if `AM_PROG_AR` macro exists before calling it, fixes
problem building libuEv on systems with older autoconf + automake.
Patch by Markus Svilans
- Fix minor issue with unit tests, return result of test not event loop
[v2.1.1][] - 2018-01-28
-----------------------
@@ -336,7 +366,9 @@ v0.0.1 - 2012-03-17
Lua users mailing list.
[UNRELEASED]: https://github.com/troglobit/libuev/compare/v2.1.1...HEAD
[UNRELEASED]: https://github.com/troglobit/libuev/compare/v2.1.3...HEAD
[v2.1.3]: https://github.com/troglobit/libuev/compare/v2.1.2...v2.1.3
[v2.1.2]: https://github.com/troglobit/libuev/compare/v2.1.1...v2.1.2
[v2.1.1]: https://github.com/troglobit/libuev/compare/v2.1.0...v2.1.1
[v2.1.0]: https://github.com/troglobit/libuev/compare/v2.0.0...v2.1.0
[v2.0.0]: https://github.com/troglobit/libuev/compare/v1.6.0...v2.0.0
+2 -2
View File
@@ -1,4 +1,4 @@
AC_INIT(libuev, 2.1.1, https://github.com/troglobit/libuev/issues)
AC_INIT(libuev, 2.1.3, https://github.com/troglobit/libuev/issues)
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
AM_SILENT_RULES([yes])
@@ -8,7 +8,7 @@ AC_CONFIG_FILES([Makefile src/libuev.pc src/Makefile examples/Makefile tests/Mak
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC
AM_PROG_AR
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
LT_INIT
# Optional features
+21
View File
@@ -1,3 +1,24 @@
libuev (2.1.3) unstable; urgency=medium
* Minor bugfix release
- Updated joystick example, use first joystick, /dev/input/js0
- Use LIST_FOREACH_SAFE() instead of while() in uev_exit()
- New API test for uev_exit()
- Don't call uev_timer_set() when stopping a timer, may cause lockups
- Return OK immediately if a signal watcher is already stopped
* Packaging fixes: libuev.so symlink goes in -dev package
-- Joachim Nilsson <troglobit@gmail.com> Thu, 06 Sep 2018 22:01:24 +0200
libuev (2.1.2) unstable; urgency=medium
* Minor bugfix release
- Fix #17: build problem on systems with too old autoconf + automake
- Fix unit tests, return result of test not result of event loop
- Refactor/simplify/collapse main event loop code after fixes in v2.1.1
* Fix minor packaging issues
-- Joachim Nilsson <troglobit@gmail.com> Tue, 27 Feb 2018 00:05:32 +0100
libuev (2.1.1) unstable; urgency=medium
* Minor bugfix release
+3 -5
View File
@@ -1,6 +1,4 @@
usr/include/uev/uev.h
usr/include/uev/private.h
usr/include/uev/queue.h
usr/lib/*/lib*.a
usr/lib/*/lib*.so
usr/include/uev/*.h
usr/lib/*/libuev.a
usr/lib/*/libuev.so
usr/lib/*/pkgconfig/lib*.pc
+1 -1
View File
@@ -78,7 +78,7 @@ int main(void)
uev_t js1_watcher;
uev_ctx_t ctx;
fd = open("/dev/input/js1", O_RDONLY, O_NONBLOCK);
fd = open("/dev/input/js0", O_RDONLY, O_NONBLOCK);
if (fd < 0)
errx(errno, "Cannot find a joystick attached.");
+1 -1
View File
@@ -2,7 +2,7 @@ lib_LTLIBRARIES = libuev.la
libuev_la_SOURCES = uev.c io.c timer.c signal.c cron.c
libuev_la_CPPFLAGS = -D_GNU_SOURCE -D_TIME_BITS=64
libuev_la_CFLAGS = -W -Wall -Wextra
libuev_la_LDFLAGS = $(AM_LDFLAGS) -version-info 2:1:0
libuev_la_LDFLAGS = $(AM_LDFLAGS) -version-info 2:2:0
noinst_PROGRAMS = bench
bench_CPPFLAGS = -D_GNU_SOURCE
+3
View File
@@ -140,6 +140,9 @@ int uev_signal_start(uev_t *w)
*/
int uev_signal_stop(uev_t *w)
{
if (!_uev_watcher_active(w))
return 0;
if (_uev_watcher_stop(w))
return -1;
-5
View File
@@ -170,17 +170,12 @@ int uev_timer_start(uev_t *w)
*/
int uev_timer_stop(uev_t *w)
{
/* Check if already stopped in uev_run() after cb() or _init() */
if (!_uev_watcher_active(w))
return 0;
/* Stop kernel timer */
uev_timer_set(w, 0, 0);
if (_uev_watcher_stop(w))
return -1;
/* Close timerfd, will have to be reopened again on reset */
close(w->fd);
w->fd = -1;
+7 -11
View File
@@ -203,14 +203,14 @@ int uev_init(uev_ctx_t *ctx)
*/
int uev_exit(uev_ctx_t *ctx)
{
uev_t *w, *next;
if (!ctx) {
errno = EINVAL;
return -1;
}
while (!LIST_EMPTY(&ctx->watchers)) {
uev_t *w = LIST_FIRST(&ctx->watchers);
LIST_FOREACH_SAFE(w, &ctx->watchers, link, next) {
/* Remove from internal list */
LIST_REMOVE(w, link);
@@ -233,6 +233,7 @@ int uev_exit(uev_ctx_t *ctx)
}
}
LIST_INIT(&ctx->watchers);
ctx->running = 0;
close(ctx->fd);
ctx->fd = -1;
@@ -347,6 +348,8 @@ int uev_run(uev_ctx_t *ctx, int flags)
if (!w->u.t.period)
w->u.t.timeout = 0;
if (!w->u.t.timeout)
uev_timer_stop(w);
break;
case UEV_CRON_TYPE:
@@ -362,16 +365,9 @@ int uev_run(uev_ctx_t *ctx, int flags)
w->u.c.when = 0;
else
w->u.c.when += w->u.c.interval;
break;
}
if (UEV_CRON_TYPE == w->type) {
if (!w->u.c.when)
uev_timer_stop(w);
}
if (UEV_TIMER_TYPE == w->type) {
if (!w->u.t.timeout)
uev_timer_stop(w);
break;
}
/*
+1
View File
@@ -1,6 +1,7 @@
*.trs
*.log
active
api
complete
cronrun
signal
+1
View File
@@ -3,6 +3,7 @@ CLEANFILES = *~ *.trs *.log
TESTS =
TESTS += active
TESTS += api
TESTS += complete
TESTS += cronrun
TESTS += signal
+10
View File
@@ -30,6 +30,9 @@ static void cb(uev_t *w, void *UNUSED(arg), int events)
fail_unless(!uev_timer_active(&timer2));
fail_unless(!uev_cron_active(&cron2));
/* Restart timer and see if we fail in uev_exit() */
uev_timer_start(&timer2);
uev_exit(w->ctx);
}
@@ -52,3 +55,10 @@ int main(void)
return uev_run(&ctx, 0);
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+34
View File
@@ -0,0 +1,34 @@
#include "check.h"
uev_t timer, file;
int counter = 10;
static void cb(uev_t *w, void *UNUSED(arg), int events)
{
if (UEV_ERROR == events)
fprintf(stderr, "timer watcher failed, ignoring ...\n");
if (counter--)
return;
uev_exit(w->ctx);
}
int main(void)
{
uev_ctx_t ctx;
FILE *fp;
uev_init(&ctx);
uev_timer_init(&ctx, &timer, cb, NULL, 100, 100);
fp = fopen("/dev/one", "r");
if (fp)
uev_io_init(&ctx, &file, cb, NULL, fileno(fp), UEV_READ);
uev_run(&ctx, 0);
uev_exit(&ctx); /* Should not hang event loop, troglobit/uftpd#16 */
return 0;
}
+4 -4
View File
@@ -82,7 +82,7 @@ static void pipe_read_cb(uev_t *w, void UNUSED(*arg), int events)
return;
}
/* Kick watchdog */
/* Kick watchdog */
if (watchdog)
uev_timer_set(watchdog, 1000, 0);
@@ -112,9 +112,9 @@ static void pipe_write_cb(uev_t *w, void *arg, int UNUSED(events))
/* Here we *must* use out, not w->fd, since we're a timer callback */
if (write(out, msg, my->counter) < 0) {
perror("\nFailed writing to pipe");
return;
}
perror("\nFailed writing to pipe");
return;
}
// fprintf(stderr, "WRITE %.*s %d\n", my->counter, msg, my->counter);
fprintf(stderr, "%d ", my->counter);
+10 -3
View File
@@ -28,6 +28,7 @@
#define TIMEOUT 2
#define INTERVAL 2
int result = -1;
struct timeval tv;
static void cron_job(uev_t *w, void *UNUSED(arg), int events)
@@ -45,12 +46,15 @@ static void cron_job(uev_t *w, void *UNUSED(arg), int events)
printf("Cron job HELO %s", ctime(&now.tv_sec));
fail_unless(now.tv_sec == tv.tv_sec);
if (!laps--)
if (!laps--) {
result = 0;
uev_exit(w->ctx);
}
}
int main(void)
{
int rc;
uev_t cron_watcher;
uev_ctx_t ctx;
time_t when, interval;
@@ -62,11 +66,14 @@ int main(void)
printf("Start of test %s", ctime(&tv.tv_sec));
printf("Expected cron %s", ctime(&when));
interval = INTERVAL;
uev_cron_init(&ctx, &cron_watcher, cron_job, NULL, when, interval);
return uev_run(&ctx, 0);
rc = uev_run(&ctx, 0);
fail_unless(result == 0);
return rc;
}
/**
+13 -13
View File
@@ -63,7 +63,7 @@ static int callback(arg_t *arg, int event, void *foo)
printf("child: segfaulting failed!\n");
#endif
return 42;
return 42;
}
static void sigsegv_cb(uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events))
@@ -74,27 +74,27 @@ static void sigsegv_cb(uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events))
static void sigchld_cb(uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events))
{
pid_t pid = waitpid(-1, NULL, WNOHANG);
pid_t pid = waitpid(-1, NULL, WNOHANG);
if (-1 != pid)
warnx("PID %d exited, bye.", pid);
if (-1 != pid)
warnx("PID %d exited, bye.", pid);
}
static void work_cb(uev_t *UNUSED(w), void *arg, int UNUSED(events))
{
int status = 0;
pid_t pid;
pid_t pid;
pid = fork();
if (-1 == pid)
err(1, "fork");
pid = fork();
if (-1 == pid)
err(1, "fork");
if (!pid) {
status = callback(arg, 6137, NULL);
exit(status);
}
exit(status);
}
if (waitpid(pid, &status, 0) == -1)
err(1, "waitpid");
if (waitpid(pid, &status, 0) == -1)
err(1, "waitpid");
if (WIFEXITED(status))
printf("Child exited normally => %d\n", WEXITSTATUS(status));
@@ -108,7 +108,7 @@ static void work_cb(uev_t *UNUSED(w), void *arg, int UNUSED(events))
static void exit_cb(uev_t *w, void *UNUSED(arg), int UNUSED(events))
{
printf("Process deadline reached, exiting!\n");
printf("Process deadline reached, exiting!\n");
uev_exit(w->ctx);
}
+15 -1
View File
@@ -3,6 +3,8 @@
#include <sys/time.h>
#define TIMEOUT 2 /* 2 sec */
int result = -1;
struct timeval start;
static void cb(uev_t *w, void *UNUSED(arg), int events)
@@ -15,11 +17,13 @@ static void cb(uev_t *w, void *UNUSED(arg), int events)
gettimeofday(&now, NULL);
fail_unless(now.tv_sec == start.tv_sec + TIMEOUT);
result = 0;
uev_exit(w->ctx);
}
int main(void)
{
int rc;
uev_t w;
uev_ctx_t ctx;
@@ -27,5 +31,15 @@ int main(void)
uev_timer_init(&ctx, &w, cb, NULL, TIMEOUT * 1000, 0);
gettimeofday(&start, NULL);
return uev_run(&ctx, 0);
rc = uev_run(&ctx, 0);
fail_unless(result == 0);
return rc;
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/