fixes for OpenVMS

This commit is contained in:
Brett Cameron 2010-05-12 12:45:12 +02:00 committed by Martin Sustrik
parent a25414e55c
commit 714a8d50a0
5 changed files with 85 additions and 10 deletions

View File

@ -25,6 +25,7 @@
#if defined ZMQ_HAVE_OPENVMS
#include <netinet/tcp.h>
#include <unistd.h>
#elif defined ZMQ_HAVE_WINDOWS
#include "windows.hpp"
#else

View File

@ -140,6 +140,10 @@ zmq::fd_t zmq::tcp_connecter_t::connect ()
#include <netdb.h>
#include <fcntl.h>
#ifdef ZMQ_HAVE_OPENVMS
#include <ioctl.h>
#endif
zmq::tcp_connecter_t::tcp_connecter_t () :
s (retired_fd)
{
@ -176,11 +180,17 @@ int zmq::tcp_connecter_t::open ()
return -1;
// Set to non-blocking mode.
int flags = fcntl (s, F_GETFL, 0);
if (flags == -1)
flags = 0;
int rc = fcntl (s, F_SETFL, flags | O_NONBLOCK);
#ifdef ZMQ_HAVE_OPENVMS
int flags = 1;
int rc = ioctl (s, FIONBIO, &flags);
errno_assert (rc != -1);
#else
int flags = fcntl (s, F_GETFL, 0);
if (flags == -1)
flags = 0;
int rc = fcntl (s, F_SETFL, flags | O_NONBLOCK);
errno_assert (rc != -1);
#endif
// Disable Nagle's algorithm.
int flag = 1;
@ -215,6 +225,8 @@ int zmq::tcp_connecter_t::open ()
errno = err;
return -1;
}
#ifndef ZMQ_HAVE_OPENVMS
else {
// Create the socket.
@ -243,6 +255,7 @@ int zmq::tcp_connecter_t::open ()
errno = err;
return -1;
}
#endif
zmq_assert (false);
return -1;

View File

@ -140,7 +140,14 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
#include <netinet/in.h>
#include <netdb.h>
#include <fcntl.h>
#ifndef ZMQ_HAVE_OPENVMS
#include <sys/un.h>
#endif
#ifdef ZMQ_HAVE_OPENVMS
#include <ioctl.h>
#endif
zmq::tcp_listener_t::tcp_listener_t () :
s (retired_fd)
@ -174,11 +181,17 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
errno_assert (rc == 0);
// Set the non-blocking flag.
flag = fcntl (s, F_GETFL, 0);
if (flag == -1)
flag = 0;
rc = fcntl (s, F_SETFL, flag | O_NONBLOCK);
#ifdef ZMQ_HAVE_OPENVMS
flag = 1;
rc = ioctl (s, FIONBIO, &flag);
errno_assert (rc != -1);
#else
flag = fcntl (s, F_GETFL, 0);
if (flag == -1)
flag = 0;
rc = fcntl (s, F_SETFL, flag | O_NONBLOCK);
errno_assert (rc != -1);
#endif
// Bind the socket to the network interface and port.
rc = bind (s, (struct sockaddr*) &addr, addr_len);
@ -196,6 +209,7 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
return 0;
}
#ifndef ZMQ_HAVE_OPENVMS
else if (strcmp (protocol_, "ipc") == 0) {
// Get rid of the file associated with the UNIX domain socket that
@ -235,6 +249,7 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
return 0;
}
#endif
else {
errno = EPROTONOSUPPORT;
return -1;
@ -249,6 +264,7 @@ int zmq::tcp_listener_t::close ()
return -1;
s = retired_fd;
#ifndef ZMQ_HAVE_OPENVMS
// If there's an underlying UNIX domain socket, get rid of the file it
// is associated with.
struct sockaddr_un *su = (struct sockaddr_un*) &addr;
@ -257,6 +273,7 @@ int zmq::tcp_listener_t::close ()
if (rc != 0)
return -1;
}
#endif
return 0;
}
@ -299,11 +316,17 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
errno_assert (sock != -1);
// Set to non-blocking mode.
#ifdef ZMQ_HAVE_OPENVMS
int flags = 1;
int rc = ioctl (sock, FIONBIO, &flags);
errno_assert (rc != -1);
#else
int flags = fcntl (s, F_GETFL, 0);
if (flags == -1)
if (flags == -1)
flags = 0;
int rc = fcntl (sock, F_SETFL, flags | O_NONBLOCK);
errno_assert (rc != -1);
#endif
struct sockaddr *sa = (struct sockaddr*) &addr;
if (AF_UNIX != sa->sa_family) {

View File

@ -97,6 +97,35 @@ const char *zmq::uuid_t::to_string ()
return string_buf;
}
#elif defined ZMQ_HAVE_OPENVMS
#include <starlet.h>
#define uuid_generate(x) sys$create_uid(&(x))
#define uuid_unparse(x, y) \
sprintf (y, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", \
x.data0, x.data1, x.data2, \
x.data3 [0], x.data3 [1], \
x.data3 [2], x.data3 [3], \
x.data3 [4], x.data3 [5], \
x.data3 [6], x.data3 [7]);
zmq::uuid_t::uuid_t ()
{
uuid_generate (uuid);
uuid_unparse (uuid, string_buf);
}
zmq::uuid_t::~uuid_t ()
{
}
const char *zmq::uuid_t::to_string ()
{
return string_buf;
}
#else
#include <stdio.h>

View File

@ -30,6 +30,14 @@
#include <uuid/uuid.h>
#elif defined ZMQ_HAVE_WINDOWS
#include <rpc.h>
#elif defined ZMQ_HAVE_OPENVMS
typedef struct
{
unsigned long data0;
unsigned short data1;
unsigned short data2;
unsigned char data3 [8];
} uuid_t;
#endif
namespace zmq
@ -77,7 +85,8 @@ namespace zmq
::uuid_t uuid;
char *string_buf;
#elif defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_SOLARIS ||\
defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_CYGWIN
defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_CYGWIN ||\
defined ZMQ_HAVE_OPENVMS
::uuid_t uuid;
char string_buf [uuid_string_len + 1];
#else