… | |
… | |
1846 | |
1846 | |
1847 | $rmp->{random_seed} ||= $exit->random_seed; |
1847 | $rmp->{random_seed} ||= $exit->random_seed; |
1848 | |
1848 | |
1849 | my $data = cf::to_json $rmp; |
1849 | my $data = cf::to_json $rmp; |
1850 | my $md5 = Digest::MD5::md5_hex $data; |
1850 | my $md5 = Digest::MD5::md5_hex $data; |
|
|
1851 | my $meta = "$cf::RANDOM_MAPS/$md5.meta"; |
1851 | |
1852 | |
1852 | if (my $fh = aio_open "$cf::RANDOM_MAPS/$md5.meta", O_WRONLY | O_CREAT, 0666) { |
1853 | if (my $fh = aio_open "$meta~", O_WRONLY | O_CREAT, 0666) { |
1853 | aio_write $fh, 0, (length $data), $data, 0; |
1854 | aio_write $fh, 0, (length $data), $data, 0; |
|
|
1855 | undef $fh; |
|
|
1856 | aio_rename "$meta~", $meta; |
1854 | |
1857 | |
1855 | $exit->slaying ("?random/$md5"); |
1858 | $exit->slaying ("?random/$md5"); |
1856 | $exit->msg (undef); |
1859 | $exit->msg (undef); |
1857 | } |
1860 | } |
1858 | } |
1861 | } |
… | |
… | |
2229 | sub main { |
2232 | sub main { |
2230 | # we must not ever block the main coroutine |
2233 | # we must not ever block the main coroutine |
2231 | local $Coro::idle = sub { |
2234 | local $Coro::idle = sub { |
2232 | Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d# |
2235 | Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d# |
2233 | (async { |
2236 | (async { |
2234 | warn "BP1\n";#d# |
|
|
2235 | Event::one_event; |
2237 | Event::one_event; |
2236 | warn "BP2\n";#d# |
|
|
2237 | })->prio (Coro::PRIO_MAX); |
2238 | })->prio (Coro::PRIO_MAX); |
2238 | }; |
2239 | }; |
2239 | |
2240 | |
2240 | cfg_load; |
2241 | cfg_load; |
2241 | db_load; |
2242 | db_load; |