summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-02-18 14:15:10 +0100
committerMartin Sustrik <sustrik@250bpm.com>2011-02-18 14:15:10 +0100
commit17e2ca71b4f6db76a4848d366defa36f1b19bdd7 (patch)
tree91cf1d4b619e245553f4bcc7b5b10ce2574cf815 /src
parent1f536b2d3820ba5435086a77ad34d86a432b94c7 (diff)
Logging of duplicit identities added
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r--src/ctx.cpp12
-rw-r--r--src/ctx.hpp3
-rw-r--r--src/object.cpp8
-rw-r--r--src/object.hpp2
-rw-r--r--src/session.cpp1
5 files changed, 20 insertions, 6 deletions
diff --git a/src/ctx.cpp b/src/ctx.cpp
index 024e813..84f9b03 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -291,14 +291,22 @@ zmq::endpoint_t zmq::ctx_t::find_endpoint (const char *addr_)
return *endpoint;
}
-void zmq::ctx_t::log (zmq_msg_t *msg_)
+void zmq::ctx_t::log (const char *format_, va_list args_)
{
+ // Create the log message.
+ zmq_msg_t msg;
+ int rc = zmq_msg_init_size (&msg, strlen (format_) + 1);
+ zmq_assert (rc == 0);
+ memcpy (zmq_msg_data (&msg), format_, zmq_msg_size (&msg));
+
// At this point we migrate the log socket to the current thread.
// We rely on mutex for executing the memory barrier.
log_sync.lock ();
if (log_socket)
- log_socket->send (msg_, 0);
+ log_socket->send (&msg, 0);
log_sync.unlock ();
+
+ zmq_msg_close (&msg);
}
diff --git a/src/ctx.hpp b/src/ctx.hpp
index c07711e..04449c4 100644
--- a/src/ctx.hpp
+++ b/src/ctx.hpp
@@ -23,6 +23,7 @@
#include <map>
#include <vector>
#include <string>
+#include <stdarg.h>
#include "../include/zmq.h"
@@ -85,7 +86,7 @@ namespace zmq
endpoint_t find_endpoint (const char *addr_);
// Logging.
- void log (zmq_msg_t *msg_);
+ void log (const char *format_, va_list args_);
enum {
term_tid = 0,
diff --git a/src/object.cpp b/src/object.cpp
index 9ec73f7..1376699 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -18,6 +18,7 @@
*/
#include <string.h>
+#include <stdarg.h>
#include "object.hpp"
#include "ctx.hpp"
@@ -151,9 +152,12 @@ void zmq::object_t::destroy_socket (socket_base_t *socket_)
ctx->destroy_socket (socket_);
}
-void zmq::object_t::log (zmq_msg_t *msg_)
+void zmq::object_t::log (const char *format_, ...)
{
- ctx->log (msg_);
+ va_list args;
+ va_start (args, format_);
+ ctx->log (format_, args);
+ va_end (args);
}
zmq::io_thread_t *zmq::object_t::choose_io_thread (uint64_t affinity_)
diff --git a/src/object.hpp b/src/object.hpp
index 748a339..af4303c 100644
--- a/src/object.hpp
+++ b/src/object.hpp
@@ -52,7 +52,7 @@ namespace zmq
void destroy_socket (class socket_base_t *socket_);
// Logs an message.
- void log (zmq_msg_t *msg_);
+ void log (const char *format_, ...);
// Chooses least loaded I/O thread.
class io_thread_t *choose_io_thread (uint64_t affinity_);
diff --git a/src/session.cpp b/src/session.cpp
index 350d043..645ebf0 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -234,6 +234,7 @@ void zmq::session_t::process_attach (i_engine *engine_,
// If the session already has an engine attached, destroy new one.
// Note new engine is not plugged in yet, we don't have to unplug it.
if (engine) {
+ log ("DPID: duplicate peer identity - disconnecting peer");
delete engine_;
return;
}