Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid regeneration of the SocketHandler when calling shutDown #49

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/header/MinimalSocket/core/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ class Socket {
*/
bool isBlocking() const { return isBlocking_; }

void shutDown() { resetHandler(); }
/**
* @brief shutdown this socket. Any pending operation like blocking read or blocking client
* accept done from any other thread are consequently terminated.
*/
void shutDown();

protected:
Socket();
Expand Down
8 changes: 7 additions & 1 deletion src/src/SocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ void close(SocketID &socket_id) {
}
} // namespace

SocketHandler::~SocketHandler() { MinimalSocket::close(socket_id); }
SocketHandler::~SocketHandler() {
MinimalSocket::close(socket_id);
}

void SocketHandler::shutDown() {
MinimalSocket::close(socket_id);
}

void SocketHandler::reset(SocketID hndl) {
if (socket_id != SCK_INVALID_SOCKET) {
Expand Down
4 changes: 3 additions & 1 deletion src/src/SocketHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ class SocketHandler {
SocketHandler() = default;

/**
* @brief close and shutdown the current socket
* @brief internally calls shut down
*/
~SocketHandler();

void shutDown();

/**
* @brief regenerates the socket descriptor, i.e. creates a new socket
*/
Expand Down
2 changes: 2 additions & 0 deletions src/src/core/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Socket::~Socket() = default;

Socket::Socket() { resetHandler(); }

void Socket::shutDown() { socket_id_wrapper->shutDown(); }

int Socket::getSocketDescriptor() const {
return static_cast<int>(getHandler().accessId());
}
Expand Down
Loading