The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Coro::PatchSet::Handle - fix Coro::Handle as much as possible

SYNOPSIS

    use Coro::PatchSet::Handle;
    # or
    # use Coro::PatchSet 'handle';
    use Coro;
    
    async { ... }

PATCHES

sysread()

In the current Coro::Handle implementation sysread($buf, $len) will always try to read $len bytes. So if we have some slow socket that sent you $len-1 bytes and 1 more byte after 10 minutes, Coro::Handle will wait this 1 byte for 10 minutes (or until error/socket closing). But this behaviour is not compatible with sysread() on system sockets, which Coro::Handle tries to emulate. After this patch sysread will behave like sysread on system sockets. It will read >= 1 and <= $len bytes for you. Bytes readed count may be less than $len if sysread() may not read it without blocking. But will always be >= 1 (if there was no error or socket closing). So in the situation above sysread will read $len-1 bytes and return. See t/05_handle_read.t

SEE ALSO

Coro::PatchSet, Coro::PatchSet::Socket

COPYRIGHT

Copyright Oleg G <oleg@cpan.org>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. cut