[zeromq-dev] Fixes for AIX and HP-UX in 2.1.10

AJ Lewis aj.lewis at quantum.com
Tue Nov 8 19:16:04 CET 2011


Also note that I did not regenerate the automake/autoconf files - the
configure.in file is changed but nothing else since I have a newer
version of the Autotools.  Please run autogen.sh and commit those
changes on both 3-0 and 2-1 (or I can do it and submit that if you like,
it's just going to be done with automake 1.11 and autoconf 2.68)

Thanks,
AJ

On Tue, Nov 08, 2011 at 12:09:04PM -0600, AJ Lewis wrote:
> 
> On Tue, Nov 08, 2011 at 08:19:31AM +0900, Pieter Hintjens wrote:
> > On Mon, Nov 7, 2011 at 11:50 PM, AJ Lewis <aj.lewis at quantum.com> wrote:
> > 
> > >> I apply the patches to 3-0 there's a conflict (src/device.cpp is
> > >> deleted). Any chance you can make a pull request for 3-0 as well?
> > >
> > > Sure, I should be able to.  I'll check it out and see what I find.
> > >  You want both the AIX and HPUX fixes, correct?
> > 
> > (Sorry for the slow answer). Yes, please.
> 
> Attached are the HP-UX equivilant changes for the 3-0 branch.  I've also
> generated a pull request, though I'm afraid it's rather messy - I
> accidentally pushed in the middle of an interactive rebase, so things
> diverged in my own tree! I won't feel bad if you ignore the pull request
> and just apply the attached patches.
> 
> The AIX change was not necessary, but there are other changes that are
> still pending to get 3-0 working with AIX that I will send (hopefully)
> soon.
> 
> Thanks,
> -- 
> AJ Lewis
> Software Engineer
> Quantum Corporation
> 
> Work:    651 688-4346
> 
> ----------------------------------------------------------------------
> The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through anti virus and spam software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt.

