Commit e49c52a0 authored by Florian Fischer's avatar Florian Fischer
Browse files

add flags to recv and send calls

parent a5096157
...@@ -27,9 +27,9 @@ ssize_t send_all(int fd, const void* buf, size_t len) { ...@@ -27,9 +27,9 @@ ssize_t send_all(int fd, const void* buf, size_t len) {
size_t bytes_written = 0; size_t bytes_written = 0;
while (bytes_written < len) { while (bytes_written < len) {
#ifdef USE_ASYNC_IO #ifdef USE_ASYNC_IO
ssize_t new_bytes_written = sync_send(fd, buf, len - bytes_written); ssize_t new_bytes_written = sync_send(fd, buf, len - bytes_written, MSG_NOSIGNAL);
#else #else
ssize_t new_bytes_written = send(fd, buf, len - bytes_written, 0); ssize_t new_bytes_written = send(fd, buf, len - bytes_written, MSG_NOSIGNAL);
#endif #endif
if (unlikely(new_bytes_written < 1)) { if (unlikely(new_bytes_written < 1)) {
return new_bytes_written; return new_bytes_written;
...@@ -49,9 +49,9 @@ void client_func(void* arg) { ...@@ -49,9 +49,9 @@ void client_func(void* arg) {
char buf[BUF_MAX]; char buf[BUF_MAX];
for (;;) { for (;;) {
#ifdef USE_ASYNC_IO #ifdef USE_ASYNC_IO
ssize_t bytes_recv = sync_recv(client_fd, (void*)&buf, BUF_MAX); ssize_t bytes_recv = sync_recv(client_fd, (void*)&buf, BUF_MAX, MSG_WAITALL);
#else #else
ssize_t bytes_recv = recv(client_fd, (void*)&buf, BUF_MAX); ssize_t bytes_recv = recv(client_fd, (void*)&buf, BUF_MAX, MSG_WAITALL);
#endif #endif
// socket was shutdown // socket was shutdown
if (unlikely(bytes_recv == 0)) { if (unlikely(bytes_recv == 0)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment