[zeromq-dev] Added ResolveEndPoint to ZMQ

Sean McKay sean at on-track-solutions.com
Thu Jun 25 17:54:30 CEST 2009


Martin Hurton pointed me in the right direction.  I've attached some patches
that have the memory leak resolved with the changes to allow for calling
ResolveEndPoint from a .Net client.

 

Thanks,

Sean

 

 

 

From: Sean McKay [mailto:sean at on-track-solutions.com] 
Sent: Wednesday, June 24, 2009 11:50 PM
To: 'zeromq-dev at mail.imatix.com'
Subject: RE: Added ResolveEndPoint to ZMQ

 

I have observed a memory leak - with the ResolveEndPoint function, and
haven't figured out how to free up the data, as calling zmq_free raises a
heabdb assertion error (e.g. if the commented out try block is uncommented).

 

How should I free up the memory that I am retrieving? 

 

    public string ResolveEndPoint(string hostname)

    {

        byte[] data;

        IntPtr locationPtr;

        ulong locationSize;

       // char[] data2 = new char[256];

        //string data2 = "";

        zmq_resolve_endpoint(this.transport, hostname, out locationPtr, out
locationSize); // out locationPtr, out locationSize);

        data = new byte[locationSize];

        Marshal.Copy(locationPtr,data,0,data.Length);

      

        //try

        //{

        //    zmq_free(locationPtr);

        //}

        //catch(Exception ex)

        //{

        //    Debug.WriteLine(ex.ToString());

        //}

        return Encoding.ASCII.GetString(data);

    }

 

Thanks,

Sean

 

From: Sean McKay [mailto:sean at on-track-solutions.com] 
Sent: Wednesday, June 24, 2009 10:24 AM
To: 'zeromq-dev at mail.imatix.com'
Subject: Added ResolveEndPoint to ZMQ

 

I'm not sure you'll want to apply these patches to the system, but I believe
having the ability to call ResolveEndPoint is a useful feature for a client.
In particular, some changes I should note:

 

I added a function in locator.cpp called resolve_endpoint_safe, which
doesn't use the asserts - rather if it runs into a reply that wasn't OK, it
sets the location variable to "UNKNOWN".  I do not code C++ for my day job
(and prefer not to! ;-), so please, if anyone has improvements or
reliability changes, feel free to make them.

 

Thanks,

 

Sean

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20090625/164b8669/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zmq_6_25_09_resolveEndPoint.patch
Type: application/octet-stream
Size: 3284 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20090625/164b8669/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Zmq_C#_6_25.patch
Type: application/octet-stream
Size: 3921 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20090625/164b8669/attachment-0001.obj>


More information about the zeromq-dev mailing list