summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-03-23 17:44:16 +0100
committerMartin Sustrik <sustrik@250bpm.com>2011-03-23 17:44:16 +0100
commit941be8d2175332cb720f390f93d07a0870db8824 (patch)
tree79ed1c130c460901be85e9aeb0b584aa40be40ed /src
parentd4d184a750e2c09a39b95db9a54daf83aac5a446 (diff)
zmq_device removed
Devices are basically applications on top of 0MQ stack. They should reside in separate libraties. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/device.cpp120
-rw-r--r--src/device.hpp32
-rw-r--r--src/zmq.cpp18
4 files changed, 0 insertions, 172 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b730f38..f8d957f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -71,7 +71,6 @@ libzmq_la_SOURCES = \
connect_session.hpp \
ctx.hpp \
decoder.hpp \
- device.hpp \
devpoll.hpp \
dist.hpp \
encoder.hpp \
@@ -141,7 +140,6 @@ libzmq_la_SOURCES = \
ctx.cpp \
connect_session.cpp \
decoder.cpp \
- device.cpp \
devpoll.cpp \
dist.cpp \
encoder.cpp \
diff --git a/src/device.cpp b/src/device.cpp
deleted file mode 100644
index 351283a..0000000
--- a/src/device.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <stddef.h>
-
-#include "../include/zmq.h"
-
-#include "device.hpp"
-#include "socket_base.hpp"
-#include "likely.hpp"
-#include "err.hpp"
-
-int zmq::device (class socket_base_t *insocket_,
- class socket_base_t *outsocket_)
-{
- zmq_msg_t msg;
- int rc = zmq_msg_init (&msg);
-
- if (rc != 0) {
- return -1;
- }
-
- int64_t more;
- size_t moresz;
-
- zmq_pollitem_t items [2];
- items [0].socket = insocket_;
- items [0].fd = 0;
- items [0].events = ZMQ_POLLIN;
- items [0].revents = 0;
- items [1].socket = outsocket_;
- items [1].fd = 0;
- items [1].events = ZMQ_POLLIN;
- items [1].revents = 0;
-
- while (true) {
-
- // Wait while there are either requests or replies to process.
- rc = zmq_poll (&items [0], 2, -1);
- if (unlikely (rc < 0)) {
- return -1;
- }
-
- // The algorithm below asumes ratio of request and replies processed
- // under full load to be 1:1. Although processing requests replies
- // first is tempting it is suspectible to DoS attacks (overloading
- // the system with unsolicited replies).
-
- // Process a request.
- if (items [0].revents & ZMQ_POLLIN) {
- while (true) {
-
- rc = insocket_->recv (&msg, 0);
- if (unlikely (rc < 0)) {
- return -1;
- }
-
- moresz = sizeof (more);
- rc = insocket_->getsockopt (ZMQ_RCVMORE, &more, &moresz);
- if (unlikely (rc < 0)) {
- return -1;
- }
-
- rc = outsocket_->send (&msg, more ? ZMQ_SNDMORE : 0);
- if (unlikely (rc < 0)) {
- return -1;
- }
-
- if (!more)
- break;
- }
- }
-
- // Process a reply.
- if (items [1].revents & ZMQ_POLLIN) {
- while (true) {
-
- rc = outsocket_->recv (&msg, 0);
- if (unlikely (rc < 0)) {
- return -1;
- }
-
- moresz = sizeof (more);
- rc = outsocket_->getsockopt (ZMQ_RCVMORE, &more, &moresz);
- if (unlikely (rc < 0)) {
- return -1;
- }
-
- rc = insocket_->send (&msg, more ? ZMQ_SNDMORE : 0);
- if (unlikely (rc < 0)) {
- return -1;
- }
-
- if (!more)
- break;
- }
- }
-
- }
-
- return 0;
-}
-
diff --git a/src/device.hpp b/src/device.hpp
deleted file mode 100644
index c5b7118..0000000
--- a/src/device.hpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef __ZMQ_DEVICE_HPP_INCLUDED__
-#define __ZMQ_DEVICE_HPP_INCLUDED__
-
-namespace zmq
-{
-
- int device (class socket_base_t *insocket_,
- class socket_base_t *outsocket_);
-
-}
-
-#endif
diff --git a/src/zmq.cpp b/src/zmq.cpp
index 5029734..89848e7 100644
--- a/src/zmq.cpp
+++ b/src/zmq.cpp
@@ -40,7 +40,6 @@
#include <stdlib.h>
#include <new>
-#include "device.hpp"
#include "socket_base.hpp"
#include "msg_content.hpp"
#include "stdint.hpp"
@@ -729,23 +728,6 @@ int zmq_errno ()
return errno;
}
-int zmq_device (int device_, void *insocket_, void *outsocket_)
-{
- if (!insocket_ || !outsocket_) {
- errno = EFAULT;
- return -1;
- }
-
- if (device_ != ZMQ_FORWARDER && device_ != ZMQ_QUEUE &&
- device_ != ZMQ_STREAMER) {
- errno = EINVAL;
- return -1;
- }
-
- return zmq::device ((zmq::socket_base_t*) insocket_,
- (zmq::socket_base_t*) outsocket_);
-}
-
////////////////////////////////////////////////////////////////////////////////
// 0MQ utils - to be used by perf tests
////////////////////////////////////////////////////////////////////////////////