Skip to content

Commit 328fdbb

Browse files
committed
Remove 'setsockopt()' on an accepted sockfd.
1 parent 5817a88 commit 328fdbb

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/server/WFServer.cc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,15 @@ int WFServerBase::create_listen_fd()
142142

143143
WFConnection *WFServerBase::new_connection(int accept_fd)
144144
{
145-
if (++this->conn_count <= this->params.max_connections ||
146-
this->drain(1) == 1)
145+
if (++this->conn_count > this->params.max_connections &&
146+
this->drain(1) <= 0)
147147
{
148-
int reuse = 1;
149-
setsockopt(accept_fd, SOL_SOCKET, SO_REUSEADDR,
150-
(const char *)(&reuse), sizeof (int));
151-
return new WFServerConnection(&this->conn_count);
148+
this->conn_count--;
149+
errno = EMFILE;
150+
return NULL;
152151
}
153152

154-
this->conn_count--;
155-
errno = EMFILE;
156-
return NULL;
153+
return new WFServerConnection(&this->conn_count);
157154
}
158155

159156
void WFServerBase::delete_connection(WFConnection *conn)

0 commit comments

Comments
 (0)