ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/login.ext
(Generate patch)

Comparing deliantra/server/ext/login.ext (file contents):
Revision 1.22 by root, Tue Jan 9 01:28:32 2007 UTC vs.
Revision 1.25 by root, Sat Jan 13 23:06:13 2007 UTC

1#! perl 1#! perl # MANDATORY
2 2
3# login handling 3# login handling
4 4
5use Fcntl; 5use Fcntl;
6use Coro::AIO; 6use Coro::AIO;
341 341
342############################################################################# 342#############################################################################
343 343
344our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs 344our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs
345our $SAVE_TIMEOUT = 20; # save players every n seconds 345our $SAVE_TIMEOUT = 20; # save players every n seconds
346our $SAVE_INTERVAL = 0.5; # save at max. one player every $SAVE_INTERVAL
347 346
348our $SCHEDULER = cf::async_ext { 347our $SCHEDULER = cf::async_ext {
349 while () { 348 while () {
350 Coro::Timer::sleep $SCHEDULE_INTERVAL; 349 Coro::Timer::sleep $SCHEDULE_INTERVAL;
351 350
359 or next; 358 or next;
360 $pl->valid or next; 359 $pl->valid or next;
361 360
362 eval { 361 eval {
363 if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { 362 if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) {
363 $cf::WAIT_FOR_TICK_ONE->wait;
364 $pl->save; 364 $pl->save;
365 365
366 unless ($pl->active) { 366 unless ($pl->active) {
367 # check refcounts, this is tricky and needs to be adjusted to fit server internals 367 # check refcounts, this is tricky and needs to be adjusted to fit server internals
368 my $ob = $pl->ob; 368 my $ob = $pl->ob;
369 Scalar::Util::weaken $pl; 369 Scalar::Util::weaken $pl;
370 Scalar::Util::weaken $ob; 370 Scalar::Util::weaken $ob;
371 my $a_ = $pl->refcnt; 371 my $a_ = $pl->refcnt;#d#
372 my $b_ = $ob->refcnt; 372 my $b_ = $ob->refcnt;#d#
373 my $pl_ref = $pl->refcnt_cnt; 373 my $pl_ref = $pl->refcnt_cnt;
374 my $ob_ref = $ob->refcnt_cnt; 374 my $ob_ref = $ob->refcnt_cnt;
375 375
376 ## pl_ref == one from object + one from cf::PLAYER 376 ## pl_ref == one from object + one from cf::PLAYER
377 ## ob_ref == one from simply being an object 377 ## ob_ref == one from simply being an object
386 $pl->destroy; 386 $pl->destroy;
387 } else { 387 } else {
388 warn "player-scheduler refcnt ", $ob->name, " $pl_ref,$a_ $ob_ref,$b_\n";#d# 388 warn "player-scheduler refcnt ", $ob->name, " $pl_ref,$a_ $ob_ref,$b_\n";#d#
389 } 389 }
390 } 390 }
391 Coro::Timer::sleep $SAVE_INTERVAL;
392 } 391 }
393 }; 392 };
394 warn $@ if $@; 393 warn $@ if $@;
395 Coro::cede; 394 Coro::cede;
396 }; 395 };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines