[CRIU] [PATCH] [v2] zdtm: fix a race in socket_udp and socket_udplite
Andrei Vagin
avagin at openvz.org
Fri Jan 20 11:28:49 PST 2017
From: Andrei Vagin <avagin at virtuozzo.com>
If we have two sockets and send an upd message from one to another,
we can't be sure that it will be delivered immediately,
there is a change to get from recv(..., MSG_DONTWAIT) EGAIN.
This message is handled asynchronously in a kernel space, so
there may be a small timeout before we get it from another socket.
v2: fix socket6_udp too
Reported-by: Mr Travis
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
test/zdtm/static/socket6_udp.c | 4 ++--
test/zdtm/static/socket_udp.c | 4 ++--
test/zdtm/static/socket_udplite.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/test/zdtm/static/socket6_udp.c b/test/zdtm/static/socket6_udp.c
index 30ddc9a..d1c39c7 100644
--- a/test/zdtm/static/socket6_udp.c
+++ b/test/zdtm/static/socket6_udp.c
@@ -85,7 +85,7 @@ int main(int argc, char **argv)
return 1;
}
- ret = recvfrom(sk1, buf, sizeof(buf), MSG_DONTWAIT,
+ ret = recvfrom(sk1, buf, sizeof(buf), 0,
(struct sockaddr *)&addr, &len);
if (ret <= 0) {
fail("Can't recv C");
@@ -102,7 +102,7 @@ int main(int argc, char **argv)
return 1;
}
- ret = recvfrom(sk2, buf, sizeof(buf), MSG_DONTWAIT,
+ ret = recvfrom(sk2, buf, sizeof(buf), 0,
(struct sockaddr *)&addr, &len);
if (ret <= 0) {
fail("Can't recv");
diff --git a/test/zdtm/static/socket_udp.c b/test/zdtm/static/socket_udp.c
index e84e8bf..5e24a8b 100644
--- a/test/zdtm/static/socket_udp.c
+++ b/test/zdtm/static/socket_udp.c
@@ -90,7 +90,7 @@ int main(int argc, char **argv)
return 1;
}
- ret = recvfrom(sk1, buf, sizeof(buf), MSG_DONTWAIT,
+ ret = recvfrom(sk1, buf, sizeof(buf), 0,
(struct sockaddr *)&addr, &len);
if (ret <= 0) {
fail("Can't recv C");
@@ -107,7 +107,7 @@ int main(int argc, char **argv)
return 1;
}
- ret = recvfrom(sk2, buf, sizeof(buf), MSG_DONTWAIT,
+ ret = recvfrom(sk2, buf, sizeof(buf), 0,
(struct sockaddr *)&addr, &len);
if (ret <= 0) {
fail("Can't recv");
diff --git a/test/zdtm/static/socket_udplite.c b/test/zdtm/static/socket_udplite.c
index aaa40e1..8218ff5 100644
--- a/test/zdtm/static/socket_udplite.c
+++ b/test/zdtm/static/socket_udplite.c
@@ -90,7 +90,7 @@ int main(int argc, char **argv)
return 1;
}
- ret = recvfrom(sk1, buf, sizeof(buf), MSG_DONTWAIT,
+ ret = recvfrom(sk1, buf, sizeof(buf), 0,
(struct sockaddr *)&addr, &len);
if (ret <= 0) {
fail("Can't recv C");
@@ -107,7 +107,7 @@ int main(int argc, char **argv)
return 1;
}
- ret = recvfrom(sk2, buf, sizeof(buf), MSG_DONTWAIT,
+ ret = recvfrom(sk2, buf, sizeof(buf), 0,
(struct sockaddr *)&addr, &len);
if (ret <= 0) {
fail("Can't recv");
--
2.7.4
More information about the CRIU
mailing list