> From 919228dd172845b943e4a7af1fa59c615487328e Mon Sep 17 00:00:00 2001
> From: AJ Lewis <aj.lewis at quantum.com>
> Date: Thu, 3 Nov 2011 11:37:41 -0500
> Subject: [PATCH 1/5] Use DCE library on HP-UX to handle UUID generation
> 
> This is the initial dumb implementation - it just replaces RAND_bytes
> in the final uuid case rather than handling uuid_create() as done in
> the BSD case.
> 
> It passes the self tests, but it's probably not the correct way to do
> it.
> 
> You can also use the openssl method my using the '--without-dce' flag
> to configure.
> 
> Signed-off-by: AJ Lewis <aj.lewis at quantum.com>
> ---
>  src/uuid.cpp |   13 ++++++++++++-
>  1 files changed, 12 insertions(+), 1 deletions(-)
> 
> diff --git a/src/uuid.cpp b/src/uuid.cpp
> index 02f716e..97bab27 100644
> --- a/src/uuid.cpp
> +++ b/src/uuid.cpp
> @@ -67,15 +67,26 @@ void zmq::generate_uuid (void *buf_)
>  
>  #else
>  
> +#if defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
> +#include <dce/uuid.h>
> +#else
>  #include <openssl/rand.h>
> +#endif
>  
>  void zmq::generate_uuid (void *buf_)
>  {
>      unsigned char *buf = (unsigned char*) buf_;
> -
> +#if defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
> +    ::uuid_t uuid;
> +    unsigned32 ret;
> +    uuid_create(&uuid, &ret);
> +    zmq_assert (ret == uuid_s_ok);
> +    memcpy(rand_buf, &uuid, sizeof(uuid));
> +#else
>      //  Generate random value.
>      int ret = RAND_bytes (buf, 16);
>      zmq_assert (ret == 1);
> +#endif
>  
>      //  Set UUID variant to 2 (UUID as specified in RFC4122).
>      const unsigned char variant = 2;
> -- 
> 1.7.7
> 

> From ebe1988a344a507df43e173fe0cdd1dfc621fab6 Mon Sep 17 00:00:00 2001
> From: AJ Lewis <aj.lewis at quantum.com>
> Date: Thu, 3 Nov 2011 11:57:52 -0500
> Subject: [PATCH 2/5] Implement DCE uuid calls properly
> 
> Create HPUX & LIBDCEKT specific sections similar to BSD section.  It's
> possible that these could be merged, but I'm not sure if it would be
> as readable because there are some type differences that might make
> things difficult.
> 
> Signed-off-by: AJ Lewis <aj.lewis at quantum.com>
> ---
>  src/uuid.cpp |   24 ++++++++++++------------
>  1 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/src/uuid.cpp b/src/uuid.cpp
> index 97bab27..6ec04f5 100644
> --- a/src/uuid.cpp
> +++ b/src/uuid.cpp
> @@ -46,6 +46,17 @@ void zmq::generate_uuid (void *buf_)
>      zmq_assert (status == uuid_s_ok);
>  }
>  
> +#elif defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
> +
> +#include <dce/uuid.h>
> +
> +void zqm::generate_uuid (void *buf_)
> +{
> +    unsigned32 status;
> +    uuid_create ((::uuid_t*) buf_, &status);
> +    zmq_assert (status == uuid_s_ok);
> +}
> +
>  #elif defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_SOLARIS ||\
>        defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_CYGWIN
>  
> @@ -67,26 +78,15 @@ void zmq::generate_uuid (void *buf_)
>  
>  #else
>  
> -#if defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
> -#include <dce/uuid.h>
> -#else
>  #include <openssl/rand.h>
> -#endif
>  
>  void zmq::generate_uuid (void *buf_)
>  {
>      unsigned char *buf = (unsigned char*) buf_;
> -#if defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
> -    ::uuid_t uuid;
> -    unsigned32 ret;
> -    uuid_create(&uuid, &ret);
> -    zmq_assert (ret == uuid_s_ok);
> -    memcpy(rand_buf, &uuid, sizeof(uuid));
> -#else
> +
>      //  Generate random value.
>      int ret = RAND_bytes (buf, 16);
>      zmq_assert (ret == 1);
> -#endif
>  
>      //  Set UUID variant to 2 (UUID as specified in RFC4122).
>      const unsigned char variant = 2;
> -- 
> 1.7.7
> 

> From 7505b66c125c11a5ef013d673057802182c9a8ec Mon Sep 17 00:00:00 2001
> From: AJ Lewis <aj.lewis at quantum.com>
> Date: Thu, 3 Nov 2011 12:10:35 -0500
> Subject: [PATCH 3/5] Combine the existing freebsd/netbsd section with the new
>  HP-UX DCE section
> 
> Using a couple #ifdefs, we can combine the freebsd/netbsd uuid section with
> the HP-UX DEC section in uuid.cpp.
> 
> Signed-off-by: AJ Lewis <aj.lewis at quantum.com>
> ---
>  src/uuid.cpp |   21 +++++++++------------
>  1 files changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/src/uuid.cpp b/src/uuid.cpp
> index 6ec04f5..fc17745 100644
> --- a/src/uuid.cpp
> +++ b/src/uuid.cpp
> @@ -35,24 +35,21 @@ void zmq::generate_uuid (void *buf_)
>      zmq_assert (ret == RPC_S_OK);
>  }
>  
> -#elif defined ZMQ_HAVE_FREEBSD || defined ZMQ_HAVE_NETBSD
> +#elif defined ZMQ_HAVE_FREEBSD || defined ZMQ_HAVE_NETBSD || (defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT)
>  
> +#ifdef ZMQ_HAVE_HPUX
> +#include <dce/uuid.h>
> +#else
>  #include <uuid.h>
> +#endif
>  
>  void zmq::generate_uuid (void *buf_)
>  {
> -    uint32_t status;
> -    uuid_create ((::uuid_t*) buf_, &status);
> -    zmq_assert (status == uuid_s_ok);
> -}
> -
> -#elif defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
> -
> -#include <dce/uuid.h>
> -
> -void zqm::generate_uuid (void *buf_)
> -{
> +#ifdef ZMQ_HAVE_HPUX
>      unsigned32 status;
> +#else
> +    uint32_t status;
> +#endif
>      uuid_create ((::uuid_t*) buf_, &status);
>      zmq_assert (status == uuid_s_ok);
>  }
> -- 
> 1.7.7
> 

