Giter Club home page Giter Club logo

zmq's Introduction

README

OVERVIEW

This repository contains various modules for the libzmq Perl binding

INDEX

TRAVIS CI

Build Status

MODULES IN THIS REPOSITORY

Note that released versions for any of these modules can be downloaded via cpan/cpanm.

cpan command comes with Perl itself, but we recommend cpanm. If you don't have cpanm installed. Please see the README at https://github.com/miyagawa/cpanminus for details on how to install cpanm

With cpanm, you can install the ZMQ perl bindings like so:

cpanm ZMQ::LibZMQ2

Check for what's available on CPAN from the following links:

If the particular version you're looking for isn't up on CPAN, you need to build/install them yourself from this repository. See the listing below for details.

Note that you need Module::Install and several other plugins. Each module's Makefile.PL should warn you, but since this would be a "for developers" version, it is ultimately your responsibility to check for the environment.

ZMQ-Constants

Lists the constants used in libzmq.

Pure Perl, required by all other modules.

perl Makefile.PL
make
make test
make install

ZMQ-LibZMQ2

Binding to the libzmq (2.x) library.

Requires a C compiler, and libzmq 2.1.x.

If you have pkg-config, libzmq should be automatically detected:

perl Makefile.PL
make
make test
make install

If you don't have pkg-config, or if you're installing against a manually installed libzmq:

ZMQ_HOME=/path/to/libzmq perl Makefile.PL
make
make test
make install

If you have multiple libzmq's installed and for some reason this module finds the wrong libzmq, you might need to tweak the generated Makefile. See CAVEATS for details.

ZMQ-LibZMQ3

Binding to the libzmq (3.x) library

Requires a C compiler, and libzmq 3.1.x.

If you have pkg-config, libzmq should be automatically detected:

perl Makefile.PL
make
make test
make install

If you don't have pkg-config, or if you're installing against a manually installed libzmq:

ZMQ_HOME=/path/to/libzmq perl Makefile.PL
make
make test
make install

If you have multiple libzmq's installed and for some reason this module finds the wrong libzmq, you might need to tweak the generated Makefile. See CAVEATS for details.

ZMQ

Perl-ish libzmq wrapper. Use ZMQ::LibZMQ2 and ZMQ::LibZMQ3 for direct one-to-one mapping for zmq functions.

The author recommends that you use ZMQ::LibZMQ[23] for most use cases -- ZMQ.pm tries to be "nice", but isn't exactly free from things like API changes between libzmq2 <-> libzmq3.

For example, with ZMQ.pm you need to be conscious about using recv and/or recvmsg. This would be problematic for "portable" code... so the only sane suggestion is to use ZMQ.pm only for one off scripts, and for other purposes explicitly specify the libzmq version you're using via an explicit "use ZMQ::LibZMQ[23]"

Pure Perl, but requires either ZMQ::LibZMQ2 or ZMQ::LibZMQ3.

perl Makefile.PL
make
make test
make install

ZMQ-LibCZMQ1

