summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-02-16 10:28:49 +0900
committerMartin Sustrik <sustrik@250bpm.com>2012-02-16 10:28:49 +0900
commita0d548e6cdef36a8dae6e6834252475728bf8583 (patch)
treec5f91d31926322bab95143d7f6e91c35bd37ac04 /src
parent8bf03ce698c49d26bed3079003e59243b72af05a (diff)
ZMQ_REENTRANT functionality removed
It doesn't play well with multipart messages. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r--src/ctx.cpp21
-rw-r--r--src/ctx.hpp6
-rw-r--r--src/socket_base.cpp13
-rw-r--r--src/socket_base.hpp9
-rw-r--r--src/xs.cpp12
5 files changed, 1 insertions, 60 deletions
diff --git a/src/ctx.cpp b/src/ctx.cpp
index 789cdc2..98d3b86 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -47,8 +47,7 @@ xs::ctx_t::ctx_t (uint32_t io_threads_) :
monitor (NULL),
log_socket (NULL),
max_sockets (512),
- io_thread_count (io_threads_),
- reentrant (false)
+ io_thread_count (io_threads_)
{
}
@@ -154,16 +153,6 @@ int xs::ctx_t::setctxopt (int option_, const void *optval_, size_t optvallen_)
max_sockets = *((int*) optval_);
opt_sync.unlock ();
break;
- case XS_REENTRANT:
- if (optvallen_ != sizeof (int) || (*((int*) optval_) != 0 &&
- *((int*) optval_) != 1)) {
- errno = EINVAL;
- return -1;
- }
- opt_sync.lock ();
- reentrant = (*((int*) optval_) ? true : false);
- opt_sync.unlock ();
- break;
default:
errno = EINVAL;
return -1;
@@ -396,14 +385,6 @@ void xs::ctx_t::publish_logs (const char *text_)
log_sync.unlock ();
}
-bool xs::ctx_t::is_reentrant ()
-{
- opt_sync.lock ();
- bool ret = reentrant;
- opt_sync.unlock ();
- return ret;
-}
-
// The last used socket ID, or 0 if no socket was used so far. Note that this
// is a global variable. Thus, even sockets created in different contexts have
// unique IDs.
diff --git a/src/ctx.hpp b/src/ctx.hpp
index e912443..56b5d4c 100644
--- a/src/ctx.hpp
+++ b/src/ctx.hpp
@@ -100,9 +100,6 @@ namespace xs
void log (int sid_, const char *text_);
void publish_logs (const char *text_);
- // True, if API is expected to be reentrant.
- bool is_reentrant ();
-
enum {
term_tid = 0,
reaper_tid = 1
@@ -176,9 +173,6 @@ namespace xs
// Number of I/O threads to launch.
uint32_t io_thread_count;
- // True, if API is expected to be reentrant.
- bool reentrant;
-
// Synchronisation of access to context options.
mutex_t opt_sync;
diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index 7ab00ea..38ec8c1 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -117,7 +117,6 @@ xs::socket_base_t *xs::socket_base_t::create (int type_, class ctx_t *parent_,
xs::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_, int sid_) :
own_t (parent_, tid_),
tag (0xbaddecaf),
- reentrant (parent_->is_reentrant ()),
ctx_terminated (false),
destroyed (false),
last_tsc (0),
@@ -146,18 +145,6 @@ void xs::socket_base_t::stop ()
send_stop ();
}
-void xs::socket_base_t::lock ()
-{
- if (reentrant)
- sync.lock ();
-}
-
-void xs::socket_base_t::unlock ()
-{
- if (reentrant)
- sync.unlock ();
-}
-
int xs::socket_base_t::parse_uri (const char *uri_,
std::string &protocol_, std::string &address_)
{
diff --git a/src/socket_base.hpp b/src/socket_base.hpp
index dd1fee7..16f7c61 100644
--- a/src/socket_base.hpp
+++ b/src/socket_base.hpp
@@ -65,10 +65,6 @@ namespace xs
// This function can be called from a different thread!
void stop ();
- // Synchronise access of application threads to the socket.
- void lock ();
- void unlock ();
-
// Interface for communication with the API layer.
int setsockopt (int option_, const void *optval_, size_t optvallen_);
int getsockopt (int option_, void *optval_, size_t *optvallen_);
@@ -145,11 +141,6 @@ namespace xs
// Used to check whether the object is a socket.
uint32_t tag;
- // Synchronisation of access to the socket. If Crossroads are running
- // in non-reentrant mode, it is a dummy mutex-like object.
- bool reentrant;
- mutex_t sync;
-
// If true, associated context was already terminated.
bool ctx_terminated;
diff --git a/src/xs.cpp b/src/xs.cpp
index a4ed3a1..99a3bae 100644
--- a/src/xs.cpp
+++ b/src/xs.cpp
@@ -180,9 +180,7 @@ int xs_setsockopt (void *s_, int option_, const void *optval_,
errno = ENOTSOCK;
return -1;
}
- s->lock ();
int rc = s->setsockopt (option_, optval_, optvallen_);
- s->unlock ();
return rc;
}
@@ -193,9 +191,7 @@ int xs_getsockopt (void *s_, int option_, void *optval_, size_t *optvallen_)
errno = ENOTSOCK;
return -1;
}
- s->lock ();
int rc = s->getsockopt (option_, optval_, optvallen_);
- s->unlock ();
return rc;
}
@@ -206,9 +202,7 @@ int xs_bind (void *s_, const char *addr_)
errno = ENOTSOCK;
return -1;
}
- s->lock ();
int rc = s->bind (addr_);
- s->unlock ();
return rc;
}
@@ -219,9 +213,7 @@ int xs_connect (void *s_, const char *addr_)
errno = ENOTSOCK;
return -1;
}
- s->lock ();
int rc = s->connect (addr_);
- s->unlock ();
return rc;
}
@@ -281,9 +273,7 @@ int xs_sendmsg (void *s_, xs_msg_t *msg_, int flags_)
return -1;
}
int sz = (int) xs_msg_size (msg_);
- s->lock ();
int rc = s->send ((xs::msg_t*) msg_, flags_);
- s->unlock ();
if (unlikely (rc < 0))
return -1;
return sz;
@@ -296,9 +286,7 @@ int xs_recvmsg (void *s_, xs_msg_t *msg_, int flags_)
errno = ENOTSOCK;
return -1;
}
- s->lock ();
int rc = s->recv ((xs::msg_t*) msg_, flags_);
- s->unlock ();
if (unlikely (rc < 0))
return -1;
return (int) xs_msg_size (msg_);