… | |
… | |
81 | our %EXTCMD = (); |
81 | our %EXTCMD = (); |
82 | our %EXTICMD = (); |
82 | our %EXTICMD = (); |
83 | our %EXT_CORO = (); # coroutines bound to extensions |
83 | our %EXT_CORO = (); # coroutines bound to extensions |
84 | our %EXT_MAP = (); # pluggable maps |
84 | our %EXT_MAP = (); # pluggable maps |
85 | |
85 | |
86 | our $RELOAD; # number of reloads so far |
86 | our $RELOAD; # number of reloads so far, non-zero while in reload |
87 | our @EVENT; |
87 | our @EVENT; |
88 | |
88 | |
89 | our $CONFDIR = confdir; |
89 | our $CONFDIR = confdir; |
90 | our $DATADIR = datadir; |
90 | our $DATADIR = datadir; |
91 | our $LIBDIR = "$DATADIR/ext"; |
91 | our $LIBDIR = "$DATADIR/ext"; |
… | |
… | |
341 | return;#d# |
341 | return;#d# |
342 | }#d# |
342 | }#d# |
343 | |
343 | |
344 | # wait for lock, if any |
344 | # wait for lock, if any |
345 | while ($LOCK{$key}) { |
345 | while ($LOCK{$key}) { |
|
|
346 | #local $Coro::current->{desc} = "$Coro::current->{desc} <waiting for lock $key>"; |
346 | push @{ $LOCK{$key} }, $Coro::current; |
347 | push @{ $LOCK{$key} }, $Coro::current; |
347 | Coro::schedule; |
348 | Coro::schedule; |
348 | } |
349 | } |
349 | } |
350 | } |
350 | |
351 | |
… | |
… | |
3580 | my $leaf_symtab = *{$stem_symtab->{$leaf}}{HASH}; |
3581 | my $leaf_symtab = *{$stem_symtab->{$leaf}}{HASH}; |
3581 | for my $name (keys %$leaf_symtab) { |
3582 | for my $name (keys %$leaf_symtab) { |
3582 | _gv_clear *{"$pkg$name"}; |
3583 | _gv_clear *{"$pkg$name"}; |
3583 | # use PApp::Util; PApp::Util::sv_dump *{"$pkg$name"}; |
3584 | # use PApp::Util; PApp::Util::sv_dump *{"$pkg$name"}; |
3584 | } |
3585 | } |
3585 | warn "cleared package #$pkg\n";#d# |
3586 | warn "cleared package $pkg\n";#d# |
3586 | } |
3587 | } |
3587 | |
|
|
3588 | our $RELOAD; # how many times to reload |
|
|
3589 | |
3588 | |
3590 | sub do_reload_perl() { |
3589 | sub do_reload_perl() { |
3591 | # can/must only be called in main |
3590 | # can/must only be called in main |
3592 | if ($Coro::current != $Coro::main) { |
3591 | if ($Coro::current != $Coro::main) { |
3593 | warn "can only reload from main coroutine"; |
3592 | warn "can only reload from main coroutine"; |
… | |
… | |
3707 | |
3706 | |
3708 | sub reload_perl() { |
3707 | sub reload_perl() { |
3709 | # doing reload synchronously and two reloads happen back-to-back, |
3708 | # doing reload synchronously and two reloads happen back-to-back, |
3710 | # coro crashes during coro_state_free->destroy here. |
3709 | # coro crashes during coro_state_free->destroy here. |
3711 | |
3710 | |
3712 | $RELOAD_WATCHER ||= EV::timer 0, 0, sub { |
3711 | $RELOAD_WATCHER ||= EV::timer $TICK * 1.5, 0, sub { |
3713 | do_reload_perl; |
3712 | do_reload_perl; |
3714 | undef $RELOAD_WATCHER; |
3713 | undef $RELOAD_WATCHER; |
3715 | }; |
3714 | }; |
3716 | } |
3715 | } |
3717 | |
3716 | |