[FFmpeg-devel] [Patch] Use Transfer-Encoding: chunked (and perhaps PUT) for HTTP uploads

Tomas Härdin tomas.hardin
Mon Jan 4 10:01:12 CET 2010


On Sun, 2010-01-03 at 21:55 -0500, Ronald S. Bultje wrote:
> Hi,
> 
> On Fri, Jan 1, 2010 at 5:10 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > i think this is ok if tested unless we have some volunteer to maintain http.c
> > iam after all not ideal for the http maintainer role as i dont know the fine
> > details of it
> 
> I can maintain.
> 
> One thing:
> 
>  static int http_close(URLContext *h)
>  {
> +    int ret;
> +    char footer[] = "0\r\n\r\n";
>      HTTPContext *s = h->priv_data;
> +
> +    /* signal end of chunked encoding if used */
> +    if ((h->flags & URL_WRONLY) && s->chunksize != -1 &&
> +        (ret = url_write(s->hd, footer, sizeof(footer) - 1)) < 0)
> +        return ret;
> +
>      url_close(s->hd);
>      av_free(s);
>      return 0;
> 
> If it fails, you want to close it the more, and still return an error,
> no? If the write fails, this is a memleak.
> 

Oops. I blame too much RAII as of late. Attached patch fixed. Any actual
error is returned (EIO most likely). Had to use ? : so http_close()
doesn't return positive values.

> (BTW why does close() have an error return value anyway?)

Because problems can occur while it is being called, such as an
interrupt. It seems at least EBADF, EINTR and EIO can occur. See
 http://www.opengroup.org/onlinepubs/000095399/functions/close.html

/Tomas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: http_1_chunked_v2_closefixed.diff
Type: text/x-patch
Size: 2290 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100104/de171496/attachment.bin>



More information about the ffmpeg-devel mailing list