Binding to the high-level C API library czmq (http://czmq.zeromq.org). Highly experimental. Your help/contribution is much appreciated.

Requires a C compiler.

If you have pkg-config, czmq should be automatically detected:

perl Makefile.PL
make
make test
make install

If you don't have pkg-config, or if you're installing against a manually installed libczmq:

CZMQ_HOME=/path/to/czmq perl Makefile.PL
make
make test
make install

If you have multiple libzmq's installed and for some reason this module finds the wrong libzmq, you might need to tweak the generated Makefile. See CAVEATS for details.

ZMQ-CZMQ

Perl-ish libczmq wrapper. Uses ZMQ::LibCZMQ1 internally.

CAVEATS

Tweaking the Makefile

I've seen cases where generated Makefile contains something like:

LDDLFLAGS = .... -L/usr/local/lib
(snip)
EXTRALIBS = -L/path/to/other-zmq -lzmq
LDLOADLIBS = -L/path/to/other-zmq -lzmq

What happens is that LDDLFLAGS is used BEFORE the other variables, and many compilers searches for libraries in that order, so if you have old libzmq in /usr/local/lib, then we might find that one first.

What you can do is first remove the -L/usr/local/lib, and see if that works. If that fails, you might want to try moving -L/usr/local/lib from LDDLFLAGS and append it to EXTRALIBS and LDLOADLIBS.

These details vary greatly depending on your system, so if this doesn't work and you must file an issue, make sure to put as much as detail as possible.

zmq's People

Contributors

aelse avatar alambike avatar antoniomonty avatar bjakubski avatar bkmit avatar bluca avatar cdybedahl avatar chylli-deriv avatar domm avatar kromg avatar lestrrat avatar melo avatar mishin avatar mosconi avatar nponeccop avatar potatogim avatar pstuifzand avatar rhrhunter avatar shripchenko avatar tsee avatar xxzgc avatar zmughal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zmq's Issues

ZMQ::LibZMQ3 missing int64 types on Strawberry Perl

Strawberry Perl doesn't define a number of useful data types that the ZMO family depends on.

These are the same data types used in libzmq itself, but libzmq has a header stdint.hpp that defines the types:

From zmq/stdint.hpp, line 32:

ifndef int8_t

typedef __int8 int8_t;

endif

ifndef int16_t

typedef __int16 int16_t;

endif

ifndef int32_t

typedef __int32 int32_t;

endif

ifndef int64_t

typedef __int64 int64_t;

endif

ifndef uint8_t

typedef unsigned __int8 uint8_t;

endif

ifndef uint16_t

typedef unsigned __int16 uint16_t;

endif

ifndef uint32_t

typedef unsigned __int32 uint32_t;

endif

ifndef uint64_t

typedef unsigned __int64 uint64_t;

endif

These defintions aren't anywhere in the ZMQ::LibZM!Q sources, so they won't build.

I'm not sure the best place to fix them, or if the same logic in the stdint.hpp file needs to be included; there's a mess of #ifdefs and stuff to only do this on certain platforms.

ZMQ::LibZMQ2 + fork = Assertion failed: ok (mailbox.cpp:84)

Hi,

libzmq 2.2.0 via brew install zeromq, Mac OS X 10.6.8, 10.8.0 and CentOS 6 (repo from http://www.zeromq.org/distro:centos). ZMQ::LibZMQ2 1.01 (latest)

I've opened this first in the ZeroMQ repo (see https://github.com/lestrrat/ZeroMQ-Perl/issues/42) but the problem is also present with ZMQ::LibZMQ2.

I've copied and pasted the description from the other issue here:

Scenario:

  • create a context;
  • fork;
  • in the child, create a new context (no context reuse across processes), plus pub socket;
  • in the parent create sub socket;

At this point both parent and child can exchange messages without any problems. Then:

  • in the child send a message, and terminate the process cleanly, making sure we close socket and terminate context;
  • the parent gets an assertion failed message: Assertion failed: ok (mailbox.cpp:84)

I can reproduce it perfectly with a small perl script: https://gist.github.com/3416913#file_test_zmq.pl (updated to ZMQ::) but with a similar C program using the libzmq directly I fail to reproduce it.

The exception is shown when the main threads is inside the sleep around line 31, immediately after the child exits. It might be a signals problem, but I don't really know.

The C program that works: https://gist.github.com/3416913#file_test.c

Using ZMQ::call for connecting insock <=> outsock as a QUEUE fails.

#!/usr/bin/env perl

BEGIN {
    $ENV { PERL_ZMQ_BACKEND } = 'ZMQ::LibZMQ2';
}

use strict;
use warnings;

use ZMQ;
use ZMQ::Constants qw(ZMQ_DEALER ZMQ_ROUTER ZMQ_QUEUE);

my $context = ZMQ::Context->new();

my $frontend = $context->socket(ZMQ_ROUTER);
$frontend->bind('tcp://*:5559');

my $backend = $context->socket(ZMQ_DEALER);
$backend->bind('tcp://*:5560');

ZMQ::call('zmq_device', ZMQ_QUEUE, $frontend, $backend);
OUTPUT:

ZMQ::LibZMQ2::Socket: Invalid ZMQ::LibZMQ2::Socket object was passed to mg_find at queue.pl line 20.

Let ZMQ::Socket do the right thing independent of the backend

In the ZMQ module there is some code that checks which backend is used when to use the send/sendmsg and recv/recvmsg methods.

I wanted to add send_multipart and recv_multipart methods. That depends on the methods for sending and receiving. Could ZMQ be changed so there is a method for sending and a method for recieving that doesn't change when a different backend is used?

I guess this is useful, because there is another name change coming up for send/sendmsg/msg_send. http://api.zeromq.org/3-2:zmq-msg-send

So why don't we choose a name now and make sure it keeps the same interface when a backend changes.

Argument is not an object

I'm attempting to use ZMQ with AnyEvent in away that was documented for ZeroMQ, using ZMQ_FD.

In the following code, every message is received by the server, but I get an extra message returned by $sock->recv. It is ZMQ::Message wraps a the scalar, 2, rather than a ZMQ::LibZMQ2::Message. So, calling $msg->data fails.

#!/usr/bin/env perl
use warnings;
use strict;
use ZMQ;
use ZMQ::Constants qw/ZMQ_PUSH ZMQ_PULL ZMQ_RCVMORE ZMQ_FD/;
use AnyEvent;
use File::Temp qw/tempdir/;

print "zmq_version: ", ZMQ::call('zmq_version'), "\n";

my $dir = tempdir(CLEANUP => 1);

my $sock_name = "ipc://$dir/zmqsock.ipc";
my $ctx = ZMQ::Context->new(1);

my $cv = AE::cv;

sub run_server {
    my $sock= $ctx->socket(ZMQ_PULL);
    $sock->bind($sock_name);
    my $fh = $sock->getsockopt(ZMQ_FD);

    my $w; $w = AE::io $fh, 0, sub {
        while ( my $msg = $sock->recv(ZMQ_RCVMORE) ) {
            my $text = $msg->data;
            print "$text\n";
            $cv->end;
        }

        undef $w;
    };
}

sub run_client {
    my $sock = $ctx->socket(ZMQ_PUSH);
    $sock->connect($sock_name);

    for (1..3) {
        $cv->begin;
        my $msg = ZMQ::Message->new("message number $_");
        $sock->send($msg);
    }
}

$cv->begin;
run_server();
run_client();
$cv->end;

$cv->recv;

Here's the output from a run on my system:

zmq_version: 2.2.0
message number 1
message number 2
message number 3
EV: error in callback (ignoring): Argument is not an object at (eval 10) line 3.

Admittedly, I may be doing something entirely wrong here and this may not be a bug in your code or the 0MQ libraries. Thank you for having a look at it.

p5-ZMQ fails to build correctly against a custom zeromq build installation

I have built zeromq to install into /opt/zimbra/zeromq-3.2.0

However, when I build the perl module, it fails:

[root@zre-rhel6-64 ZMQ-LibZMQ3-1.00]# PKG_CONFIG_PATH=/opt/zimbra/zeromq-3.2.0/lib/pkgconfig ZMQ_HOME=/opt/zimbra/zeromq-3.2.0 perl Makefile.PL
Cannot determine perl version info from lib/ZMQ/LibZMQ3.pm
Probing environment variables:

  • Detected ZMQ_INCLUDES from ZMQ_HOME...
  • Detected ZMQ_H from ZMQ_HOME...
  • Detected ZMQ_LIBS from ZMQ_HOME...
    Probing libzmq via pkg-config ...
  • found libzmq 3.2.0
    Detected the following ZMQ settings:
  • ZMQ_HOME = /opt/zimbra/zeromq-3.2.0
  • ZMQ_H = /opt/zimbra/zeromq-3.2.0/include/zmq.h
  • ZMQ_INCLUDES = /opt/zimbra/zeromq-3.2.0/include
  • ZMQ_LIBS = -L/opt/zimbra/zeromq-3.2.0/lib
  • ZMQ_TRACE = (null)
    Detecting zmq version...
  • Detected libzmq version 3.2.0
    /home/build/p4/main/ThirdParty/Perl/tmp/ZMQ-LibZMQ3-1.00/assertlibQXk5EBbQ: error while loading shared libraries: libzmq.so.3: cannot open shared object file: No such file or directory
    wrong result: 'zmq'

ZMQ-LibCZMQ1 Bool -> bool

This is something I'm not sure that this is proper fix. But I needed this to make it work at RHEL5/RHEL6.

diff -ur ZMQ-LibCZMQ1-0.03-/src/perl_czmq.xs ZMQ-LibCZMQ1-0.03/src/perl_czmq.xs
--- ZMQ-LibCZMQ1-0.03-/src/perl_czmq.xs 2013-01-09 07:31:05.000000000 +0200
+++ ZMQ-LibCZMQ1-0.03/src/perl_czmq.xs  2013-05-12 15:57:38.000000000 +0300
@@ -232,7 +232,7 @@
     OUTPUT:
         RETVAL

-Bool
+bool
 zsocket_poll( socket, msecs)
         PerlLibCZMQ1_zsocket_raw *socket;
         int msecs;
@@ -591,7 +591,7 @@
 zframe_strdup(frame)
         PerlLibCZMQ1_zframe *frame;

-Bool
+bool
 zframe_streq(frame, string)
         PerlLibCZMQ1_zframe *frame;
         char *string;
@@ -600,7 +600,7 @@
 zframe_more(frame)
         PerlLibCZMQ1_zframe *frame;

-Bool
+bool
 zframe_eq(self, other)
         PerlLibCZMQ1_zframe *self;
         PerlLibCZMQ1_zframe *other;
diff -ur ZMQ-LibCZMQ1-0.03-/tools/genfiles.pl ZMQ-LibCZMQ1-0.03/tools/genfiles.pl
--- ZMQ-LibCZMQ1-0.03-/tools/genfiles.pl        2013-01-07 11:32:42.000000000 +0200
+++ ZMQ-LibCZMQ1-0.03/tools/genfiles.pl 2013-05-12 15:56:56.000000000 +0300
@@ -166,7 +166,7 @@
     my (@decl, @input, @output);

     push @decl, "const void * T_PV";
-    push @decl, "Bool         T_BOOL";
+    push @decl, "bool         T_BOOL";
     push @decl, "byte *       T_PV";
     push @decl, "PerlLibCZMQ1_zsocket_raw* PERLCZMQ_ZSOCKET_RAW";
     push @input, <<EOM;

ZMQ::LibZMQ2 build fails

What I tried

I very much appreciate and sympathize with the efforts made towards developing this module.

(I am not 100% sure if I should post this bug report as ZMQ::LibZMQ3 is out and maybe I should try that instead)

I'd like to report a problem.

I am running Perl 5.14.2.

I will describe all my install attempt: I first ran git clone [email protected]:zeromq/libzmq.git to get the source for 0MQ.

Then I installed it to my $HOME with ./autogen.sh ; ./configure --prefix=$HOME/local; make; make install;

After this I added these lines to my ~/.bashrc so that:

  • the header will be automatically detected by gcc

  • the library will be found by gcc

  • pkg-config is able to find the libzmq.pc

    export C_INCLUDE_PATH=$C_INCLUDE_PATH:$HOME/local/include
    export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$HOME/local/include
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/local/lib/pkgconfig

Now I'm going to try to install ZMQ::LibZMQ2 from CPAN like this cpanm ZMQ::LibZMQ2 , however, I am getting this:

Detected the following ZMQ settings:
 + ZMQ_HOME = (null)
 + ZMQ_H = (null)
 + ZMQ_INCLUDES = 
 + ZMQ_LIBS = -L/home/user/local/lib -lzmq  
 + ZMQ_TRACE = (null)

So I thought, ok I will give it what it needs(I am unsure if I did this right):

ZMQ_HOME=/home/user/local/lib/ \
ZMQ_H=/home/user/local/include/zmq.h \
ZMQ_INCLUDES=/home/user/local/include \
ZMQ_LIBS=/home/user/local/lib perl Makefile.PL

The result

user@user-K56CM:~/.cpanm/work/1365728991.21838/ZMQ-LibZMQ2-1.07$ make
cp lib/ZMQ/LibZMQ2.pm blib/lib/ZMQ/LibZMQ2.pm
/usr/bin/perl "-Iinc" /usr/share/perl/5.14/ExtUtils/xsubpp  -typemap /usr/share/perl/5.14/ExtUtils/typemap  xs/perl_libzmq2.xs > xs/perl_libzmq2.xsc && mv xs/perl_libzmq2.xsc xs/perl_libzmq2.c
cc -c  "-I." "-I/home/user/local/include" "-Ixs" "-I." -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -Wno-comment -O2 -g   -DVERSION=\"1.07\" -DXS_VERSION=\"1.07\" -o xs/perl_libzmq2.o -fPIC "-I/usr/lib/perl/5.14/CORE"  -DUSE_PPPORT xs/perl_libzmq2.c
xs/perl_libzmq2.xs: In function 'XS_ZMQ__LibZMQ2_zmq_recv':
xs/perl_libzmq2.xs:681:9: error: too few arguments to function 'zmq_recv'
In file included from xs/perl_libzmq2.h:7:0,
                 from xs/perl_libzmq2.xs:1:
/home/user/local/include/zmq.h:213:16: note: declared here
xs/perl_libzmq2.xs: In function 'XS_ZMQ__LibZMQ2__zmq_send':
xs/perl_libzmq2.xs:706:9: error: too few arguments to function 'zmq_send'
In file included from xs/perl_libzmq2.h:7:0,
                 from xs/perl_libzmq2.xs:1:
/home/user/local/include/zmq.h:212:16: note: declared here
xs/perl_libzmq2.c: In function 'XS_ZMQ__LibZMQ2_zmq_poll':
xs/perl_libzmq2.c:2328:7: warning: unused variable 'RETVAL' [-Wunused-variable]
xs/perl_libzmq2.xs: In function 'XS_ZMQ__LibZMQ2_zmq_device':
xs/perl_libzmq2.xs:882:9: warning: implicit declaration of function 'zmq_device' [-Wimplicit-function-declaration]
make: *** [xs/perl_libzmq2.o] Error 1

Questions

Is ZMQ::LibZMQ2 still recommended or should ::LibZMQ3 be used instead ?
If ::LibZMQ2 can still be used, what libzmq version should it be used with ?

API Unification

The differences between zmq2 and zmq3 could be effectively papered over by providing a superset of the APIs down at the ZMQ level. For example, sendmsg and recvmsg can easily be made to work on ZMQ::Socket using both underlying libraries.

Are you open to this kind of change?

Also, error reporting would be Much Nicer if either $! integration were more advanced or zmq_strerror was exposed via the base ZMQ. Or both.

p5-ZMQ incorrectly tries to link to -luuid on linux systems

When installing on a linux box, p5-ZMQ tries to link to non-existent library "uuid":

[root@zre-rhel6-64 ZMQ-LibZMQ3-1.00]# make
cp lib/ZMQ/LibZMQ3.pm blib/lib/ZMQ/LibZMQ3.pm
/usr/bin/perl "-Iinc" /usr/share/perl5/ExtUtils/xsubpp -typemap /usr/share/perl5/ExtUtils/typemap xs/perl_libzmq3.xs > xs/perl_libzmq3.xsc && mv xs/perl_libzmq3.xsc xs/perl_libzmq3.c
gcc -c "-I." "-I/opt/zimbra/zeromq-3.2.0/include" "-Ixs" "-I." -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wdeclaration-after-statement -Wc++-compat -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DVERSION="1.00" -DXS_VERSION="1.00" -o xs/perl_libzmq3.o -fPIC "-I/usr/lib64/perl5/CORE" -DUSE_PPPORT xs/perl_libzmq3.c
xs/perl_libzmq3.c: In function 'XS_ZMQ__LibZMQ3_zmq_poll':
xs/perl_libzmq3.c:2488: warning: unused variable 'targ'
xs/perl_libzmq3.c:2487: warning: unused variable 'RETVAL'
Running Mkbootstrap for ZMQ::LibZMQ3 ()
chmod 644 LibZMQ3.bs
rm -f blib/arch/auto/ZMQ/LibZMQ3/LibZMQ3.so
gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic xs/perl_libzmq3.o -o blib/arch/auto/ZMQ/LibZMQ3/LibZMQ3.so
-L/opt/zimbra/zeromq-3.2.0/lib -lzmq -luuid \

/usr/bin/ld: cannot find -luuid
collect2: ld returned 1 exit status
make: *** [blib/arch/auto/ZMQ/LibZMQ3/LibZMQ3.so] Error 1

ZMQ-LibCZMQ1 tools/gen_versioned.pl mentioned at MANIFEST

Drop it

diff -ur ZMQ-LibCZMQ1-0.03-/MANIFEST ZMQ-LibCZMQ1-0.03/MANIFEST
--- ZMQ-LibCZMQ1-0.03-/MANIFEST 2013-03-01 06:38:53.000000000 +0200
+++ ZMQ-LibCZMQ1-0.03/MANIFEST  2013-05-12 15:48:19.000000000 +0300
@@ -23,7 +23,6 @@
 t/004_zmsg.t
 tools/detect_czmq.pl
 tools/detect_zmq.pl
-tools/gen_versioned.pl
 tools/genfiles.pl
 tools/zmqcheck/Makefile.PL
 xt/999_leak.t

ZMQ::LibZMQ2 leaks memory in _zmq_recv

If I run the following example I see that ZMQ Subscriber leaks memory:

use 5.010;
use strict;
use warnings;

use ZMQ;
use ZMQ::Constants qw(ZMQ_PUB ZMQ_SUB ZMQ_SUBSCRIBE);
use Time::HiRes qw(usleep);

if (fork) {
    $0 = "ZMQ Publisher";
    my $ctx = ZMQ::Context->new;
    my $sock = $ctx->socket(ZMQ_PUB);
    $sock->bind("tcp://*:7654");
    while (1) {
        $sock->send( "Foo" x 100, 0 );
        usleep(1000);
    }
}
else {
    sleep 1;
    $0 = "ZMQ Subscriber";
    my $ctx = ZMQ::Context->new;
    my $sock = $ctx->socket(ZMQ_SUB);
    $sock->connect("tcp://localhost:7654");
    $sock->setsockopt( ZMQ_SUBSCRIBE, '' );
    while (1) {
        my $msg = $sock->recv;
        $msg->close;
    }
}

I tested it on Debian Squeeze and Ubuntu 11.10 with libzmq 2.1.9 and 2.2.0.

The reason is seems that you're creating temporary zmq_msg_t structure and don't call zmq_msg_close on it. The following commit fixes the problem for me: trinitum/p5-ZMQ@6aa97bf

ZMQ::Poller is missing

I would like to rewrite some of the examples in Perl, but some of the infrastructure is missing. In the case of ZMQ::Poller there is the zmq_poll function that could be used. But this would create big differences between the examples.

Solution:

Write ZMQ::Poller.

zmq_disconnect support?

Unless I'm missing something, I noticed that ZMQ::LibZMQ3 is missing the zmq_disconnect() api. Is this something that would be a simple drop in enhancement or would it be a bit more involved?

thanks,
Robert

ZMQ-LibCZMQ1 RHEL-5 / gcc-4.1.2 fix

There is problem when probing functions at toos/zmqcheck. At RHEL-5 all functions are found available and then it does not work.

At RHEL-5 there is gcc 4.1.2 and it does not return error when function is not declared when using -Wall -std=c99 -pedantic-errors.

$ cat foo.c
int main(void) {
   this_is_not_defined();
   return (0);
}
$ gcc -Wall  -std=c99 -pedantic-errors foo.c -c;echo $?
foo.c: In function ‘main’:
foo.c:2: warning: implicit declaration of function ‘this_is_not_defined’
0

If I add -Werror-implicit-function-declaration

$ gcc -Wall  -std=c99 -pedantic-errors -Werror-implicit-function-declaration foo.c -c;echo $?
foo.c: In function ‘main’:
foo.c:2: error: implicit declaration of function ‘this_is_not_defined’
1
$ 

So I've used this patch to build it:

--- ZMQ-LibCZMQ1-0.03-/tools/zmqcheck/Makefile.PL       2013-01-09 08:21:55.000000000 +0200
+++ ZMQ-LibCZMQ1-0.03/tools/zmqcheck/Makefile.PL        2013-05-12 16:37:45.000000000 +0300
@@ -39,7 +39,7 @@
     $postamble .= sprintf <<'EOM', ($func) x 3;
 %s:

-       @$(CC) -c $(PASTHRU_INC) $(INC) $(CCFLAGS) $(OPTIMIZE) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $(EXTRALIBS) -std=c99 -pedantic-errors %s.c -o %s.o >> zmqcheck.out 2>&1
+       @$(CC) -c $(PASTHRU_INC) $(INC) $(CCFLAGS) $(OPTIMIZE) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $(EXTRALIBS) -std=c99 -Werror-implicit-function-declaration -pedantic-errors %s.c -o %s.o >> zmqcheck.out 2>&1

 EOM
 }

But I think some other strategy might be in order to to probing properly.

Later gcc versions (RHEL-6 / gcc-4.4.6) work as expected without any patching.

zmq_proxy is missing

Hi,

The next stable 3.2.x release re-introduces the zmq_proxy method.

It would be nice to see it supported in LibZMQ3.

Thanks,

p5-ZMQ fails to build RPATH into resulting so file

When the libzqm library is built, it does not set the RPATH, meaning that loading the library in a non-standard location fails:

[root@zre-rhel6-64 LibZMQ3]# ldd LibZMQ3.so
linux-vdso.so.1 => (0x00007fff895ff000)
libzmq.so.3 => not found
libc.so.6 => /lib64/libc.so.6 (0x00007f15c8de2000)
/lib64/ld-linux-x86-64.so.2 (0x0000003cd3800000)

Primarily because -Wl,-rpath,/path/to/lib is not passed in when it is being linked.

ZMQ-LibCZMQ1 xs -> src

Scripts have some locations for XS set at xs/ but all files are at src/.

diff -ur ZMQ-LibCZMQ1-0.03-/Makefile.PL ZMQ-LibCZMQ1-0.03/Makefile.PL
--- ZMQ-LibCZMQ1-0.03-/Makefile.PL      2013-01-13 06:07:48.000000000 +0200
+++ ZMQ-LibCZMQ1-0.03/Makefile.PL       2013-05-12 15:26:57.000000000 +0300
@@ -46,7 +46,7 @@
     $_[0]->[0]->();
 }

-my @clean = qw(xs/*.inc xs/typemap);
+my @clean = qw(src/*.inc src/typemap);

 my $zmqcheck_dir = "tools/zmqcheck";
 {
diff -ur ZMQ-LibCZMQ1-0.03-/tools/genfiles.pl ZMQ-LibCZMQ1-0.03/tools/genfiles.pl
--- ZMQ-LibCZMQ1-0.03-/tools/genfiles.pl        2013-01-07 11:32:42.000000000 +0200
+++ ZMQ-LibCZMQ1-0.03/tools/genfiles.pl 2013-05-12 15:56:56.000000000 +0300
@@ -57,7 +57,7 @@
 }

 EOM
-    open my $src, '<', "xs/perl_czmq.xs";
+    open my $src, '<', "src/perl_czmq.xs" or die;
     foreach my $perl_type (@perl_types) {
         my $c_type = $perl_type;
         $c_type =~ s/::/_/g;

ZMQ-LibZMQ3 does not build on OSX 10.9 (Mavericks)

As far as I am able to tell, the final section of Makefile.PL (the part after WriteAll) serves no purpose on OSX 10.9 Mavericks other than to break the build. Trying to build with it gives a link error, removing the whole block entirely makes it build and test successfully. I assume it is needed on earlier versions, which is why I'm not just sending a pull request.

Tested with perl versions 5.10.1, 5.12.5, 5.14.4, 5.16.3, 5.18.1 and blead.

ZMQ::LibZMQ2 missing zmq_errno() and zmq_strerror()

The documentation mentions zmq_errno() and zmq_strerror(). However when you try importing the functions, you get these error messages.

"zmq_errno" is not exported by the ZMQ::LibZMQ2 module
"zmq_strerror" is not exported by the ZMQ::LibZMQ2 module

Create Alien::ZMQ based on Alien::Base

The ZeroMQ library can be quite hard to install. It would be beneficial if it was possible to have a working version of the library installed by just installing Alien::ZMQ.

With the work being done on Alien::Base as part of a TPF grant, this should be easier.

zmq_disconnect(): Socket operation on non-socket

Hi,

I have tried to use zmq_disconnect on LibZMQ3 but I encountered the error "Socket operation on non-socket" msg.

and then I have found the cause of that.

diff -urN ZMQ-LibZMQ3/xs/perl_libzmq3.xs ZMQ-LibZMQ3_new/xs/perl_libzmq3.xs
--- ZMQ-LibZMQ3/xs/perl_libzmq3.xs      2014-06-18 19:25:43.000000000 +0900
+++ ZMQ-LibZMQ3_new/xs/perl_libzmq3.xs  2014-07-08 11:47:50.793955524 +0900
@@ -758,7 +758,7 @@
         const char *addr;
     CODE:
 #ifdef HAS_ZMQ_DISCONNECT
-        RETVAL = zmq_disconnect(socket, addr);
+        RETVAL = zmq_disconnect(socket->socket, addr);
         if (RETVAL != 0) {
             SET_BANG;
         }
@@ -792,7 +792,7 @@
         const char *addr;
     CODE:
 #ifdef HAS_ZMQ_UNBIND
-        RETVAL = zmq_unbind(socket, addr);
+        RETVAL = zmq_unbind(socket->socket, addr);
         if (RETVAL == -1) {
             SET_BANG;
         }
@@ -1175,7 +1175,7 @@
         int events;
     CODE:
 #ifdef HAS_ZMQ_SOCKET_MONITOR
-        RETVAL = zmq_socket_monitor(socket, addr, events);
+        RETVAL = zmq_socket_monitor(socket->socket, addr, events);
         if (RETVAL != 0) {
             SET_BANG;
         }

After apply this patch, zmq_disconnect() function do that correctly.

I am grateful for being able to use this package.

Have a nice day!

ZMQ::LibZMQ3 somehow breaks perl's die semantics with infinite poll(...) loop

Something gets broken inside of perl, when certain functions from ZMQ::LibZMQ3 are added into the code. It does not matter if the functions ever actually execute. This test case should get stuck forever instead of finishing the die process on Mac OS X. I have seen it happen sometimes on Linux as well but not as reliably.

I am guessing, referencing certain functions must cause a ZMQ event loop to be started, but there is no code to ensure the loop is ended and doesn't become infinite when perl tries to shut down. When tracing the code with dtruss, etc. you can see it gets stuck in some kind of poll(...).

When a custom __DIE__ handler is registered, it seems possible to work around the issue.

#!/usr/bin/env perl

use strict;
use warnings FATAL => 'all';

use ZMQ::LibZMQ3;
use ZMQ::Constants qw(:all);

# ZMQ context
my $zmq_ctx    = zmq_ctx_new();
my $zmq_socket = zmq_socket($zmq_ctx, ZMQ_PUB) or die "zmq_socket failed: $!";
zmq_bind($zmq_socket, "tcp://*:31337") and die "zmq_bind failed: $!";

sub handle_die {
    my ($message) = @_;

    # $^S : parser state: undef during parse, 1 when running eval, 0 otherwise
    die @_ if $^S;

    print "got here\n";
    zmq_close($zmq_socket) if $zmq_socket;
    zmq_ctx_destroy($zmq_ctx) if $zmq_ctx;

    die @_;
}

die "should be able to die at this point but it gets stuck";

$SIG{__DIE__} = \&handle_die;

my $data = "foo bar baz boo";
my $message = zmq_msg_init_data($data);
zmq_send($zmq_socket, $message) or die "zmq_msg_send failed: $!";
#zmq_msg_close($message);

die "but instead we can only die from this point due to stuck poll(...) loop";

exit(0);

RFC: Rename CZMQ to LibCZMQ1

I was planning to create bindings for FileMQ and ZyRE, and turns out they both depend on CZMQ

Current implementation of CZMQ is VERY half-assed, and don't follow the LibZMQ[23] naming scheme. I think this may be a good time to rename stuff. Speak now if you have any objections:

 https://github.com/lestrrat/p5-ZMQ/tree/topic/rename-czmq

adding perl bindings in embedded system

I am using yocto to build libzmq3 and the perl bindings.

I get the following:
Probing libzmq via pkg-config ...

  • found libzmq 4.1.4
  • Detected ZMQ_INCLUDES from pkg-config...
  • Detected ZMQ_LIBS from pkg-config...
    Detected the following ZMQ settings:
  • ZMQ_HOME = (null)
  • ZMQ_H = (null)
  • ZMQ_INCLUDES =
  • ZMQ_LIBS = -lzmq
  • ZMQ_TRACE = (null)

Looks like ZMQ_INCLUDES is not found from the libzmq.pc package file.. but that file looks ok:
prefix=/usr
exec_prefix=/usr
libdir=/usr/lib
includedir=/usr/include

Name: libzmq
Description: 0MQ c++ library
Version: 4.1.4
Libs: -L${libdir} -lzmq
Cflags: -I${includedir}

Anyway I fixed this in yocto by exporting the export ZMQ_INCLUDES location and that works but I still get a failure:
| Probing environment variables:
| Alien::ZMQ not found
| Probing libzmq via pkg-config ...
| + found libzmq 4.1.4
| + Detected ZMQ_LIBS from pkg-config...
| Detected the following ZMQ settings:
| + ZMQ_HOME = (null)
| + ZMQ_H = (null)
| + ZMQ_INCLUDES = /usr/include
| + ZMQ_LIBS = -lzmq
| + ZMQ_TRACE = (null)
| *** Module name IN: /usr/lib/perl/5.22.1/IO.pm
| *** p1: /usr/lib/ p3: perl/5.22.1/ p5: IO.pm
| *** Module name OUT: /usr/lib/perl-native/perl/5.22.1/IO.pm
| # arm-poky-linux-gnueabi-gcc -march=armv7-a -marm -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/ -O2 -pipe -g -feliminate-unused-debug-types -DDEBIAN -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc assertlibM2QiFoty.c -I/usr/include -o assertlibtlHxWLPE
| # arm-poky-linux-gnueabi-gcc -march=armv7-a -marm -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/ -O2 -pipe -g -feliminate-unused-debug-types -DDEBIAN -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc assertlibipzhaFu0.c -o assertlibhIw7zwaM -I/usr/include -lzmq
| assertlibhIw7zwaM: assertlibhIw7zwaM: cannot execute binary file
| wrong result: 'zmq'

Anyway I tried to build on the target and I get other errors towards the end of the make process:
CHECK: Does your zmq have zmq_ctx_new... YES
Checking if your kit is complete...
Looks good
Warning: prerequisite Task::Weaken 0 not found.
Warning: prerequisite Test::Fatal 0 not found.
Warning: prerequisite Test::Requires 0 not found.
Warning: prerequisite Test::TCP 1.08 not found.
Warning: prerequisite ZMQ::Constants 0 not found.
ExtUtils::MM_Unix::tool_xsubpp : Can't find xsubpp at /usr/lib/perl/5.22.1/ExtUtils/MM_Unix.pm line 3578.

Any assistance or pointers to others who have used yocto and libzmq3 would be much appreciated. Looks like this is a bigger job than I expected!

Peter.

ZMQ::LibZMQ3 doesn't build on Strawberry Perl

I've been trying to use ZMQ::LibZMQ3 on Strawberry Perl.

There's a couple of small problems.

One is this, from Makefile.PL:

Can't do inplace edit without backup at Makefile.PL line 101.

This is because Windows Perl can't do in-place edit.

A work-around is to change $^I to have a backup. I used ~ like gvim does:

Line 100 of Makefile.PL:
local $^I = '~';

That lets the Makefile.PL work.

Would you like a patch with that and an unlink of that file?

segfault when zmq_poll() with closed socket

Hi.

I met a segfault with my program.

this situation like below.

  1. call zmq_poll() with a monitor socket gained by zmq_monitor_socket() and then some callback is triggered.
  2. this callback checks connection and then if it is disconnected, close this socket.
  3. after that, call zmq_poll() with same pollitems.
  4. Bang!

I have rebuilt ZMQ::LibZMQ3 with ZMQ_TRACE.

1887                 mg = P5ZMQ3_Socket_mg_find( aTHX_ SvRV(*svr), &P5ZMQ3_Socket_vtbl );
1888
1889                 /* debugging logs added for tracing */
1890                 P5ZMQ3_TRACE(" + mg %d: %d", i, mg);
1891                 P5ZMQ3_TRACE(" + mg->mg_ptr %d: %d", i, mg->mg_ptr);
1892 
1893                 pollitems[i].socket = ((P5ZMQ3_Socket *) mg->mg_ptr)->socket;
1894                 P5ZMQ3_TRACE( " + via pollitem[%d].socket = %p", i, pollitems[i].socket );

and this is output from that.

[perlzmq (29306)] START mg_free (Message)
[perlzmq (29306)] + zmq message 2e41f50
[perlzmq (29306)] END mg_free (Message)
[perlzmq (29306)] START zmq_poll
[perlzmq (29306)] + processing element 0
[perlzmq (29306)] + mg 0: 48468640
[perlzmq (29306)] + mg->mg_ptr 0: 0
Segmentation fault (core dumped)

Actually... it may be my fault, too.

but I think that we can handle this situation more gracefully :)

Test 100_basic.t hangs with zeromq 4.0.3

It appears that version 4 of ØMQ changed its semantics to allow the case that the first test in 100_basic.t expects to fail. The result is, as far as I understand it, that the test unexpectedly succeeds and when perl tries to GC the client socket ØMQ refuses to destroy it until it's completed it's initialization. Since that never happens, the effect is to make the test hang. Adding an "else" branch that does zmq_bind() makes the test proceed (and report failure).

I don't know if this test still tests something interesting on ØMQ 4, or should just be skipped in that case.

All other tests pass with ØMQ 4.0.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.