Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process exit when lost connection #38

Open
zpl opened this issue Jun 4, 2016 · 1 comment
Open

Process exit when lost connection #38

zpl opened this issue Jun 4, 2016 · 1 comment

Comments

@zpl
Copy link

zpl commented Jun 4, 2016

Hello. there is a bug.

example code:

my $queue = Net::RabbitMQ->new();
$queue->connect( .... );
$queue->channel_open(1);

while (1) {
    my $result = $queue->publish( 1, ... );
    print $result . "\n";
    sleep 1;
}

now, if you shutdown RabbitMQ server, when process inside while - perl process will end right after publish.

try or eval will not help.

That's happened because of write call on closed handle

EPIPE
fd is connected to a pipe or socket whose reading end is closed. When this happens the writing process will also receive a SIGPIPE signal. (Thus, the write return value is seen only if the program catches, blocks or ignores this signal.)
http://linux.die.net/man/2/write

And because we unable to handle SIGPIPE - our program is closed.

@zpl
Copy link
Author

zpl commented Jun 4, 2016

there is how it will looks like with my fix:

$ perl queue.pl                                                                                                                                                         
0
0
0
0
0
-1
-1
-1
-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant