mirror of
https://github.com/troglobit/finit.git
synced 2026-10-29 12:40:44 +00:00
keventd: one condition emitter, one file reader, one clock
Three copies of read-first-line-from-a-file (sysfs_read_file, a static sysfs_read, fgetline), two condition emitters symlinking the same reconf marker (cond_emit, sys_cond), two seqnum-stable loops, and five hand-rolled logit() prototypes, none with a printf attribute, so no format string was ever checked. Keep one of each: cond_emit() is exported and mkpaths its parents, which also retires init_dev_condition_dir() and the sys/ directory priming loop; logit() moves to keventd.h with the format attribute; the stability test becomes seqnum_stable(), shared by the coldplug gate and settle; kev_now_ms() serves dbus.c too. rule_ctx_free() and kev_seq_baseline() had one caller each in their own files, now static. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
7 files changed
+83
-186
No files matched your search
+3
-13
@@ -50,8 +50,6 @@
|
||||
#include "udevdb.h"
|
||||
#include "util.h"
|
||||
|
||||
void logit(int prio, const char *fmt, ...);
|
||||
|
||||
#define DEVBUS_DIR "/run/keventd"
|
||||
#define DEVBUS_SOCKET DEVBUS_DIR "/bus"
|
||||
#define DEVBUS_PATH_OBJECT "/org/finit/device"
|
||||
@@ -86,14 +84,6 @@ static struct settle settles[DEVBUS_MAX_SETTLES];
|
||||
static uev_t settle_timer;
|
||||
static int settle_armed;
|
||||
|
||||
static uint64_t now_ms(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (uint64_t)ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
|
||||
}
|
||||
|
||||
/*
|
||||
* Same policy as /run/finit/bus: root and members of the --with-group
|
||||
* group. The group set comes from the kernel (SO_PEERGROUPS), the
|
||||
@@ -226,7 +216,7 @@ static void settle_sweep(uev_t *w, void *arg, int events);
|
||||
*/
|
||||
static void settle_arm(uint64_t deadline)
|
||||
{
|
||||
uint64_t now = now_ms();
|
||||
uint64_t now = kev_now_ms();
|
||||
int ms = deadline > now ? (int)(deadline - now) : 1;
|
||||
|
||||
if (!settle_armed) {
|
||||
@@ -247,7 +237,7 @@ static void settle_arm(uint64_t deadline)
|
||||
static void settle_sweep(uev_t *w, void *arg, int events)
|
||||
{
|
||||
uint64_t next = 0;
|
||||
uint64_t now = now_ms();
|
||||
uint64_t now = kev_now_ms();
|
||||
int empty = kev_queue_empty();
|
||||
int i;
|
||||
|
||||
@@ -305,7 +295,7 @@ static int device1_settle(link_call_t *call, void *u)
|
||||
break;
|
||||
|
||||
settles[i].conn = link_call_connection(call);
|
||||
settles[i].deadline = now_ms() + (uint64_t)timeout * 1000;
|
||||
settles[i].deadline = kev_now_ms() + (uint64_t)timeout * 1000;
|
||||
settle_arm(settles[i].deadline);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user