mirror of
https://github.com/troglobit/libuev.git
synced 2026-11-17 19:31:18 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5841413e2 | ||
|
|
be89142b39 | ||
|
|
aedc189672 | ||
|
|
0b5461d5ff | ||
|
|
397247d567 | ||
|
|
28643fa599 | ||
|
|
09d9b6ba04 | ||
|
|
354cdcaf7a | ||
|
|
05bc6a0830 | ||
|
|
4792b988a1 | ||
|
|
ae28276f3f | ||
|
|
e699cb7f5f | ||
|
|
fbe2c15377 | ||
|
|
c964bbe8fb | ||
|
|
faf7667012 | ||
|
|
332f28e5e1 | ||
|
|
d3c021af42 | ||
|
|
0f59096154 | ||
|
|
d67290c073 | ||
|
|
c23100c3f0 | ||
|
|
ff2396b973 | ||
|
|
70ef23b9e3 | ||
|
|
568fe6a9e1 | ||
|
|
ae048605db | ||
|
|
2d9f1c9ce6 | ||
|
|
f9c72a01c8 | ||
|
|
270e270591 | ||
|
|
3c3b37c9aa | ||
|
|
0c92a564d8 | ||
|
|
53eadaa1c9 | ||
|
|
9591ac7efb |
No files matched your search
@@ -0,0 +1,12 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
libuEv is a small project, as such we have no possibility to support older versions.
|
||||
The only supported version is the latest released on GitHub:
|
||||
|
||||
<https://github.com/troglobit/libuev/releases>
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Contact the project's main author and owner to report and discuss vulnerabilities.
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install tree doxygen
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: Configure
|
||||
run: |
|
||||
./autogen.sh
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
run: |
|
||||
make check || (cat test/test-suite.log; false)
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: libuev-test-${{ matrix.compiler }}
|
||||
path: test/*
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: debian:stable
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: Installing dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
coverity:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: Fetch latest Coverity Scan MD5
|
||||
id: var
|
||||
env:
|
||||
@@ -24,10 +24,8 @@ jobs:
|
||||
wget -q https://scan.coverity.com/download/cxx/linux64 \
|
||||
--post-data "token=$TOKEN&project=${COVERITY_PROJ}&md5=1" \
|
||||
-O coverity-latest.tar.gz.md5
|
||||
export MD5=$(cat coverity-latest.tar.gz.md5)
|
||||
echo "Got MD5 $MD5"
|
||||
echo ::set-output name=md5::${MD5}
|
||||
- uses: actions/cache@v2
|
||||
echo "md5=$(cat coverity-latest.tar.gz.md5)" | tee -a $GITHUB_OUTPUT
|
||||
- uses: actions/cache@v4
|
||||
id: cache
|
||||
with:
|
||||
path: coverity-latest.tar.gz
|
||||
@@ -50,10 +48,6 @@ jobs:
|
||||
fi
|
||||
mkdir coverity
|
||||
tar xzf coverity-latest.tar.gz --strip 1 -C coverity
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install pkg-config libsystemd-dev libcap-dev
|
||||
- name: Configure
|
||||
run: |
|
||||
./autogen.sh
|
||||
@@ -76,7 +70,7 @@ jobs:
|
||||
--form description="${PROJECT_NAME} $(git rev-parse HEAD)" \
|
||||
https://scan.coverity.com/builds?project=${COVERITY_PROJ}
|
||||
- name: Upload build.log
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverity-build.log
|
||||
path: cov-int/build-log.txt
|
||||
@@ -7,42 +7,32 @@ on:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Create GitHub release
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
outputs:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
release_id: ${{ steps.create_release.outputs.id }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Extract ChangeLog entry ...
|
||||
# Hack to extract latest entry for body_path below
|
||||
run: |
|
||||
awk '/-----*/{if (x == 1) exit; x=1;next}x' ChangeLog.md \
|
||||
|head -n -1 > release.md
|
||||
cat release.md
|
||||
- name: Create release ...
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: libuEv ${{ github.ref }}
|
||||
body_path: release.md
|
||||
draft: false
|
||||
prerelease: false
|
||||
tarball:
|
||||
name: Build and upload release tarball
|
||||
needs: release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
MAKEFLAGS: -j3
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: Installing dependencies ...
|
||||
run: |
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install tree doxygen
|
||||
- name: Setting release variables ...
|
||||
id: build
|
||||
run: |
|
||||
ver=${GITHUB_REF#refs/tags/}
|
||||
echo "ver=${ver}" >> $GITHUB_OUTPUT
|
||||
if echo $ver | grep -qE '^[0-9]+\.[0-9]+(\.[0-9]+)?(-alpha|-beta|-rc)[0-9]*$'; then
|
||||
echo "pre=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "pre=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
if echo $ver | grep -qE '^[0-9.]+\.[0-9.]+(\.[0-9]+)?$'; then
|
||||
echo "latest=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "latest=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- name: Creating Makefiles ...
|
||||
run: |
|
||||
./autogen.sh
|
||||
@@ -53,10 +43,15 @@ jobs:
|
||||
ls -lF ../
|
||||
mkdir -p artifacts/
|
||||
mv ../*.tar.* artifacts/
|
||||
- name: Upload release artifacts ...
|
||||
uses: skx/github-action-publish-binaries@release-0.15
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Extract ChangeLog entry ...
|
||||
run: |
|
||||
awk '/-----*/{if (x == 1) exit; x=1;next}x' ChangeLog.md \
|
||||
|head -n -1 > release.md
|
||||
cat release.md
|
||||
- uses: ncipollo/release-action@v1
|
||||
with:
|
||||
releaseId: ${{ needs.release.outputs.release_id }}
|
||||
args: artifacts/*
|
||||
name: libuEv ${{ github.ref_name }}
|
||||
prerelease: ${{ steps.build.outputs.pre }}
|
||||
makeLatest: ${{ steps.build.outputs.latest }}
|
||||
bodyFile: "release.md"
|
||||
artifacts: "artifacts/*"
|
||||
+43
-1
@@ -4,6 +4,47 @@ Change Log
|
||||
All notable changes to the project are documented in this file.
|
||||
|
||||
|
||||
[UNRELEASED][]
|
||||
--------------
|
||||
|
||||
### Changes
|
||||
- Timers now keep their deadline between calls to `uev_run()`, they are
|
||||
only started by the first call. Previously every call restarted all
|
||||
timers, so with `UEV_ONCE` in a busy loop they never expired. Use
|
||||
`uev_timer_set()` to restart a timer for each call
|
||||
- `uev_run()` with only `UEV_NONBLOCK` now returns when no event is
|
||||
pending, previously it never returned and used 100% CPU
|
||||
- A cron watcher with start time zero now runs when the event loop is
|
||||
started, as documented, previously it never ran. This means that
|
||||
`uev_cron_set(w, 0, 0)` no longer disarms a cron watcher, it runs it
|
||||
now. Use `uev_cron_stop()` to stop it
|
||||
|
||||
### Fixes
|
||||
- Fix `uev_io_set()` ignoring a new file descriptor, or new events, for
|
||||
an active `UEV_ONESHOT` watcher
|
||||
- Fix `uev_run()` with `UEV_ONCE` not returning until end of file when
|
||||
stdin is redirected from a regular file
|
||||
- Fix `uev_cron_start()` restarting a stopped cron watcher as a regular
|
||||
timer, with the wrong timeout
|
||||
- Fix file descriptor leak in `uev_event_init()` when the watcher cannot
|
||||
be added to the event loop
|
||||
- Fix `uev_exit()` closing stdin after a failed `uev_init()`
|
||||
- Fix NULL pointer dereference in `uev_timer_init()` when called without
|
||||
a watcher
|
||||
- Fix `uev_cron_init()` and `uev_signal_init()` leaving a closed file
|
||||
descriptor in the watcher on failure
|
||||
|
||||
|
||||
[v2.4.1][] - 2024-01-04
|
||||
-----------------------
|
||||
|
||||
### Changes
|
||||
- Update README with list of moden Linux APIs used
|
||||
|
||||
### Fixes
|
||||
- Fix #27: possible buffer overrun in `uev_run()`, found by Steve Palmer
|
||||
|
||||
|
||||
[v2.4.0][] - 2021-10-03
|
||||
-----------------------
|
||||
|
||||
@@ -443,7 +484,8 @@ v0.0.1 - 2012-03-17
|
||||
Lua users mailing list.
|
||||
|
||||
|
||||
[UNRELEASED]: https://github.com/troglobit/libuev/compare/v2.4.0...HEAD
|
||||
[UNRELEASED]: https://github.com/troglobit/libuev/compare/v2.4.1...HEAD
|
||||
[v2.4.1]: https://github.com/troglobit/libuev/compare/v2.4.0...v2.4.1
|
||||
[v2.4.0]: https://github.com/troglobit/libuev/compare/v2.3.2...v2.4.0
|
||||
[v2.3.2]: https://github.com/troglobit/libuev/compare/v2.3.1...v2.3.2
|
||||
[v2.3.1]: https://github.com/troglobit/libuev/compare/v2.3.0...v2.3.1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
Copyright (c) 2013-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -25,6 +25,13 @@ of APIs. It is similar to the more established [libevent][], [libev][]
|
||||
and the venerable [Xt(3)][] event loop. The *µ* in the name refers to
|
||||
both its limited feature set and the size impact of the library.
|
||||
|
||||
Linux APIs supported and wrapped for ease-of-use:
|
||||
|
||||
- `epoll(2)`
|
||||
- `eventfd(2)`
|
||||
- `signalfd(2)`
|
||||
- `timerfd(2)`
|
||||
|
||||
Failure mode changes introduced in v2.0 may affect users of v1.x, See
|
||||
the [ChangeLog][] for the full details.
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
AC_INIT(libuev, 2.4.0, https://github.com/troglobit/libuev/issues)
|
||||
AC_INIT(libuev, 2.5.0-dev, https://github.com/troglobit/libuev/issues)
|
||||
AC_CONFIG_AUX_DIR(aux)
|
||||
AM_INIT_AUTOMAKE([1.11 foreign dist-xz])
|
||||
AM_SILENT_RULES([yes])
|
||||
|
||||
Vendored
+7
-6
@@ -2,7 +2,8 @@ Source: libuev
|
||||
Section: libs
|
||||
Priority: optional
|
||||
Maintainer: Joachim Wiberg <troglobit@gmail.com>
|
||||
Build-Depends: debhelper (>= 10), libtool
|
||||
Build-Depends: debhelper (>= 10)
|
||||
Build-Depends-Indep: doxygen
|
||||
Standards-Version: 4.3.0
|
||||
Homepage: https://github.com/troglobit/libuev/
|
||||
Vcs-Browser: https://github.com/troglobit/libuev/
|
||||
@@ -12,7 +13,7 @@ Package: libuev-dev
|
||||
Priority: optional
|
||||
Section: libdevel
|
||||
Architecture: any
|
||||
Depends: ${misc:Depends}, libuev2 (= ${binary:Version})
|
||||
Depends: ${misc:Depends}, libuev3 (= ${binary:Version})
|
||||
Description: static library, header files, and docs for libuev
|
||||
Static library, header files, and documentation for libuEv
|
||||
.
|
||||
@@ -24,10 +25,10 @@ Description: static library, header files, and docs for libuev
|
||||
Experienced developers may appreciate libuEv is built on top of modern
|
||||
Linux APIs like epoll, eventfd, timerf, and signalfd.
|
||||
|
||||
Package: libuev2
|
||||
Replaces: libuev
|
||||
Conflicts: libuev
|
||||
Provides: libuev
|
||||
Package: libuev3
|
||||
Replaces: libuev, libuev2
|
||||
Conflicts: libuev, libuev2
|
||||
Provides: libuev, libuev2
|
||||
Architecture: any
|
||||
Depends: ${misc:Depends}, ${shlibs:Depends}
|
||||
Description: Lightweight event loop library for Linux
|
||||
|
||||
Vendored
+1
-1
@@ -14,7 +14,7 @@ Copyright: 2016-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
|
||||
License: MIT
|
||||
Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
Copyright (c) 2013-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
File renamed without changes.
File renamed without changes.
+2
-2
@@ -1,5 +1,5 @@
|
||||
libuev.so.2 libuev2 #MINVER#
|
||||
* Build-Depends-Package: libite-dev
|
||||
libuev.so.3 libuev3 #MINVER#
|
||||
* Build-Depends-Package: libuev-dev
|
||||
_uev_watcher_active@Base 2.3.0
|
||||
_uev_watcher_init@Base 2.3.0
|
||||
_uev_watcher_rearm@Base 2.3.0
|
||||
+5
-2
@@ -168,8 +168,11 @@ result = uev_run(&ctx, UEV_NONE);
|
||||
```
|
||||
|
||||
With `flags` set to `UEV_ONCE` the event loop returns as soon as it has
|
||||
served the first event. If `flags` is set to `UEV_ONCE | UEV_NONBLOCK`
|
||||
the event loop returns immediately if no event is available.
|
||||
served the first event. With `UEV_NONBLOCK` the event loop returns as
|
||||
soon as no event is available, also when combined with `UEV_ONCE`.
|
||||
|
||||
Timers are started by the first call to `uev_run()` and keep their
|
||||
deadline between calls. Use `uev_timer_set()` to restart a timer.
|
||||
|
||||
```
|
||||
if (result < 0)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Simple example of how to use libuEv with Linux joystick API
|
||||
*
|
||||
* Copyright (c) 2014-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
* Copyright (c) 2014-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+25
-7
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <errno.h>
|
||||
#include <string.h> /* memset() */
|
||||
#include <sys/timerfd.h>
|
||||
#include <time.h> /* time() */
|
||||
#include <unistd.h> /* close(), read() */
|
||||
|
||||
#include "uev.h"
|
||||
@@ -67,6 +68,11 @@ int uev_cron_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, time_t when
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (!w || !ctx) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (when < 0 || interval < 0) {
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
@@ -83,6 +89,7 @@ int uev_cron_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, time_t when
|
||||
_uev_watcher_stop(w);
|
||||
exit:
|
||||
close(fd);
|
||||
w->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -92,9 +99,12 @@ int uev_cron_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, time_t when
|
||||
/**
|
||||
* Reset an at/cron job watcher
|
||||
* @param w Watcher to reset
|
||||
* @param when First point in time to call @p cb
|
||||
* @param when First point in time to call @p cb, zero for 'now'
|
||||
* @param interval For an at job this is zero, for cron the offset interval
|
||||
*
|
||||
* Note, unlike uev_timer_set() a @p when of zero does not disarm the
|
||||
* watcher, use uev_cron_stop() for that.
|
||||
*
|
||||
* @return POSIX OK(0) or non-zero with @p errno set on error.
|
||||
*/
|
||||
int uev_cron_set(uev_t *w, time_t when, time_t interval)
|
||||
@@ -110,12 +120,12 @@ int uev_cron_set(uev_t *w, time_t when, time_t interval)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Zero is 'now', when the event loop is started */
|
||||
if (!when && w->ctx->running)
|
||||
when = time(NULL);
|
||||
|
||||
/* Handle stopped timers */
|
||||
if (w->fd < 0) {
|
||||
/* Timer already stopped */
|
||||
if (!when && !interval)
|
||||
return 0;
|
||||
|
||||
if (uev_cron_init(w->ctx, w, (uev_cb_t *)w->cb, w->arg, when, interval))
|
||||
return -1;
|
||||
}
|
||||
@@ -144,7 +154,15 @@ int uev_cron_set(uev_t *w, time_t when, time_t interval)
|
||||
*/
|
||||
int uev_cron_start(uev_t *w)
|
||||
{
|
||||
return uev_timer_start(w);
|
||||
if (!w) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (-1 != w->fd)
|
||||
_uev_watcher_stop(w);
|
||||
|
||||
return uev_cron_set(w, w->u.c.when, w->u.c.interval);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+9
-3
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -57,8 +57,14 @@ int uev_event_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg)
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
return _uev_watcher_init(ctx, w, UEV_EVENT_TYPE, cb, arg, fd, UEV_READ)
|
||||
|| _uev_watcher_start(w);
|
||||
if (_uev_watcher_init(ctx, w, UEV_EVENT_TYPE, cb, arg, fd, UEV_READ) ||
|
||||
_uev_watcher_start(w)) {
|
||||
close(fd);
|
||||
w->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -64,7 +64,8 @@ int uev_io_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int fd, int e
|
||||
*/
|
||||
int uev_io_set(uev_t *w, int fd, int events)
|
||||
{
|
||||
if ((events & UEV_ONESHOT) && _uev_watcher_active(w))
|
||||
if ((events & UEV_ONESHOT) && _uev_watcher_active(w) &&
|
||||
fd == w->fd && events == w->events)
|
||||
return _uev_watcher_rearm(w);
|
||||
|
||||
/* Ignore any errors, only to clean up anything lingering ... */
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Private methods and data types, do not use directly!
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+2
-1
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -72,6 +72,7 @@ int uev_signal_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int signo
|
||||
_uev_watcher_stop(w);
|
||||
exit:
|
||||
close(fd);
|
||||
w->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
+8
-3
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -68,8 +68,8 @@ static void msec2tspec(int msec, struct timespec *ts)
|
||||
* period and restarted.
|
||||
*
|
||||
* A timer is automatically started if the event loop is already
|
||||
* running, otherwise it is kept on hold until triggered by calling
|
||||
* uev_run().
|
||||
* running, otherwise it is kept on hold until triggered by the first
|
||||
* call to uev_run().
|
||||
*
|
||||
* @see uev_timer_set
|
||||
* @return POSIX OK(0) or non-zero with @p errno set on error.
|
||||
@@ -78,6 +78,11 @@ int uev_timer_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int timeou
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (!w || !ctx) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (timeout < 0 || period < 0) {
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -196,11 +196,11 @@ int uev_init(uev_ctx_t *ctx)
|
||||
/**
|
||||
* Create an event loop context
|
||||
* @param ctx Pointer to an uev_ctx_t context to be initialized
|
||||
* @param maxevents Maximum number of events in event cache
|
||||
* @param maxevents Maximum number of events in event cache [1, 10]
|
||||
*
|
||||
* This function is the same as uev_init() except for the @p maxevents
|
||||
* argument, which controls the number of events in the event cache
|
||||
* returned to the main loop.
|
||||
* argument, max ::UEV_MAX_EVENTS, which controls the number of events
|
||||
* in the event cache returned to the main loop.
|
||||
*
|
||||
* In cases where you have multiple events pending in the cache and some
|
||||
* event may cause later ones, already sent by the kernel to userspace,
|
||||
@@ -222,7 +222,11 @@ int uev_init1(uev_ctx_t *ctx, int maxevents)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (maxevents > UEV_MAX_EVENTS)
|
||||
maxevents = UEV_MAX_EVENTS;
|
||||
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
ctx->fd = -1;
|
||||
ctx->maxevents = maxevents;
|
||||
|
||||
return _init(ctx, 0);
|
||||
@@ -286,17 +290,20 @@ int uev_exit(uev_ctx_t *ctx)
|
||||
*
|
||||
* With @p flags set to ::UEV_ONCE the event loop returns after the first
|
||||
* event has been served, useful for instance to set a timeout on a file
|
||||
* descriptor. If @p flags also has the ::UEV_NONBLOCK flag set the event
|
||||
* loop will return immediately if no event is pending, useful when run
|
||||
* inside another event loop.
|
||||
* descriptor. With the ::UEV_NONBLOCK flag set the event loop returns
|
||||
* as soon as no event is pending, useful when run inside another event
|
||||
* loop.
|
||||
*
|
||||
* Timers are started by the first call and keep their deadline between
|
||||
* calls. Use uev_timer_set() to restart a timer.
|
||||
*
|
||||
* @return POSIX OK(0) upon successful termination of the event loop, or
|
||||
* non-zero on error.
|
||||
*/
|
||||
int uev_run(uev_ctx_t *ctx, int flags)
|
||||
{
|
||||
uev_t *w;
|
||||
int timeout = -1;
|
||||
uev_t *w;
|
||||
|
||||
if (!ctx || ctx->fd < 0) {
|
||||
errno = EINVAL;
|
||||
@@ -306,21 +313,26 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
||||
if (flags & UEV_NONBLOCK)
|
||||
timeout = 0;
|
||||
|
||||
/* Start the event loop */
|
||||
/* Start the event loop and all dormant timers, first call only */
|
||||
if (!ctx->running) {
|
||||
ctx->running = 1;
|
||||
|
||||
/* Start all dormant timers */
|
||||
_UEV_FOREACH(w, ctx->watchers) {
|
||||
if (UEV_CRON_TYPE == w->type)
|
||||
uev_cron_set(w, w->u.c.when, w->u.c.interval);
|
||||
if (UEV_TIMER_TYPE == w->type)
|
||||
uev_timer_set(w, w->u.t.timeout, w->u.t.period);
|
||||
}
|
||||
}
|
||||
|
||||
while (ctx->running && ctx->watchers) {
|
||||
struct epoll_event ee[UEV_MAX_EVENTS];
|
||||
int maxevents = ctx->maxevents;
|
||||
int i, nfds, rerun = 0;
|
||||
|
||||
if (maxevents > UEV_MAX_EVENTS)
|
||||
maxevents = UEV_MAX_EVENTS;
|
||||
|
||||
/* Handle special case: `application < file.txt` */
|
||||
if (ctx->workaround) {
|
||||
_UEV_FOREACH(w, ctx->watchers) {
|
||||
@@ -337,11 +349,14 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
if (rerun)
|
||||
if (rerun) {
|
||||
if (flags & UEV_ONCE)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
ctx->workaround = 0;
|
||||
|
||||
while ((nfds = epoll_wait(ctx->fd, ee, ctx->maxevents, timeout)) < 0) {
|
||||
while ((nfds = epoll_wait(ctx->fd, ee, maxevents, timeout)) < 0) {
|
||||
if (!ctx->running)
|
||||
break;
|
||||
|
||||
@@ -354,11 +369,14 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (!nfds && (flags & UEV_NONBLOCK))
|
||||
break;
|
||||
|
||||
for (i = 0; ctx->running && i < nfds; i++) {
|
||||
struct signalfd_siginfo fdsi;
|
||||
ssize_t sz = sizeof(fdsi);
|
||||
uint32_t events;
|
||||
uint64_t exp;
|
||||
ssize_t sz = sizeof(fdsi);
|
||||
|
||||
w = (uev_t *)ee[i].data.ptr;
|
||||
events = ee[i].events;
|
||||
@@ -402,11 +420,9 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
||||
}
|
||||
|
||||
if (!w->u.c.interval)
|
||||
w->u.c.when = 0;
|
||||
uev_timer_stop(w);
|
||||
else
|
||||
w->u.c.when += w->u.c.interval;
|
||||
if (!w->u.c.when)
|
||||
uev_timer_stop(w);
|
||||
break;
|
||||
|
||||
case UEV_EVENT_TYPE:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -3,7 +3,14 @@
|
||||
active
|
||||
api
|
||||
complete
|
||||
cronnow
|
||||
cronrun
|
||||
cronstart
|
||||
error
|
||||
io
|
||||
nonblock
|
||||
resume
|
||||
signal
|
||||
stdin
|
||||
timer
|
||||
event
|
||||
@@ -8,8 +8,15 @@ TESTS =
|
||||
TESTS += active
|
||||
TESTS += api
|
||||
TESTS += complete
|
||||
TESTS += cronnow
|
||||
TESTS += cronrun
|
||||
TESTS += cronstart
|
||||
TESTS += error
|
||||
TESTS += io
|
||||
TESTS += nonblock
|
||||
TESTS += resume
|
||||
TESTS += signal
|
||||
TESTS += stdin
|
||||
TESTS += timer
|
||||
TESTS += event
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Test libuEv event library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/* Verifies that a cron watcher with start time zero runs now */
|
||||
#include "check.h"
|
||||
|
||||
static int fired;
|
||||
|
||||
static void cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
fired++;
|
||||
uev_exit(w->ctx);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uev_ctx_t ctx;
|
||||
uev_t w;
|
||||
|
||||
fail_unless(uev_init(&ctx) == 0);
|
||||
fail_unless(uev_cron_init(&ctx, &w, cb, NULL, 0, 0) == 0);
|
||||
|
||||
alarm(2);
|
||||
fail_unless(uev_run(&ctx, 0) == 0);
|
||||
fail_unless(fired == 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Test cron API in libuEv event library
|
||||
*
|
||||
* Copyright (c) 2016-2021 Joachim Wiberg <troglobit()gmail!com>
|
||||
* Copyright (c) 2016-2024 Joachim Wiberg <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/* Verifies that a stopped cron watcher can be started again */
|
||||
#include "check.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
time_t when = time(NULL) + 3600;
|
||||
uev_ctx_t ctx;
|
||||
uev_t cron;
|
||||
|
||||
fail_unless(uev_init(&ctx) == 0);
|
||||
fail_unless(uev_cron_init(&ctx, &cron, NULL, NULL, when, 3600) == 0);
|
||||
fail_unless(uev_cron_stop(&cron) == 0);
|
||||
fail_unless(!uev_cron_active(&cron));
|
||||
|
||||
fail_unless(uev_cron_start(&cron) == 0);
|
||||
fail_unless(uev_cron_active(&cron));
|
||||
fail_unless(cron.type == UEV_CRON_TYPE);
|
||||
fail_unless(cron.u.c.when == when);
|
||||
fail_unless(cron.u.c.interval == 3600);
|
||||
|
||||
return uev_exit(&ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,87 @@
|
||||
/* Verifies cleanup on failure to set up a context or watcher */
|
||||
#include "check.h"
|
||||
#include <signal.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
/* A failed uev_event_init() must not leak its eventfd */
|
||||
static void event_init(void)
|
||||
{
|
||||
uev_ctx_t ctx;
|
||||
uev_t w;
|
||||
int fd;
|
||||
|
||||
fail_unless(uev_init(&ctx) == 0);
|
||||
fail_unless(close(ctx.fd) == 0);
|
||||
|
||||
fd = dup(STDIN_FILENO);
|
||||
fail_unless(fd >= 0);
|
||||
close(fd);
|
||||
|
||||
fail_unless(uev_event_init(&ctx, &w, NULL, NULL) != 0);
|
||||
fail_unless(w.fd == -1);
|
||||
fail_unless(dup(STDIN_FILENO) == fd);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
/* A failed uev_init() must not leave stdin as the context descriptor */
|
||||
static void ctx_init(void)
|
||||
{
|
||||
struct rlimit old, lim;
|
||||
uev_ctx_t ctx;
|
||||
int rc;
|
||||
|
||||
fail_unless(getrlimit(RLIMIT_NOFILE, &old) == 0);
|
||||
lim = old;
|
||||
lim.rlim_cur = 0;
|
||||
fail_unless(setrlimit(RLIMIT_NOFILE, &lim) == 0);
|
||||
|
||||
rc = uev_init(&ctx);
|
||||
|
||||
fail_unless(setrlimit(RLIMIT_NOFILE, &old) == 0);
|
||||
fail_unless(rc == -1);
|
||||
fail_unless(ctx.fd == -1);
|
||||
}
|
||||
|
||||
/* A failed init must not leave a closed descriptor in the watcher */
|
||||
static void watcher_init(void)
|
||||
{
|
||||
uev_ctx_t ctx;
|
||||
uev_t w;
|
||||
|
||||
fail_unless(uev_init(&ctx) == 0);
|
||||
fail_unless(close(ctx.fd) == 0);
|
||||
|
||||
fail_unless(uev_cron_init(&ctx, &w, NULL, NULL, time(NULL) + 3600, 0) != 0);
|
||||
fail_unless(w.fd == -1);
|
||||
|
||||
fail_unless(uev_signal_init(&ctx, &w, NULL, NULL, SIGUSR1) != 0);
|
||||
fail_unless(w.fd == -1);
|
||||
}
|
||||
|
||||
/* Invalid arguments must not crash */
|
||||
static void null_init(void)
|
||||
{
|
||||
uev_ctx_t ctx;
|
||||
|
||||
fail_unless(uev_init(&ctx) == 0);
|
||||
fail_unless(uev_timer_init(&ctx, NULL, NULL, NULL, 100, 0) != 0);
|
||||
fail_unless(uev_cron_init(&ctx, NULL, NULL, NULL, time(NULL) + 3600, 0) != 0);
|
||||
fail_unless(uev_exit(&ctx) == 0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
event_init();
|
||||
watcher_init();
|
||||
null_init();
|
||||
ctx_init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Verifies eventfd support
|
||||
*
|
||||
* Copyright (c) 2018-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
* Copyright (c) 2018-2024 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* Verifies uev_io_set() on an active oneshot watcher */
|
||||
#include "check.h"
|
||||
#include <sys/socket.h>
|
||||
|
||||
static int fd = -1;
|
||||
static int ev;
|
||||
|
||||
static void cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
fd = w->fd;
|
||||
ev = events;
|
||||
}
|
||||
|
||||
static void run(uev_ctx_t *ctx)
|
||||
{
|
||||
fd = -1;
|
||||
ev = 0;
|
||||
fail_unless(uev_run(ctx, UEV_ONCE | UEV_NONBLOCK) == 0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int a[2], b[2];
|
||||
uev_ctx_t ctx;
|
||||
uev_t w;
|
||||
|
||||
fail_unless(socketpair(AF_UNIX, SOCK_STREAM, 0, a) == 0);
|
||||
fail_unless(socketpair(AF_UNIX, SOCK_STREAM, 0, b) == 0);
|
||||
fail_unless(write(b[1], "b", 1) == 1);
|
||||
|
||||
fail_unless(uev_init(&ctx) == 0);
|
||||
fail_unless(uev_io_init(&ctx, &w, cb, NULL, a[0], UEV_READ | UEV_ONESHOT) == 0);
|
||||
|
||||
/* New descriptor */
|
||||
fail_unless(uev_io_set(&w, b[0], UEV_READ | UEV_ONESHOT) == 0);
|
||||
run(&ctx);
|
||||
fail_unless(fd == b[0]);
|
||||
|
||||
/* New events, same descriptor */
|
||||
fail_unless(uev_io_set(&w, a[0], UEV_WRITE | UEV_ONESHOT) == 0);
|
||||
run(&ctx);
|
||||
fail_unless(fd == a[0]);
|
||||
fail_unless(ev & UEV_WRITE);
|
||||
|
||||
/* Nothing new, only rearm */
|
||||
run(&ctx);
|
||||
fail_unless(fd == -1);
|
||||
fail_unless(uev_io_set(&w, a[0], UEV_WRITE | UEV_ONESHOT) == 0);
|
||||
run(&ctx);
|
||||
fail_unless(fd == a[0]);
|
||||
|
||||
return uev_exit(&ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,35 @@
|
||||
/* Verifies that UEV_NONBLOCK returns when no event is pending */
|
||||
#include "check.h"
|
||||
|
||||
static int fired;
|
||||
|
||||
static void cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
fired++;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uev_ctx_t ctx;
|
||||
uev_t w;
|
||||
|
||||
fail_unless(uev_init(&ctx) == 0);
|
||||
fail_unless(uev_event_init(&ctx, &w, cb, NULL) == 0);
|
||||
|
||||
alarm(2);
|
||||
fail_unless(uev_run(&ctx, UEV_NONBLOCK) == 0);
|
||||
fail_unless(fired == 0);
|
||||
|
||||
fail_unless(uev_event_post(&w) == 0);
|
||||
fail_unless(uev_run(&ctx, UEV_NONBLOCK) == 0);
|
||||
fail_unless(fired == 1);
|
||||
|
||||
return uev_exit(&ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,34 @@
|
||||
/* Verifies that timers keep their deadline between calls to uev_run() */
|
||||
#include "check.h"
|
||||
|
||||
static int fired;
|
||||
|
||||
static void cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
fired++;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uev_ctx_t ctx;
|
||||
uev_t w;
|
||||
int i;
|
||||
|
||||
fail_unless(uev_init(&ctx) == 0);
|
||||
fail_unless(uev_timer_init(&ctx, &w, cb, NULL, 50, 0) == 0);
|
||||
|
||||
for (i = 0; i < 15; i++) {
|
||||
fail_unless(uev_run(&ctx, UEV_ONCE | UEV_NONBLOCK) == 0);
|
||||
usleep(10000);
|
||||
}
|
||||
fail_unless(fired == 1);
|
||||
|
||||
return uev_exit(&ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/* Multiple signals, segfault and fork() to test sub-processes.
|
||||
*
|
||||
* Copyright (c) 2015-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
* Copyright (c) 2015-2024 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -78,7 +78,7 @@ static void sig_cb(uev_t *w, void *cbarg, int events)
|
||||
break;
|
||||
|
||||
case SIGCHLD:
|
||||
if (arg->pid != w->siginfo.ssi_pid)
|
||||
if (arg->pid != (pid_t)w->siginfo.ssi_pid)
|
||||
err(1, "wrong child exited pid %d vs ssi_pid %d",
|
||||
arg->pid, w->siginfo.ssi_pid);
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/* Verifies UEV_ONCE with stdin redirected from a regular file */
|
||||
#include "check.h"
|
||||
|
||||
static int calls;
|
||||
|
||||
static void cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
char ch;
|
||||
|
||||
calls++;
|
||||
read(w->fd, &ch, 1);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
FILE *fp = tmpfile();
|
||||
uev_ctx_t ctx;
|
||||
uev_t w;
|
||||
|
||||
fail_unless(fp != NULL);
|
||||
fail_unless(fputs("abc", fp) >= 0);
|
||||
rewind(fp);
|
||||
fail_unless(dup2(fileno(fp), STDIN_FILENO) == STDIN_FILENO);
|
||||
|
||||
fail_unless(uev_init(&ctx) == 0);
|
||||
fail_unless(uev_io_init(&ctx, &w, cb, NULL, STDIN_FILENO, UEV_READ) == 0);
|
||||
|
||||
alarm(5);
|
||||
fail_unless(uev_run(&ctx, UEV_ONCE) == 0);
|
||||
fail_unless(calls == 1);
|
||||
|
||||
/* Without UEV_ONCE the rest is drained, including EOF */
|
||||
fail_unless(uev_run(&ctx, 0) == 0);
|
||||
fail_unless(calls == 4);
|
||||
|
||||
return uev_exit(&ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
Reference in new issue
Block a user