aufflick has asked for the wisdom of the Perl Monks concerning the following question:

I have taken over maintenance of HTTP::Daemon::SSL and I have a dilemma.

HTTP::Daemon::SSL's accept() method is supposed to return false if the IO::Socket times out without a connection (unless the timeout is 0 of course, in which case it will never return). This is in conformance with the documentation for HTTP::Daemon which (on this point) HTTP::Daemon::SSL's documentation does not indicate variance. HTTP::Daemon::SSL does not do this, however, as it has a while(1) loop in it's overridden accept() method.

My problem is this - in fixing this I may break code that uses HTTP::Daemon::SSL and assumes this built-in while loop. I'm not too concerned as any code which also works with HTTP::Daemon will work after this fix, but I'm wondering what people feel the etiquette is in this situation.

For instance, the current version is 1.02 - should I change the version to 2.0 to signify a change in the API (even though the published API doesn't change - the functionality is simply coming into step with the docs)? Are there any other ways I can mitigate impact?

Update: As requested by Corion, here is a code sample. The following code will exit cleanly with a HUP if $daemon is an instance of HTTP::Daemon, but not if it is an instance of HTTP::Daemon::SSL 1.02:

$SIG{HUP} = sub { $__server_should_run = 0; }; $__server_should_run = 1; while ($__server_should_run) { my $conn = $daemon->accept or next; # handle request }

Replies are listed 'Best First'.
Re: Correcting/changing a CPAN module interface
by Anno (Deacon) on Jul 23, 2007 at 11:46 UTC
    It looks like it should be possible to change HTTP::Daemon::SSL so that its default behavior is unchanged, but the timing-out behavior can be activated through a new option that old code won't use. The calls from HTTP::Daemon would have to be modified to use the new option. If you don't maintain HTTP::Daemon also, send the maintainer a patch.

    From a cursory glance at the docs it seems that HTTP::Daemon::SSL is at least implicitly described as respecting a timeout, so the change could be considered a bug fix. I don't think a "big" version change is required.

    Anno

      Yes I agree it's a bug fix - I'm probably being anal.

      The thing is that HTTP::Daemon::SSL is supposed to be a drop-in replacement for HTTP::Daemon, which has a very established api, so I think I do need to change the default behaviour.

      I actually wasn't aware that CPAN didn't install modules with a _xx development version number, so I'll go that route first and solicit feedback that way.

        You can also turn it around and give HTTP::Daemon::SSL a new parameter to enforce bug compatibility. That could happen at load time, as in
        use HTTP::Daemon::SSL qw( compat);
        but it could be individual with accept( ..., compat => 1. In the (unlikely) case that something relies on accept not to time out, there'd be a way to fix it.

        Anno

Re: Correcting/changing a CPAN module interface
by Anonymous Monk on Jul 23, 2007 at 11:27 UTC
    You could release a "developer version" ( 1.02_1 ) and let it sit on cpan for a month (or more), so you can get feedback. The benefit is 'cpan install HTTP::Daemon::SSL' won't install those.
Re: Correcting/changing a CPAN module interface
by daxim (Curate) on Jul 23, 2007 at 11:36 UTC
    Don't change the code, change the documentation. Seriously.

    Write:

    Note: In 1.02 and before this used to say {...}, but that was wrong.