mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 08:26:30 +00:00
Fix random failures in send_buf_full
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
83b88229a3
commit
e4954827dc
@ -105,14 +105,9 @@ static ssize_t receive_all(int sockfd)
|
|||||||
size_t recv_len = 0;
|
size_t recv_len = 0;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
if (mark_filde_nonblock(sockfd) < 0) {
|
|
||||||
perror("receive_all: mark_filde_nonblock");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ret = recv(sockfd, buffer, sizeof(buffer), 0);
|
ret = recv(sockfd, buffer, sizeof(buffer), 0);
|
||||||
if (ret < 0 && errno == EAGAIN)
|
if (ret == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -197,6 +192,9 @@ int test_full_send_buffer(struct sockaddr_in *addr)
|
|||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
ssize_t recv_len;
|
ssize_t recv_len;
|
||||||
|
|
||||||
|
close(sendfd);
|
||||||
|
sendfd = -1;
|
||||||
|
|
||||||
// Ensure that the parent executes send() first, then the child
|
// Ensure that the parent executes send() first, then the child
|
||||||
// executes recv().
|
// executes recv().
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@ -230,6 +228,9 @@ int test_full_send_buffer(struct sockaddr_in *addr)
|
|||||||
sent_len += 1;
|
sent_len += 1;
|
||||||
fprintf(stderr, "Sent bytes: %lu\n", sent_len);
|
fprintf(stderr, "Sent bytes: %lu\n", sent_len);
|
||||||
|
|
||||||
|
close(sendfd);
|
||||||
|
sendfd = -1;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
wait:
|
wait:
|
||||||
@ -250,7 +251,8 @@ out:
|
|||||||
close(recvfd);
|
close(recvfd);
|
||||||
|
|
||||||
out_send:
|
out_send:
|
||||||
close(sendfd);
|
if (sendfd >= 0)
|
||||||
|
close(sendfd);
|
||||||
|
|
||||||
out_listen:
|
out_listen:
|
||||||
close(listenfd);
|
close(listenfd);
|
||||||
|
@ -18,7 +18,7 @@ echo "Start network test......"
|
|||||||
./socketpair
|
./socketpair
|
||||||
./sockoption
|
./sockoption
|
||||||
./listen_backlog
|
./listen_backlog
|
||||||
# ./send_buf_full
|
./send_buf_full
|
||||||
./http_server &
|
./http_server &
|
||||||
./http_client
|
./http_client
|
||||||
./tcp_err
|
./tcp_err
|
||||||
|
Reference in New Issue
Block a user