Re: Filesize Bug in NJB3 Workaround
Richard Low <[email protected]> Thu, 22 Sep 2005 14:32:47 +0100
| Newsgroups | gmane.comp.multimedia.libnjb.user |
|---|---|
| Message-ID | <[email protected]> |
On 22 Sep 2005, at 11:17, Linus Walleij wrote:
> This should work partially but worries me, what happens if even
> more than what can be fitted in the current chunk remains? Perhaps
> we should actually test against the chunk max size, and if remain
> == max chunk, even try to get one more byte or something, so that
> it is adjusted upwards.
>
> On the other hand it is a corner case anyway so perhaps we needn't
> care.
Yes, I see your point. If a file was really (NJB3_CHUNK_SIZE +
something small) big, but was reported as (NJB3_CHUNK_SIZE -
something small) then my code will fail. Implementing what you
suggested works - I made a file just greater than 1 MB, which was
reported as just under 1 MB, and the file downloads correctly. See
below for an updated version. But as you say, even if this doesn't
work in all cases, it is still better than the download always failing.
> Apart from the remark it looks OK but I cannot apply this patch as
> of now, the codebase is changed, could you make a patch against
> CVS? (Else I'll try to make it on a fresh 2.2.3 and diff it to the
> CVS, but this could introduce errors on my part.)
Sorry, I didn't realise the code had changed already. Here is a diff
against current cvs
1116,1130c1116
< if (chunk_size > remain)
< {
< printf("LIBNJB panic: chunk_size >
remain, going to get whole chunk and see what happens\n");
<
< if (chunk_size == NJB3_CHUNK_SIZE)
< {
< size += (NJB3_CHUNK_SIZE) + 1
- remain;
< remain = NJB3_CHUNK_SIZE + 1;
< }
< else
< {
< size += (chunk_size - remain);
< remain = chunk_size;
< }
< } else if ( chunk_size == -1 ) {
---
> if ( chunk_size == -1 ) {
Richard.
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php