ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.415 by root, Thu Apr 10 15:35:16 2008 UTC vs.
Revision 1.416 by root, Fri Apr 11 13:59:06 2008 UTC

3442 warn "runtime file written.\n"; 3442 warn "runtime file written.\n";
3443 3443
3444 1 3444 1
3445} 3445}
3446 3446
3447our $uuid_lock;
3448our $uuid_skip;
3449
3450sub write_uuid_sync($) {
3451 $uuid_skip ||= $_[0];
3452
3453 return if $uuid_lock;
3454 local $uuid_lock = 1;
3455
3456 my $uuid = "$LOCALDIR/uuid";
3457
3458 my $fh = aio_open "$uuid~", O_WRONLY | O_CREAT, 0644
3459 or return;
3460
3461 my $value = uuid_str $uuid_skip + uuid_seq uuid_cur;
3462 $uuid_skip = 0;
3463
3464 (aio_write $fh, 0, (length $value), $value, 0) <= 0
3465 and return;
3466
3467 # always fsync - this file is important
3468 aio_fsync $fh
3469 and return;
3470
3471 close $fh
3472 or return;
3473
3474 aio_rename "$uuid~", $uuid
3475 and return;
3476
3477 warn "uuid file written ($value).\n";
3478
3479 1
3480
3481}
3482
3483sub write_uuid($$) {
3484 my ($skip, $sync) = @_;
3485
3486 $sync ? write_uuid_sync $skip
3487 : async { write_uuid_sync $skip };
3488}
3489
3447sub emergency_save() { 3490sub emergency_save() {
3448 my $freeze_guard = cf::freeze_mainloop; 3491 my $freeze_guard = cf::freeze_mainloop;
3449 3492
3450 warn "enter emergency perl save\n"; 3493 warn "enter emergency perl save\n";
3451 3494
3471 warn "end emergency map save\n"; 3514 warn "end emergency map save\n";
3472 3515
3473 warn "begin emergency database checkpoint\n"; 3516 warn "begin emergency database checkpoint\n";
3474 BDB::db_env_txn_checkpoint $DB_ENV; 3517 BDB::db_env_txn_checkpoint $DB_ENV;
3475 warn "end emergency database checkpoint\n"; 3518 warn "end emergency database checkpoint\n";
3519
3520 warn "begin write uuid\n";
3521 write_uuid_sync 1;
3522 warn "end write uuid\n";
3476 }; 3523 };
3477 3524
3478 warn "leave emergency perl save\n"; 3525 warn "leave emergency perl save\n";
3479} 3526}
3480 3527

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines