mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-05 06:20:00 +02:00
Merge pull request #336 from weidmueller/feature/fix-poll-function-calls
Fix error detection of poll function calls
This commit is contained in:
@@ -503,8 +503,11 @@ resend:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (polltimeout) {
|
if (polltimeout) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* wait for the write socket (with timeout) */
|
/* wait for the write socket (with timeout) */
|
||||||
if (poll(&fds, 1, polltimeout) < 0) {
|
ret = poll(&fds, 1, polltimeout);
|
||||||
|
if (ret == 0 || (ret == -1 && errno != -EINTR)) {
|
||||||
perror("poll");
|
perror("poll");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -216,7 +216,7 @@ static void do_send()
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = poll(fds, 1, 1000);
|
err = poll(fds, 1, 1000);
|
||||||
if (err == -1 && errno != -EINTR) {
|
if (err == 0 || (err == -1 && errno != -EINTR)) {
|
||||||
perror("poll()");
|
perror("poll()");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-8
@@ -368,10 +368,12 @@ static int j1939cat_send_loop(struct j1939cat_priv *priv, int out_fd, char *buf,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = poll(&fds, 1, priv->polltimeout);
|
ret = poll(&fds, 1, priv->polltimeout);
|
||||||
if (ret == -EINTR)
|
if (ret == -1) {
|
||||||
continue;
|
if (errno == -EINTR)
|
||||||
if (ret < 0)
|
continue;
|
||||||
return -errno;
|
else
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return -ETIME;
|
return -ETIME;
|
||||||
if (!(fds.revents & events)) {
|
if (!(fds.revents & events)) {
|
||||||
@@ -572,10 +574,12 @@ static int j1939cat_recv(struct j1939cat_priv *priv)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = poll(&fds, 1, priv->polltimeout);
|
ret = poll(&fds, 1, priv->polltimeout);
|
||||||
if (ret == -EINTR)
|
if (ret == -1) {
|
||||||
continue;
|
if (errno == -EINTR)
|
||||||
if (ret < 0)
|
continue;
|
||||||
return -errno;
|
else
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
if (!ret)
|
if (!ret)
|
||||||
continue;
|
continue;
|
||||||
if (!(fds.revents & events)) {
|
if (!(fds.revents & events)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user