home
/
code
/
khatus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Timeout IO poll at desired intervals
[khatus.git]
/
x5
/
khatus.c
diff --git
a/x5/khatus.c
b/x5/khatus.c
index
e804642
..
ce7db95
100644
(file)
--- a/
x5/khatus.c
+++ b/
x5/khatus.c
@@
-345,7
+345,7
@@
fifo_read_error(Fifo *f, char *buf)
b = buf + f->pos_init;
/* Copy as much of the error message as possible.
b = buf + f->pos_init;
/* Copy as much of the error message as possible.
- * EXCLUDING the
re
minating \0. */
+ * EXCLUDING the
ter
minating \0. */
for (i = 0; i < errlen && i < f->width; i++)
b[i] = errmsg[i];
/* Any remaining slots: */
for (i = 0; i < errlen && i < f->width; i++)
b[i] = errmsg[i];
/* Any remaining slots: */
@@
-397,12
+397,13
@@
fifo_read_one(Fifo *f, struct timespec t, char *buf)
}
void
}
void
-fifo_read_all(Config *cfg, struct timespec
t
, char *buf)
+fifo_read_all(Config *cfg, struct timespec
*ti
, char *buf)
{
fd_set fds;
int maxfd = -1;
int ready = 0;
struct stat st;
{
fd_set fds;
int maxfd = -1;
int ready = 0;
struct stat st;
+ struct timespec t;
FD_ZERO(&fds);
for (Fifo *f = cfg->fifos; f; f = f->next) {
FD_ZERO(&fds);
for (Fifo *f = cfg->fifos; f; f = f->next) {
@@
-435,12
+436,10
@@
fifo_read_all(Config *cfg, struct timespec t, char *buf)
FD_SET(f->fd, &fds);
}
debug("selecting...\n");
FD_SET(f->fd, &fds);
}
debug("selecting...\n");
- ready =
select(maxfd + 1, &fds, NULL, NULL
, NULL);
+ ready =
pselect(maxfd + 1, &fds, NULL, NULL, ti
, NULL);
debug("ready: %d\n", ready);
debug("ready: %d\n", ready);
- assert(ready != 0);
- if (ready < 0)
- /* TODO: Do we really want to fail here? */
- fatal("%s", strerror(errno));
+ assert(ready >= 0);
+ clock_gettime(CLOCK_MONOTONIC, &t);
while (ready) {
for (Fifo *f = cfg->fifos; f; f = f->next) {
if (FD_ISSET(f->fd, &fds)) {
while (ready) {
for (Fifo *f = cfg->fifos; f; f = f->next) {
if (FD_ISSET(f->fd, &fds)) {
@@
-555,11
+554,7
@@
main(int argc, char *argv[])
/* TODO: Handle signals */
for (;;) {
clock_gettime(CLOCK_MONOTONIC, &t0); // FIXME: check errors
/* TODO: Handle signals */
for (;;) {
clock_gettime(CLOCK_MONOTONIC, &t0); // FIXME: check errors
- /* TODO: Set timeout on fifo_read_all based on diff of last time of
- * fifo_read_all and desired time of next TTL check?
- */
- /* TODO: How long to wait on IO? Max TTL? */
- fifo_read_all(cfg, t0, buf);
+ fifo_read_all(cfg, &ti, buf);
if (cfg->output_to_x_root_window) {
if (XStoreName(display, DefaultRootWindow(display), buf) < 0)
fatal("XStoreName failed.\n");
if (cfg->output_to_x_root_window) {
if (XStoreName(display, DefaultRootWindow(display), buf) < 0)
fatal("XStoreName failed.\n");
This page took
0.027015 seconds
and
4
git commands to generate.