Obsolete
/
libipc-old
Archived
3
0
Fork 0
pollfd
Karchnu 2020-07-03 22:27:56 +02:00
parent 0f46858e78
commit 3b1aaf36c2
2 changed files with 36 additions and 0 deletions

View File

@ -16,3 +16,19 @@ Logs are in one of the following directories: `$XDG_DATA_HOME/ipc/` or `$HOME/.l
The log file can be indicated with the `IPC_LOGFILE` environment variable, too.
To remove logs: `make LDFLAGS=-DIPC_WITHOUT_ERRORS`
# Planning for 0.7
- `libipc` should have callbacks to use along with switching capabilities, making easier to implement proxies with communication protocols
# Planning for 0.8
- `libipc` should be thread-safe
# Planning for 0.8
- `libipc` should use `libevent` for performance improvments
# Planning for 1.0
- `libipc` should have usable bindings in several languages

View File

@ -1,4 +1,5 @@
#include <sys/select.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
@ -467,10 +468,29 @@ struct ipc_error ipc_events_loop (struct ipc_ctx *ctx, struct ipc_event *event,
}
}
struct timeval tv_1;
memset (&tv_1, 0, sizeof(struct timeval));
struct timeval tv_2;
memset (&tv_2, 0, sizeof(struct timeval));
gettimeofday(&tv_1, NULL);
if ((n = poll(ctx->pollfd, ctx->size, *timer)) < 0) {
IPC_RETURN_ERROR (IPC_ERROR_WAIT_EVENT__POLL);
}
gettimeofday(&tv_2, NULL);
int new_timer = *timer - ((tv_2.tv_sec - tv_1.tv_sec) * 1000000 + (tv_2.tv_usec - tv_1.tv_usec)) / 1000;
// Handle memory fuckery, 'cause low level programming is fun.
if (new_timer >= *timer || new_timer < 0) {
*timer = 0;
}
else {
*timer = new_timer;
}
// Timeout.
if (n == 0) {
IPC_EVENT_SET (event, IPC_EVENT_TYPE_TIMER, 0, 0, NULL);