Skip to content

Commit bbce173

Browse files
committed
zmq-source: change the way how zmq-source handle the connection creation
* In the source case syslog-ng use pull socket. When you use pull socket you must connect to socket instead of bind and the other part has to bind. * E.g.: pull -> connect | push -> bind * Remove the lot of c test scripts and use python instead.
1 parent 5934b33 commit bbce173

File tree

5 files changed

+20
-144
lines changed

5 files changed

+20
-144
lines changed

modules/zmq/scripts/publisher.c

-35
This file was deleted.

modules/zmq/scripts/pusher.c

-54
This file was deleted.

modules/zmq/scripts/subscriber.c

-52
This file was deleted.

modules/zmq/scripts/test_pusher.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
3+
import time
4+
import zmq
5+
6+
def producer():
7+
context = zmq.Context()
8+
zmq_socket = context.socket(zmq.PUSH)
9+
zmq_socket.bind("tcp://127.0.0.1:8888")
10+
for num in xrange(10000):
11+
work_message = { 'num' : num }
12+
zmq_socket.send_json(work_message)
13+
14+
15+
producer()

modules/zmq/zmq-source.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ zmq_sd_set_port(LogDriver *source, gint port)
5151
{
5252
ZMQSourceDriver *self = (ZMQSourceDriver *)source;
5353
self->port = port;
54+
msg_info("Port set successfully!", evt_tag_int("Port: ", self->port), NULL);
5455
}
5556

5657
static void
@@ -91,9 +92,9 @@ create_zmq_context(ZMQSourceDriver* self)
9192

9293
gchar* address = get_address(self);
9394

94-
if (zmq_bind(self->socket, address) != 0)
95+
if (zmq_connect(self->socket, address) != 0)
9596
{
96-
msg_error("Failed to bind!", evt_tag_str("Bind address", address), evt_tag_errno("Error", errno),NULL);
97+
msg_error("Failed to connect!", evt_tag_str("Connect address", address), evt_tag_errno("Error", errno),NULL);
9798
g_free(address);
9899
return FALSE;
99100
}
@@ -230,8 +231,9 @@ zmq_sd_new(GlobalConfig *cfg)
230231
self->super.super.super.notify = zmq_sd_notify;
231232
self->super.super.super.free_fn = zmq_sd_free;
232233

233-
zmq_sd_set_address((LogDriver *) self, "*");
234+
zmq_sd_set_address((LogDriver *) self, "localhost");
234235
zmq_sd_set_port((LogDriver *) self, 5558);
236+
235237
log_reader_options_defaults(&self->reader_options);
236238
return &self->super.super;
237239
}

0 commit comments

Comments
 (0)