diff options
| -rw-r--r-- | bindings/python/pyzmq.cpp | 2 | ||||
| -rw-r--r-- | src/pgm_socket.cpp | 64 | ||||
| -rw-r--r-- | src/pgm_socket.hpp | 12 | 
3 files changed, 57 insertions, 21 deletions
| diff --git a/bindings/python/pyzmq.cpp b/bindings/python/pyzmq.cpp index 75f872d..425effe 100644 --- a/bindings/python/pyzmq.cpp +++ b/bindings/python/pyzmq.cpp @@ -17,11 +17,11 @@      along with this program.  If not, see <http://www.gnu.org/licenses/>.  */ +#include <Python.h>  #include <stddef.h>  #include <assert.h>  #include <errno.h>  #include <string.h> -#include <Python.h>  #include "../c/zmq.h" diff --git a/src/pgm_socket.cpp b/src/pgm_socket.cpp index 8be64f8..5067672 100644 --- a/src/pgm_socket.cpp +++ b/src/pgm_socket.cpp @@ -144,9 +144,22 @@ int zmq::pgm_socket_t::open_transport ()      struct pgm_transport_info_t *res = NULL;      if (!pgm_if_get_transport_info (network, NULL, &res, &pgm_error)) { -        errno = EINVAL; -	    g_error_free (pgm_error); -        return -1; + +        if (pgm_error->code == PGM_IF_ERROR_INVAL || +              pgm_error->code == PGM_IF_ERROR_XDEV || +              pgm_error->code == PGM_IF_ERROR_NODEV || +              pgm_error->code == PGM_IF_ERROR_NOTUNIQ || +              pgm_error->code == PGM_IF_ERROR_ADDRFAMILY || +              pgm_error->code == PGM_IF_ERROR_FAMILY || +              pgm_error->code == PGM_IF_ERROR_NODATA || +              pgm_error->code == PGM_IF_ERROR_NONAME || +              pgm_error->code == PGM_IF_ERROR_SERVICE) { +            errno = EINVAL; +	        g_error_free (pgm_error); +            return -1; +        } + +        zmq_assert (false);      }      res->ti_gsi = gsi; @@ -159,11 +172,16 @@ int zmq::pgm_socket_t::open_transport ()      }      if (!pgm_transport_create (&transport, res, &pgm_error)) { -        pgm_if_free_transport_info (res); -        //  TODO: tranlate errors from glib into errnos. -        errno = EINVAL; -        g_error_free (pgm_error); -        return -1; +        if (pgm_error->code == PGM_TRANSPORT_ERROR_INVAL || +              pgm_error->code == PGM_TRANSPORT_ERROR_PERM || +              pgm_error->code == PGM_TRANSPORT_ERROR_NODEV) { +            pgm_if_free_transport_info (res); +            g_error_free (pgm_error); +            errno = EINVAL; +            return -1; +        } + +        zmq_assert (false);      }      pgm_if_free_transport_info (res); @@ -316,10 +334,21 @@ int zmq::pgm_socket_t::open_transport ()      //  Bind a transport to the specified network devices.      if (!pgm_transport_bind (transport, &pgm_error)) { -        //  TODO: tranlate errors from glib into errnos. -        errno = EINVAL; -        g_error_free (pgm_error); -        return -1; +        if (pgm_error->code == PGM_IF_ERROR_INVAL || +              pgm_error->code == PGM_IF_ERROR_XDEV || +              pgm_error->code == PGM_IF_ERROR_NODEV || +              pgm_error->code == PGM_IF_ERROR_NOTUNIQ || +              pgm_error->code == PGM_IF_ERROR_ADDRFAMILY || +              pgm_error->code == PGM_IF_ERROR_FAMILY || +              pgm_error->code == PGM_IF_ERROR_NODATA || +              pgm_error->code == PGM_IF_ERROR_NONAME || +              pgm_error->code == PGM_IF_ERROR_SERVICE) { +            g_error_free (pgm_error); +            errno = EINVAL; +            return -1; +        } + +        zmq_assert (false);      }      return 0; @@ -492,7 +521,11 @@ ssize_t zmq::pgm_socket_t::receive (void **raw_data_, const pgm_tsi_t **tsi_)          const PGMIOStatus status = pgm_recvmsgv (transport, pgm_msgv,              pgm_msgv_len, MSG_DONTWAIT, &nbytes_rec, &pgm_error); -      + +        if (status == PGM_IO_STATUS_ERROR) { +            zmq_assert (false); +        } +          //  In a case when no ODATA/RDATA fired POLLIN event (SPM...)          //  pgm_recvmsg returns ?.          if (status == PGM_IO_STATUS_TIMER_PENDING) { @@ -520,7 +553,6 @@ ssize_t zmq::pgm_socket_t::receive (void **raw_data_, const pgm_tsi_t **tsi_)              return -1;          } -        //  Catch the rest of the errors.           zmq_assert (status == PGM_IO_STATUS_NORMAL);      } @@ -556,6 +588,10 @@ void zmq::pgm_socket_t::process_upstream ()      PGMIOStatus status = pgm_recvmsgv (transport, &dummy_msg,          1, MSG_DONTWAIT, &dummy_bytes, &pgm_error); +    if (status == PGM_IO_STATUS_ERROR) { +        zmq_assert (false); +    } +      //  No data should be returned.      zmq_assert (dummy_bytes == 0 && (status == PGM_IO_STATUS_TIMER_PENDING ||           status == PGM_IO_STATUS_RATE_LIMITED)); diff --git a/src/pgm_socket.hpp b/src/pgm_socket.hpp index ea37004..b1d0718 100644 --- a/src/pgm_socket.hpp +++ b/src/pgm_socket.hpp @@ -50,12 +50,6 @@ namespace zmq          //  Initialize PGM network structures (GSI, GSRs).          int init (bool udp_encapsulation_, const char *network_); - -        //  Open PGM transport. Parameters are the same as in constructor. -        int open_transport (); - -        //  Close transport. -        void close_transport ();          //   Get receiver fds and store them into user allocated memory.          void get_receiver_fds (int *receive_fd_, int *waiting_pipe_fd_); @@ -82,6 +76,12 @@ namespace zmq          void process_upstream ();      private: + +        //  Open PGM transport. +        int open_transport (); + +        //  Close transport. +        void close_transport ();          //  OpenPGM transport          pgm_transport_t* transport; | 
