Permalink
Browse files

Problem: assertion fails when requesting endpoint of non-existent peer

Solution: return empty string for endpoint if peer does not exist
  • Loading branch information...
sthoduka committed Jan 4, 2018
1 parent 3efaef9 commit 2014d3bbc6842a37399ab68cd9cfd7ccfa181728
View
@@ -401,6 +401,7 @@ This is the class interface:
zyre_peer_groups (zyre_t *self);
// Return the endpoint of a connected peer.
// Returns empty string if peer does not exist.
// Caller owns return value and must destroy it when done.
ZYRE_EXPORT char *
zyre_peer_address (zyre_t *self, const char *peer);
View
@@ -219,6 +219,7 @@
<method name = "peer address">
Return the endpoint of a connected peer.
Returns empty string if peer does not exist.
<argument name = "peer" type = "string" />
<return type = "string" fresh = "1" />
</method>
@@ -282,6 +282,7 @@ public Zlist peerGroups () {
}
/*
Return the endpoint of a connected peer.
Returns empty string if peer does not exist.
*/
native static String __peerAddress (long self, String peer);
public String peerAddress (String peer) {
@@ -193,6 +193,7 @@ zlist_t *
zyre_peer_groups (zyre_t *self);
// Return the endpoint of a connected peer.
// Returns empty string if peer does not exist.
char *
zyre_peer_address (zyre_t *self, const char *peer);
@@ -275,6 +275,7 @@ string my_zyre.peerAddress (String)
```
Return the endpoint of a connected peer.
Returns empty string if peer does not exist.
```
string my_zyre.peerHeaderValue (String, String)
@@ -408,6 +408,7 @@ def peer_groups(self):
def peer_address(self, peer):
"""
Return the endpoint of a connected peer.
Returns empty string if peer does not exist.
"""
return return_fresh_string(lib.zyre_peer_address(self._as_parameter_, peer))
@@ -240,6 +240,7 @@ def peer_groups(self):
def peer_address(self, peer):
"""
Return the endpoint of a connected peer.
Returns empty string if peer does not exist.
"""
return utils.lib.zyre_peer_address(self._p, utils.to_bytes(peer))
@@ -181,6 +181,7 @@ zlist_t *
zyre_peer_groups (zyre_t *self);
// Return the endpoint of a connected peer.
// Returns empty string if peer does not exist.
char *
zyre_peer_address (zyre_t *self, const char *peer);
@@ -4262,6 +4262,7 @@
zyre_peer_groups (zyre_t *self);
// Return the endpoint of a connected peer.
// Returns empty string if peer does not exist.
char *
zyre_peer_address (zyre_t *self, const char *peer);
@@ -220,6 +220,7 @@ zlist_t *QmlZyre::peerGroups () {
///
// Return the endpoint of a connected peer.
// Returns empty string if peer does not exist.
QString QmlZyre::peerAddress (const QString &peer) {
char *retStr_ = zyre_peer_address (self, peer.toUtf8().data());
QString retQStr_ = QString (retStr_);
@@ -152,6 +152,7 @@ public slots:
zlist_t *peerGroups ();
// Return the endpoint of a connected peer.
// Returns empty string if peer does not exist.
QString peerAddress (const QString &peer);
// Return the value of a header of a conected peer.
@@ -303,6 +303,7 @@ QZlist * QZyre::peerGroups ()
///
// Return the endpoint of a connected peer.
// Returns empty string if peer does not exist.
QString QZyre::peerAddress (const QString &peer)
{
char *retStr_ = zyre_peer_address (self, peer.toUtf8().data());
@@ -459,6 +459,7 @@ def peer_groups()
end
# Return the endpoint of a connected peer.
# Returns empty string if peer does not exist.
#
# @param peer [String, #to_s, nil]
# @return [::FFI::AutoPointer]
View
@@ -191,6 +191,7 @@ This is the class interface:
zyre_peer_groups (zyre_t *self);
// Return the endpoint of a connected peer.
// Returns empty string if the peer does not exist.
// Caller owns return value and must destroy it when done.
ZYRE_EXPORT char *
zyre_peer_address (zyre_t *self, const char *peer);
View
@@ -162,6 +162,7 @@ ZYRE_EXPORT zlist_t *
zyre_peer_groups (zyre_t *self);
// Return the endpoint of a connected peer.
// Returns empty string if the peer does not exist.
// Caller owns return value and must destroy it when done.
ZYRE_EXPORT char *
zyre_peer_address (zyre_t *self, const char *peer);
View
@@ -187,6 +187,7 @@ ZYRE_EXPORT zlist_t *
zyre_peer_groups (zyre_t *self);
// Return the endpoint of a connected peer.
// Returns empty string if peer does not exist.
// Caller owns return value and must destroy it when done.
ZYRE_EXPORT char *
zyre_peer_address (zyre_t *self, const char *peer);
View
@@ -529,7 +529,8 @@ zyre_peers_by_group (zyre_t *self, const char *group)
// --------------------------------------------------------------------------
// Return the endpoint of a connected peer. Caller owns the string.
// Return the endpoint of a connected peer. Returns empty string if
// the peer does not exist. Caller owns the string.
char *
zyre_peer_address (zyre_t *self, const char *peer)
View
@@ -684,8 +684,10 @@ zyre_node_recv_api (zyre_node_t *self)
if (streq (command, "PEER ENDPOINT")) {
char *uuid = zmsg_popstr (request);
zyre_peer_t *peer = (zyre_peer_t *) zhash_lookup (self->peers, uuid);
assert (peer);
zsock_send (self->pipe, "s", zyre_peer_endpoint (peer));
if (peer)
zsock_send (self->pipe, "s", zyre_peer_endpoint (peer));
else
zsock_send (self->pipe, "s", "");
zstr_free (&uuid);
}
else

0 comments on commit 2014d3b

Please sign in to comment.