Skip to content
Snippets Groups Projects
Commit 4b7f7802 authored by Florian Fischer's avatar Florian Fischer
Browse files

[SimpleDiskAndNetworkTest] use *AndWait() or waitAndSetErrno() and correct types

errno was never set on error and thus the DIE_MSG_ERRNO did not properly
report what happened.

Found during changing Future member types.
parent 084d678e
No related branches found
No related tags found
1 merge request!205Fix most llvm-12 clang-tidy warnings in IO code
......@@ -26,9 +26,8 @@
static void server_func(int sockfd) {
struct sockaddr_in clientaddr;
socklen_t clientaddr_len = sizeof(clientaddr);
auto client_fd =
emper::io::accept(sockfd, reinterpret_cast<struct sockaddr*>(&clientaddr), &clientaddr_len)
->wait();
auto client_fd = emper::io::acceptAndWait(sockfd, reinterpret_cast<struct sockaddr*>(&clientaddr),
&clientaddr_len);
if (client_fd < 0) {
DIE_MSG_ERRNO("accept failed");
......@@ -40,7 +39,7 @@ static void server_func(int sockfd) {
char read_buf[MAX];
for (;;) {
int received = emper::io::recv(client_fd, recv_buf, sizeof(recv_buf), 0)->wait();
ssize_t received = emper::io::recvAndWait(client_fd, recv_buf, sizeof(recv_buf), 0);
if (received == 0) {
exit(EXIT_SUCCESS);
}
......@@ -57,7 +56,7 @@ static void server_func(int sockfd) {
DIE_MSG_ERRNO("mkstemp failed");
}
int written = emper::io::writeFile(file_fd, recv_buf, received)->wait();
ssize_t written = emper::io::writeFileAndWait(file_fd, recv_buf, received);
if (written < 0) {
DIE_MSG_ERRNO("write failed");
}
......@@ -68,7 +67,7 @@ static void server_func(int sockfd) {
DIE_MSG_ERRNO("open failed");
}
int bytes_read = emper::io::readFile(file_fd, read_buf, written)->wait();
ssize_t bytes_read = emper::io::readFileAndWait(file_fd, read_buf, written);
if (bytes_read == 0) {
DIE_MSG("nothing to read");
}
......@@ -78,7 +77,7 @@ static void server_func(int sockfd) {
}
close(file_fd);
int sent = emper::io::send(client_fd, read_buf, bytes_read, 0)->wait();
ssize_t sent = emper::io::sendAndWait(client_fd, read_buf, bytes_read, 0);
if (sent == 0) {
DIE_MSG("client socket unexpected shutdown");
}
......@@ -107,7 +106,7 @@ static void server_func(int sockfd) {
iov[1].iov_len = s2.length();
auto writevFuture = emper::io::writev(file_fd, &iov[0], iovcnt);
written = writevFuture->wait();
written = writevFuture->waitAndSetErrno();
if (written < 0) {
DIE_MSG_ERRNO("wrtev failed");
}
......@@ -119,7 +118,7 @@ static void server_func(int sockfd) {
}
auto readFuture = emper::io::readFile(file_fd, read_buf, written, 0, true);
bytes_read = readFuture->wait();
bytes_read = readFuture->waitAndSetErrno();
if (bytes_read == 0) {
DIE_MSG("nothing to read");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment