citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit a059a8269163640abe461e4dbbf0d7a49fb1cabe
parent 870b1747d40c9285ae89c468bb8bd594fc2dbed2
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Wed, 30 Mar 2016 18:54:56 -0600

viewer: simplify non-blocking set

Diffstat:
Mviewer/af_unix.cc | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/viewer/af_unix.cc b/viewer/af_unix.cc @@ -45,6 +45,7 @@ af_unix::set_listen() if (bind(fd, (struct sockaddr *)&addr, sizeof(addr))) err(1, "bind"); + /* Size 1024 backlog */ if (listen(fd, 1024)) err(1, "listen"); } @@ -66,11 +67,10 @@ af_unix::accept() } // Turn off non blocking mode - int flags = fcntl(new_fd, F_GETFL, 0); - if (flags < 0) + int flags; + if ((flags = fcntl(new_fd, F_GETFL, 0)) < 0) err(1, "fcntl(F_GETFL)"); - fcntl(new_fd, F_SETFL, flags & ~O_NONBLOCK); - if (flags < 0) + if (fcntl(new_fd, F_SETFL, flags & ~O_NONBLOCK) < 0) err(1, "fcntl(F_SETFL)"); std::cerr << "accepted new connection" << std::endl;