Skip to content

Commit

Permalink
fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFreeman committed Apr 4, 2024
1 parent c37fdd6 commit 052e0fe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/swoole_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ struct ListenPort {
void close();
bool import(int sock);
const char *get_protocols();
int create_socket(swoole::Server *server);
void close_socket_fd();

#ifdef SW_USE_OPENSSL
bool ssl_create_context(SSLContext *context);
Expand Down Expand Up @@ -356,7 +358,6 @@ struct ListenPort {
}

size_t get_connection_num();
int create_socket(swoole::Server *server);
};

struct ServerGS {
Expand Down
8 changes: 8 additions & 0 deletions src/server/port.cc
Original file line number Diff line number Diff line change
Expand Up @@ -840,4 +840,12 @@ int ListenPort::create_socket(Server *server) {
return SW_OK;
}

void ListenPort::close_socket_fd() {
if (::close(socket->fd) < 0) {
swoole_sys_warning("close(%d) failed", socket->fd);
}
delete socket;
socket = nullptr;
}

} // namespace swoole
2 changes: 2 additions & 0 deletions src/server/reactor_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ int Server::start_reactor_processes() {
return SW_ERR;
}
#if defined(__linux__) && defined(HAVE_REUSEPORT)
} else {
ls->close_socket_fd();
}
#endif
}
Expand Down
2 changes: 2 additions & 0 deletions src/server/worker_threads.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ int Server::start_worker_threads() {
return SW_ERR;
}
#if defined(__linux__) && defined(HAVE_REUSEPORT)
} else {
ls->close_socket_fd();
}
#endif
}
Expand Down

0 comments on commit 052e0fe

Please sign in to comment.