Skip to content

Commit

Permalink
Improve Events API
Browse files Browse the repository at this point in the history
If the call is interrupted by a signal, this will throw, which we clearly do not want. Simplifying the API to let the user decide what to do on error is probably the best option.
  • Loading branch information
ktf authored and dennisklein committed May 4, 2021
1 parent 868fe02 commit 6dfea32
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fairmq/FairMQSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class FairMQSocket
/// If the backend supports it, fills the unsigned integer @a events with the ZMQ_EVENTS value
/// DISCLAIMER: this API is experimental and unsupported and might be dropped / refactored in
/// the future.
virtual void Events(uint32_t* events) = 0;
virtual int Events(uint32_t* events) = 0;
virtual void SetLinger(const int value) = 0;
virtual int GetLinger() const = 0;
virtual void SetSndBufSize(const int value) = 0;
Expand Down
6 changes: 2 additions & 4 deletions fairmq/shmem/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,10 @@ class Socket final : public fair::mq::Socket
}
}

void Events(uint32_t* events) override
int Events(uint32_t* events) override
{
size_t eventsSize = sizeof(uint32_t);
if (zmq_getsockopt(fSocket, ZMQ_EVENTS, events, &eventsSize) < 0) {
throw SocketError(tools::ToString("failed setting ZMQ_EVENTS, reason: ", zmq_strerror(errno)));
}
return zmq_getsockopt(fSocket, ZMQ_EVENTS, events, &eventsSize);
}

int GetLinger() const override
Expand Down
6 changes: 2 additions & 4 deletions fairmq/zeromq/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,10 @@ class Socket final : public fair::mq::Socket
}
}

void Events(uint32_t* events) override
int Events(uint32_t* events) override
{
size_t eventsSize = sizeof(uint32_t);
if (zmq_getsockopt(fSocket, ZMQ_EVENTS, events, &eventsSize) < 0) {
throw SocketError(tools::ToString("failed setting ZMQ_EVENTS, reason: ", zmq_strerror(errno)));
}
return zmq_getsockopt(fSocket, ZMQ_EVENTS, events, &eventsSize);
}

void SetLinger(const int value) override
Expand Down

0 comments on commit 6dfea32

Please sign in to comment.