> From 6eebb800207dd38a44a18c5a47ad4924ed794616 Mon Sep 17 00:00:00 2001
> From: AJ Lewis <aj.lewis at quantum.com>
> Date: Mon, 7 Nov 2011 15:24:12 -0600
> Subject: [PATCH 4/5] Put UUID into a temporary var when calling uuid_create()
>  and memcpy it into buf_
> 
> On HP-UX, when using libdcekt's uuid_create() function, I get bus
> errors if we attempt to use buf_ in uuid_create() directly.  It
> appears that the buffer needs to be aligned when it is passed through
> uuid_create().  So now we just create a temporary uuid_t, pass that to
> uuid_create(), and memcpy the result into the buf_, making sure to not
> overrun either buffer in the process.
> 
> Signed-off-by: AJ Lewis <aj.lewis at quantum.com>
> ---
>  src/uuid.cpp |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/src/uuid.cpp b/src/uuid.cpp
> index fc17745..8b1cbe8 100644
> --- a/src/uuid.cpp
> +++ b/src/uuid.cpp
> @@ -45,13 +45,20 @@ void zmq::generate_uuid (void *buf_)
>  
>  void zmq::generate_uuid (void *buf_)
>  {
> +    ::uuid_t tmp_uuid;
>  #ifdef ZMQ_HAVE_HPUX
>      unsigned32 status;
>  #else
>      uint32_t status;
>  #endif
> -    uuid_create ((::uuid_t*) buf_, &status);
> +    /* Make sure we don't overrun the buffer */
> +    int size = sizeof (tmp_uuid);
> +    if (size > 16)
> +	size = 16;
> +
> +    uuid_create (&tmp_uuid, &status);
>      zmq_assert (status == uuid_s_ok);
> +    memcpy (buf_, &tmp_uuid, size);
>  }
>  
>  #elif defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_SOLARIS ||\
> -- 
> 1.7.7
> 

> From 86fe189d6d2a18c663074ecb7371f6c331630953 Mon Sep 17 00:00:00 2001
> From: AJ Lewis <aj.lewis at quantum.com>
> Date: Tue, 8 Nov 2011 08:41:16 -0600
> Subject: [PATCH 5/5] Assert if buf_ passed into generate_uuid is NULL
> 
> Signed-off-by: AJ Lewis <aj.lewis at quantum.com>
> ---
>  src/uuid.cpp |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/src/uuid.cpp b/src/uuid.cpp
> index 8b1cbe8..45047e8 100644
> --- a/src/uuid.cpp
> +++ b/src/uuid.cpp
> @@ -31,6 +31,7 @@
>  
>  void zmq::generate_uuid (void *buf_)
>  {
> +    zmq_assert (buf_ != NULL);
>      RPC_STATUS ret = UuidCreate ((::UUID*) buf_);
>      zmq_assert (ret == RPC_S_OK);
>  }
> @@ -58,6 +59,7 @@ void zmq::generate_uuid (void *buf_)
>  
>      uuid_create (&tmp_uuid, &status);
>      zmq_assert (status == uuid_s_ok);
> +    zmq_assert (buf_ != NULL);
>      memcpy (buf_, &tmp_uuid, size);
>  }
>  
> @@ -68,6 +70,7 @@ void zmq::generate_uuid (void *buf_)
>  
>  void zmq::generate_uuid (void *buf_)
>  {
> +    zmq_assert (buf_ != NULL);
>      uuid_generate ((unsigned char*) buf_);
>  }
>  
> @@ -77,7 +80,8 @@ void zmq::generate_uuid (void *buf_)
>  
>  void zmq::generate_uuid (void *buf_)
>  {
> -    sys$create_uid(buf_);
> +    zmq_assert (buf_ != NULL);
> +    sys$create_uid(buf_);]
>  }
>  
>  #else
> @@ -86,6 +90,8 @@ void zmq::generate_uuid (void *buf_)
>  
>  void zmq::generate_uuid (void *buf_)
>  {
> +    zmq_assert (buf_ != NULL);
> +
>      unsigned char *buf = (unsigned char*) buf_;
>  
>      //  Generate random value.
> -- 
> 1.7.7
> 

> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev


-- 
AJ Lewis
Software Engineer
Quantum Corporation

Work:    651 688-4346



More information about the zeromq-dev mailing list