Skip Menu |
 

This queue is for tickets about the AnyEvent-HTTPD CPAN distribution.

Report information
The Basics
Id: 82673
Status: new
Priority: 0/
Queue: AnyEvent-HTTPD

People
Owner: Nobody in particular
Requestors: vitaliy.tokarev [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.93
Fixed in: (no value)



Subject: Suggestion about unreg_cb
Download (untitled) / with headers
text/plain 584b
Hi! I have started using AnyEvent::HTTPD and found one problem with $http- Show quoted text
>unreg_cb. Perhaps, I've misunderstood about unreg_cb, but if we do
following: $http->reg_cb("/my-url" => sub { ... }); I consider to remove this callback I need to do next: $http->unreg_cb("/my-url"); But this does not work! So, I've attached Object::Event patch, which may be useful for AnyEvent::HTTPD::HTTPServer, because it subclassing Object::Event. Anyway, I will be glad to simplify process for removing useless callbacks in any time and description of this action in documentation. Thanks.
Subject: Object_Event_unreg_cb.diff
--- /home/tvv/.staticperl-5.16.2/lib/Object/Event.pm.orig +++ /home/tvv/.staticperl-5.16.2/lib/Object/Event.pm @@ -352,6 +352,9 @@ for my $reg (values %$evs) { @$reg = grep { (substr $_->[1], 0, $key_len) ne $key } @$reg; } + + # if remove by name do it easy + delete $evs->{$cb}; } =item my $handled = $obj->event ($eventname, @args)
From: vitaliy.tokarev [...] gmail.com
Attached AnyEvent::HTTP::Server patch, I hope this help.
Subject: AnyEvent_HTTP_Server_unreg_cb.diff
--- /home/tvv/.staticperl-5.16.2/lib/AnyEvent/HTTPD/HTTPServer.pm.orig +++ /home/tvv/.staticperl-5.16.2/lib/AnyEvent/HTTPD/HTTPServer.pm @@ -95,4 +95,20 @@ $self->event (connect => $htc); } +sub unreg_cb { + my ($self, $cb, $gen) = @_; + + if (ref ($cb) eq 'REF') { + # we've got a guard object + $$cb = undef; + return; + } + + return unless defined $cb; # some small safety against bad arguments + + delete $self->{__oe_events}{$cb}; + $self; +} + + 1;


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.