… | |
… | |
350 | |
350 | |
351 | sub session($) { |
351 | sub session($) { |
352 | my ($fh) = @_; |
352 | my ($fh) = @_; |
353 | |
353 | |
354 | $fh = Coro::Handle::unblock $fh; |
354 | $fh = Coro::Handle::unblock $fh; |
355 | select $fh; |
355 | my $old_fh = select $fh; |
|
|
356 | my $guard = Coro::guard { select $old_fh }; |
356 | |
357 | |
357 | my $loglevel = $SESLOGLEVEL; |
358 | my $loglevel = $SESLOGLEVEL; |
358 | local $log{$Coro::current} = sub { |
359 | local $log{$Coro::current} = sub { |
359 | return unless $_[0] <= $loglevel; |
360 | return unless $_[0] <= $loglevel; |
360 | print $fh "\015", (format_msg $_[0], $_[1]), "> "; |
361 | print $fh "\015", (format_msg $_[0], $_[1]), "> "; |
… | |
… | |
410 | fh => $fh, |
411 | fh => $fh, |
411 | path => $path, |
412 | path => $path, |
412 | }, $class; |
413 | }, $class; |
413 | |
414 | |
414 | $self->{cw} = AnyEvent->io (fh => $fh, poll => 'r', cb => sub { |
415 | $self->{cw} = AnyEvent->io (fh => $fh, poll => 'r', cb => sub { |
415 | Coro::async { |
416 | Coro::async_pool { |
416 | warn select;#d# |
|
|
417 | $Coro::current->desc ("[Coro::Debug session]"); |
417 | $Coro::current->desc ("[Coro::Debug session]"); |
418 | my $fh = $fh->accept; |
|
|
419 | session $fh; |
418 | session +$fh->accept; |
420 | close $fh; |
|
|
421 | }; |
419 | }; |
422 | }); |
420 | }); |
423 | |
421 | |
424 | $self |
422 | $self |
425 | } |
423 | } |