Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible sys_read failure for chunked io #22

Open
ostap opened this issue Nov 5, 2012 · 1 comment
Open

possible sys_read failure for chunked io #22

ostap opened this issue Nov 5, 2012 · 1 comment
Labels

Comments

@ostap
Copy link
Member

ostap commented Nov 5, 2012

sys_read fails on chunked io when the requested amount of data for read is less than the size of the chunk. we need to implement a buffered io and keep the unread data in the buffer.

here is the problematic code from the system.c:

static int net_read_chunk(IO *io, void *buf, int size)
{
    int r = 0, sz = 0;
    if (readn(io, &sz, sizeof(sz), net_read) == sizeof(sz)) {
        if (sz < 0)
            io->stop |= IO_TERM;
        else if (sz > size)
            io->stop |= IO_ERROR;
        else if (sz > 0)
            r = readn(io, buf, sz, net_read);
    }   

    return io->stop & ~IO_TERM ? -1 : r;
}

the situation with sz > size should put the requested amount of data into the buf and keep the remaining in the buffer associated with the IO.

@ostap
Copy link
Member Author

ostap commented Nov 9, 2012

the issue has been worked around as part of #18 so it is not of a critical priority, however we need to fix it on the IO level at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant