summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@fastmq.commkdir>2009-12-21 18:50:24 +0100
committerMartin Sustrik <sustrik@fastmq.commkdir>2009-12-21 18:50:24 +0100
commit5a0674dfeccf0d80dc92e77a8630be280c71fb84 (patch)
tree2d98eb4435b0c15f72488b6a1d6aebb0847d4eaf /src
parent990a1e8686bdeb3472a27d00cb2436936a4d0d26 (diff)
OpenPGM error handling improved
Diffstat (limited to 'src')
-rw-r--r--src/pgm_socket.cpp64
-rw-r--r--src/pgm_socket.hpp12
2 files changed, 56 insertions, 20 deletions
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;