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

new_from_fh

Coro::Handle::new_from_fh creates tied handle. In the current implementation it ties Glob which is not a real file handle. So things like IO::Handle::new_from_fd doesn't work with such tied handle. After this patch tied handle will be a real filehandle (duplicate of original filehandle) and new_from_fd will work as expected. See t/07_handle_new_from_fd.t

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

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.