summaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2023-05-02 13:05:26 +0300
committerdefanor <defanor@uberspace.net>2023-05-02 13:05:26 +0300
commit938963c1d1c6a9b929d28a90030332d4f397ca61 (patch)
tree596869c5f96b7578826c7e84c439f0b6313339b1 /emacs
parentf53cb7886439619860ff86451318a5a04fc49322 (diff)
Use timespec and monotonic clock for timers
Diffstat (limited to 'emacs')
-rw-r--r--emacs/xml_interface.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/emacs/xml_interface.c b/emacs/xml_interface.c
index 7db2c63..2f4ebba 100644
--- a/emacs/xml_interface.c
+++ b/emacs/xml_interface.c
@@ -329,8 +329,10 @@ int main (int argc, char **argv) {
fd_set read_fds, write_fds;
int nfds;
- struct timeval tv;
- struct timeval *mtv;
+ struct timespec tv;
+ struct timespec *mtv;
+ struct timeval tv_ms;
+ struct timeval *mtv_ms;
int n = 0;
do {
@@ -367,7 +369,13 @@ int main (int argc, char **argv) {
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
nfds = rexmpp_fds(&s, &read_fds, &write_fds);
- mtv = rexmpp_timeout(&s, NULL, (struct timeval*)&tv);
+ mtv = rexmpp_timeout(&s, NULL, &tv);
+ mtv_ms = NULL;
+ if (mtv != NULL) {
+ tv_ms.tv_sec = mtv->tv_sec;
+ tv_ms.tv_usec = mtv->tv_nsec / 1000;
+ mtv_ms = &tv_ms;
+ }
/* Add other file descriptors we are interested in, particularly
stdin for user input. */
@@ -375,7 +383,7 @@ int main (int argc, char **argv) {
/* Run select(2) with all those file descriptors and timeouts,
waiting for either user input or some rexmpp event to occur. */
- n = select(nfds, &read_fds, &write_fds, NULL, mtv);
+ n = select(nfds, &read_fds, &write_fds, NULL, mtv_ms);
if (n == -1) {
printf("select error: %s\n", strerror(errno));
break;