It probably does not help much as it does not explain intentions.
They stay with the original authors of this code.
However, I believe it is a small step in the right direction.
Change-Id: I236a9b2b3dabb712ad7b1d0b6a8b1b33dd1e0230
#include <sys/file.h>
#include <system_info.h>
+#define UDEV_MONITOR_POLL_TIMEOUT_MILISECONDS 100
+
int peripheral_lock(const char *file_name)
{
int fd = open(file_name, O_WRONLY | O_CLOEXEC);
for (int cnt = 0; cnt < 10; cnt++) {
_D("poll iteration");
- if (poll(&pfd, 1, 100) < 0) {
+ if (poll(&pfd, 1, UDEV_MONITOR_POLL_TIMEOUT_MILISECONDS) < 0) {
_E("Failed to watch udev monitor");
return -EIO;
}
#define GPIO_INTERRUPTED_CALLBACK_UNSET 0
#define GPIO_INTERRUPTED_CALLBACK_SET 1
+#define GPIO_INTERRUPTED_CALLBACK_CHECK_SET_INTERVAL_MILISECONDS 3000
+
#define GPIO_BUFFER_MAX 64
typedef struct _peripheral_gpio_interrupted_cb_info_s {
while (g_atomic_int_get(&gpio->cb_info.status) == GPIO_INTERRUPTED_CALLBACK_SET) {
- poll_state = poll(&poll_fd, 1, 3000);
+ poll_state = poll(&poll_fd, 1, GPIO_INTERRUPTED_CALLBACK_CHECK_SET_INTERVAL_MILISECONDS);
if (poll_state == 0)
continue;