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

[EchoServer] don't die when a connection is dropped

parent 6ead33f3
No related branches found
No related tags found
1 merge request!1WIP: Emper shutdown
......@@ -2,8 +2,7 @@
// Copyright © 2020-2021 Florian Fischer
#include <sys/types.h>
#include <cassert>
#include <climits>
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <iostream>
......@@ -44,9 +43,10 @@ auto main(int argc, char* argv[]) -> int {
if (unlikely(bytes_recv <= 0)) {
// socket was shutdown
if (bytes_recv < 0) {
DIE_MSG_ERRNO("server read failed");
LOGE("server read failed:" << strerror(errno));
}
finish:
emper::io::closeAndForget(socket);
return;
}
......@@ -55,8 +55,11 @@ auto main(int argc, char* argv[]) -> int {
exit(EXIT_SUCCESS);
}
ATTR_UNUSED ssize_t bytes_send = emper::io::sendAndWait(socket, buf, bytes_recv, 0);
assert(bytes_recv == bytes_send);
ssize_t bytes_send = emper::io::sendAndWait(socket, buf, bytes_recv, MSG_NOSIGNAL, true);
if (unlikely(bytes_recv != bytes_send)) {
LOGE("server send failed: " << strerror(errno));
goto finish;
}
}
});
......
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