feat!: Remove deprecated Socket::Close()

BREAKING CHANGE
This commit is contained in:
Dennis Klein 2023-04-05 13:10:28 +02:00
parent 600624c884
commit 55f9991bab
3 changed files with 34 additions and 39 deletions

View File

@ -57,9 +57,6 @@ struct Socket
virtual int64_t Send(Parts& parts, int timeout = -1) { return Send(parts.fParts, timeout); }
virtual int64_t Receive(Parts& parts, int timeout = -1) { return Receive(parts.fParts, timeout); }
[[deprecated("Use Socket::~Socket() instead.")]]
virtual void Close() = 0;
virtual void SetOption(const std::string& option, const void* value, size_t valueSize) = 0;
virtual void GetOption(const std::string& option, void* value, size_t* valueSize) = 0;

View File

@ -319,23 +319,6 @@ class Socket final : public fair::mq::Socket
void* GetSocket() const { return fSocket; }
void Close() override
{
// LOG(debug) << "Closing socket " << fId;
if (fSocket && zmq_close(fSocket) != 0) {
LOG(error) << "Failed closing data socket " << fId
<< ", reason: " << zmq_strerror(errno);
}
fSocket = nullptr;
if (fMonitorSocket && zmq_close(fMonitorSocket) != 0) {
LOG(error) << "Failed closing monitor socket " << fId
<< ", reason: " << zmq_strerror(errno);
}
fMonitorSocket = nullptr;
}
void SetOption(const std::string& option, const void* value, size_t valueSize) override
{
if (zmq_setsockopt(fSocket, zmq::getConstant(option), value, valueSize) < 0) {
@ -452,7 +435,23 @@ class Socket final : public fair::mq::Socket
unsigned long GetMessagesTx() const override { return fMessagesTx; }
unsigned long GetMessagesRx() const override { return fMessagesRx; }
~Socket() override { Close(); }
~Socket() override
{
// LOG(debug) << "Closing socket " << fId;
if (fSocket && zmq_close(fSocket) != 0) {
LOG(error) << "Failed closing data socket " << fId
<< ", reason: " << zmq_strerror(errno);
}
fSocket = nullptr;
if (fMonitorSocket && zmq_close(fMonitorSocket) != 0) {
LOG(error) << "Failed closing monitor socket " << fId
<< ", reason: " << zmq_strerror(errno);
}
fMonitorSocket = nullptr;
}
private:
Manager& fManager;

View File

@ -257,23 +257,6 @@ class Socket final : public fair::mq::Socket
void* GetSocket() const { return fSocket; }
void Close() override
{
// LOG(debug) << "Closing socket " << fId;
if (fSocket && zmq_close(fSocket) != 0) {
LOG(error) << "Failed closing data socket " << fId
<< ", reason: " << zmq_strerror(errno);
}
fSocket = nullptr;
if (fMonitorSocket && zmq_close(fMonitorSocket) != 0) {
LOG(error) << "Failed closing monitor socket " << fId
<< ", reason: " << zmq_strerror(errno);
}
fMonitorSocket = nullptr;
}
void SetOption(const std::string& option, const void* value, size_t valueSize) override
{
if (zmq_setsockopt(fSocket, getConstant(option), value, valueSize) < 0) {
@ -390,7 +373,23 @@ class Socket final : public fair::mq::Socket
unsigned long GetMessagesTx() const override { return fMessagesTx; }
unsigned long GetMessagesRx() const override { return fMessagesRx; }
~Socket() override { Close(); }
~Socket() override
{
// LOG(debug) << "Closing socket " << fId;
if (fSocket && zmq_close(fSocket) != 0) {
LOG(error) << "Failed closing data socket " << fId
<< ", reason: " << zmq_strerror(errno);
}
fSocket = nullptr;
if (fMonitorSocket && zmq_close(fMonitorSocket) != 0) {
LOG(error) << "Failed closing monitor socket " << fId
<< ", reason: " << zmq_strerror(errno);
}
fMonitorSocket = nullptr;
}
private:
Context& fCtx;