If the receiver is blocked, Buxton daemon also can be blocked.
To prevent blocking, timeout argument in poll() is set.
Change-Id: I42cc6d8ba18cffebdc9eac6bab74bf3f56ecf24f
Signed-off-by: Suchang Woo <suchang.woo@samsung.com>
#include "log.h"
#include "proto.h"
+#define SEND_TIMEOUT 1000 /* milliseconds */
+
struct recv_info {
int fd;
uint16_t seq;
fds[0].revents = 0;
do {
- /* CAN BE BLOCKED ! */
- r = poll(fds, 1, -1);
+ r = poll(fds, 1, SEND_TIMEOUT);
if (r == -1) {
if (errno == EINTR)
continue;
return -1;
}
- } while (r <= 0);
+
+ if (r == 0) {
+ bxt_err("send: fd %d poll timeout", fd);
+ free(buf);
+ errno = ETIMEDOUT;
+
+ return -1;
+ }
+ } while (r < 0);
r = send(fd, buf, sizeof(*hdr) + len, 0);