mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
Don't just SETFL O_NONBLOCK, first GETFL.
This commit is contained in:
parent
b86889f027
commit
f3ce5d1eb9
@ -458,10 +458,15 @@ static void appendf(struct apbuf *buf, const char *format, ...)
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Make the specified socket non-blocking.
|
||||
*/
|
||||
static void nonblock_socket(const int sock)
|
||||
static void
|
||||
nonblock_socket(const int sock)
|
||||
{
|
||||
assert(sock != -1);
|
||||
if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1)
|
||||
int flags = fcntl(sock, F_GETFL, NULL);
|
||||
|
||||
if (flags == -1)
|
||||
err(1, "fcntl(F_GETFL)");
|
||||
flags |= O_NONBLOCK;
|
||||
if (fcntl(sock, F_SETFL, flags) == -1)
|
||||
err(1, "fcntl() to set O_NONBLOCK");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user