Skip to content

Commit

Permalink
Problem: zgossip class was not properly exported
Browse files Browse the repository at this point in the history
Solution: added export_macro = "CZMQ_EXPORT" to zgossip.xml
  • Loading branch information
hintjens committed Jun 1, 2015
1 parent 02aa4aa commit c09a4d0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
4 changes: 2 additions & 2 deletions doc/zgossip.doc
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ This is the class interface:
//
// This is the zgossip constructor as a zactor_fn:
//
void
CZMQ_EXPORT void
zgossip (zsock_t *pipe, void *args);

// Self test of this class
void
CZMQ_EXPORT void
zgossip_test (bool verbose);

This is the class self test code:
Expand Down
4 changes: 2 additions & 2 deletions doc/zgossip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ SYNOPSIS
//
// This is the zgossip constructor as a zactor_fn:
//
void
CZMQ_EXPORT void
zgossip (zsock_t *pipe, void *args);

// Self test of this class
void
CZMQ_EXPORT void
zgossip_test (bool verbose);
----

Expand Down
4 changes: 2 additions & 2 deletions include/zgossip.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ extern "C" {
//
// This is the zgossip constructor as a zactor_fn:
//
void
CZMQ_EXPORT void
zgossip (zsock_t *pipe, void *args);

// Self test of this class
void
CZMQ_EXPORT void
zgossip_test (bool verbose);
// @end

Expand Down
5 changes: 3 additions & 2 deletions src/zgossip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
script = "zproto_server_c"
protocol_class = "zgossip_msg"
project_header = "../include/czmq.h"
export_macro = "CZMQ_EXPORT"
>
This is a server implementation of the ZeroMQ Gossip Discovery Protocol
<include filename = "license.xml" />
Expand Down Expand Up @@ -41,13 +42,13 @@
<event name = "PING">
<action name = "send" message = "PONG" />
</event>

<!-- All other protocol messages are invalid -->
<event name = "*">
<action name = "send" message = "INVALID" />
<action name = "terminate" />
</event>

<!-- This built-in event hits on a client timeout -->
<event name = "expired">
<action name = "terminate" />
Expand Down
18 changes: 12 additions & 6 deletions src/zgossip_engine.inc
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,27 @@ engine_broadcast_event (server_t *server, client_t *client, event_t event)
}
}

// Poll socket for activity, invoke handler on any received message.
// Handler must be a CZMQ zloop_fn function; receives server as arg.
// Poll actor or zsock for activity, invoke handler on any received
// message. Handler must be a CZMQ zloop_fn function; receives server
// as arg.

static void
engine_handle_socket (server_t *server, zsock_t *socket, zloop_reader_fn handler)
engine_handle_socket (server_t *server, void *sock, zloop_reader_fn handler)
{
if (server) {
s_server_t *self = (s_server_t *) server;
// Resolve zactor_t -> zsock_t
if (zactor_is (sock))
sock = zactor_sock ((zactor_t *) sock);
else
assert (zsock_is (sock));
if (handler != NULL) {
int rc = zloop_reader (self->loop, socket, handler, self);
int rc = zloop_reader (self->loop, (zsock_t *) sock, handler, self);
assert (rc == 0);
zloop_reader_set_tolerant (self->loop, socket);
zloop_reader_set_tolerant (self->loop, (zsock_t *) sock);
}
else
zloop_reader_end (self->loop, socket);
zloop_reader_end (self->loop, (zsock_t *) sock);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/zgossip_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@ zgossip_msg_test (bool verbose)
zgossip_msg_t *self = zgossip_msg_new ();
assert (self);
zgossip_msg_destroy (&self);

// Create pair of sockets we can send through
// We must bind before connect if we wish to remain compatible with ZeroMQ < v4
zsock_t *output = zsock_new (ZMQ_DEALER);
Expand All @@ -615,6 +614,7 @@ zgossip_msg_test (bool verbose)
rc = zsock_connect (input, "inproc://selftest-zgossip_msg");
assert (rc == 0);


// Encode/send/decode and verify each message type
int instance;
self = zgossip_msg_new ();
Expand Down

0 comments on commit c09a4d0

Please sign in to comment.