replace select to poll (#584)

* replace select

* Added poll/select selection during compilation

---------

Co-authored-by: Olof Hagsand <olof@hagsand.se>
This commit is contained in:
Roman Khromenok 2024-12-17 15:30:40 +02:00 committed by GitHub
parent 4080bd3a5a
commit 2a6bbac712
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 1 deletions

View file

@ -465,6 +465,13 @@ AH_BOTTOM([#include <clixon_custom.h>])
test "x$prefix" = xNONE && prefix=$ac_default_prefix
AC_ARG_ENABLE([event-poll],
AS_HELP_STRING([--enable-event-poll], [Enable event polling feature]),
[if test "$enable_event_poll" = "yes"; then
AC_DEFINE([CLIXON_EVENT_POLL], 1, [Enable event polling feature])
fi]
)
AC_CONFIG_FILES([Makefile
lib/Makefile
lib/src/Makefile

View file

@ -213,8 +213,8 @@
* This causes xml_cmp to show that the datastores are unequal and may cause a wrong diff, or
* worse case an overwrite.
*/
#undef SYSTEM_ONLY_CONFIG_CANDIDATE_CLEAR
#undef SYSTEM_ONLY_CONFIG_CANDIDATE_CLEAR
/*! In full XPath namespace resolve, match even if namespace not resolved
*
* In the case of xpath lookup functions (eg xpath_vec_ctx) where nsc is defined, then
@ -224,3 +224,4 @@
* This seems wrong and should be changed, but need further investigation
*/
#define XPATH_NS_ACCEPT_UNRESOLVED

View file

@ -69,6 +69,10 @@
#include "clixon_options.h"
#include "clixon_event.h"
#ifdef CLIXON_EVENT_POLL
#include <poll.h>
#endif
/*
* Constants
*/
@ -353,6 +357,24 @@ clixon_event_unreg_timeout(int (*fn)(int, void*),
* @retval 0 Nothing to read/empty fd
* @retval -1 Error
*/
#ifdef CLIXON_EVENT_POLL
int
clixon_event_poll(int fd) {
struct pollfd pfd;
int retval;
pfd.fd = fd;
pfd.events = POLLIN;
retval = poll(&pfd, 1, 0);
if (retval < 0) {
clixon_err(OE_EVENTS, errno, "poll");
}
return retval;
}
#else
int
clixon_event_poll(int fd)
{
@ -366,6 +388,7 @@ clixon_event_poll(int fd)
clixon_err(OE_EVENTS, errno, "select");
return retval;
}
#endif
/*! Dispatch file descriptor events (and timeouts) by invoking callbacks.
*