… | |
… | |
8 | use Storable; |
8 | use Storable; |
9 | use Opcode; |
9 | use Opcode; |
10 | use Safe; |
10 | use Safe; |
11 | use Safe::Hole; |
11 | use Safe::Hole; |
12 | |
12 | |
13 | use Coro 3.3 (); |
13 | use Coro 3.4 (); |
14 | use Coro::Event; |
14 | use Coro::Event; |
15 | use Coro::Timer; |
15 | use Coro::Timer; |
16 | use Coro::Signal; |
16 | use Coro::Signal; |
17 | use Coro::Semaphore; |
17 | use Coro::Semaphore; |
18 | use Coro::AIO; |
18 | use Coro::AIO; |
… | |
… | |
2228 | |
2228 | |
2229 | sub main { |
2229 | sub main { |
2230 | # we must not ever block the main coroutine |
2230 | # we must not ever block the main coroutine |
2231 | local $Coro::idle = sub { |
2231 | local $Coro::idle = sub { |
2232 | Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d# |
2232 | Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d# |
|
|
2233 | (async { |
2233 | async { Event::one_event }; |
2234 | Event::one_event; |
|
|
2235 | })->prio (Coro::PRIO_MAX); |
2234 | }; |
2236 | }; |
2235 | |
2237 | |
2236 | cfg_load; |
2238 | cfg_load; |
2237 | db_load; |
2239 | db_load; |
2238 | load_extensions; |
2240 | load_extensions; |
… | |
… | |
2386 | } |
2388 | } |
2387 | |
2389 | |
2388 | warn "reloaded"; |
2390 | warn "reloaded"; |
2389 | }; |
2391 | }; |
2390 | |
2392 | |
|
|
2393 | our $RELOAD_WATCHER; # used only during reload |
|
|
2394 | |
2391 | register_command "reload" => sub { |
2395 | register_command "reload" => sub { |
2392 | my ($who, $arg) = @_; |
2396 | my ($who, $arg) = @_; |
2393 | |
2397 | |
2394 | if ($who->flag (FLAG_WIZ)) { |
2398 | if ($who->flag (FLAG_WIZ)) { |
2395 | $who->message ("start of reload."); |
2399 | $who->message ("reloading server."); |
|
|
2400 | |
|
|
2401 | # doing reload synchronously and two reloads happen back-to-back, |
|
|
2402 | # coro crashes during coro_state_free->destroy here. |
|
|
2403 | |
|
|
2404 | $RELOAD_WATCHER ||= Event->timer (after => 0, data => WF_AUTOCANCEL, cb => sub { |
2396 | reload; |
2405 | reload; |
2397 | $who->message ("end of reload."); |
2406 | undef $RELOAD_WATCHER; |
|
|
2407 | }); |
2398 | } |
2408 | } |
2399 | }; |
2409 | }; |
2400 | |
2410 | |
2401 | unshift @INC, $LIBDIR; |
2411 | unshift @INC, $LIBDIR; |
2402 | |
2412 | |