… | |
… | |
526 | $rlen = $rlen * 2 + 16 if $rlen - 128 < length $rbuf; |
526 | $rlen = $rlen * 2 + 16 if $rlen - 128 < length $rbuf; |
527 | $len = sysread $fh, $rbuf, $rlen - length $rbuf, length $rbuf; |
527 | $len = sysread $fh, $rbuf, $rlen - length $rbuf, length $rbuf; |
528 | |
528 | |
529 | if ($len) { |
529 | if ($len) { |
530 | while (8 <= length $rbuf) { |
530 | while (8 <= length $rbuf) { |
531 | ($id, $len) = unpack "LL", $rbuf; |
531 | ($id, $len) = unpack "NN", $rbuf; |
532 | 8 + $len <= length $rbuf |
532 | 8 + $len <= length $rbuf |
533 | or last; |
533 | or last; |
534 | |
534 | |
535 | my @r = $t->(substr $rbuf, 8, $len); |
535 | my @r = $t->(substr $rbuf, 8, $len); |
536 | substr $rbuf, 0, 8 + $len, ""; |
536 | substr $rbuf, 0, 8 + $len, ""; |
… | |
… | |
581 | |
581 | |
582 | $rcb{$id} = pop; |
582 | $rcb{$id} = pop; |
583 | |
583 | |
584 | $guard if 0; # keep it alive |
584 | $guard if 0; # keep it alive |
585 | |
585 | |
586 | $wbuf .= pack "LL/a*", $id, &$f; |
586 | $wbuf .= pack "NN/a*", $id, &$f; |
587 | $ww ||= $fh && AE::io $fh, 1, $wcb; |
587 | $ww ||= $fh && AE::io $fh, 1, $wcb; |
588 | } |
588 | } |
589 | : sub { |
589 | : sub { |
590 | push @rcb, pop; |
590 | push @rcb, pop; |
591 | |
591 | |
592 | $guard; # keep it alive |
592 | $guard; # keep it alive |
593 | |
593 | |
594 | $wbuf .= pack "L/a*", &$f; |
594 | $wbuf .= pack "N/a*", &$f; |
595 | $ww ||= $fh && AE::io $fh, 1, $wcb; |
595 | $ww ||= $fh && AE::io $fh, 1, $wcb; |
596 | } |
596 | } |
597 | } |
597 | } |
598 | |
598 | |
599 | =item $rpc->(..., $cb->(...)) |
599 | =item $rpc->(..., $cb->(...)) |