#include <yubikey.h>
#include <time.h>
#include <gcrypt.h>
-#include "util.h"
+#include <sys/select.h>
#include <arpa/inet.h>
+#include "util.h"
#ifdef UNUSED
#elif defined(__GNUC__)
NULL, /* Access policy handler */
NULL, /* Data to access policy handler */
handle_request, /* default handler for all URIs */
- NULL, /* Data for default handler */
- MHD_OPTION_END);
+ NULL, /* Data for default handler */
+ MHD_OPTION_END);
if (d == NULL) {
fprintf(stderr, "Could not start daemon\n");
exit(1);
}
while (1) {
+ fd_set rs, ws, es;
+ int max_fd = 0;
+ unsigned long long timeout;
+ struct timeval tv;
+
+ FD_ZERO(&rs);
+ FD_ZERO(&ws);
+ FD_ZERO(&es);
+
+ if (MHD_get_fdset(d, &rs, &ws, &es, &max_fd) == MHD_NO) {
+ MHD_stop_daemon(d);
+ exit(1);
+ }
+ if (MHD_get_timeout(d, &timeout) == MHD_NO) {
+ timeout = 0;
+ }
+ tv.tv_usec = (timeout % 1000) * 1000;
+ tv.tv_sec = timeout / 1000;
+ if (timeout == 0) {
+ select(max_fd+1, &rs, &ws, &es, NULL);
+ } else {
+ select(max_fd+1, &rs, &ws, &es, &tv);
+ }
if (MHD_run(d) == MHD_NO) {
MHD_stop_daemon(d);
exit(1);