[Ffmpeg-devel] Stream file handle hijacking by another thread

Stas Oskin stas.oskin
Sun Feb 18 14:34:18 CET 2007


> Apparently, the h->priv_data somehow resets to 0x0, which in turn sets
> the file descriptor to 0 as well. This leads to the mentioned errors,
> and apparently to the bug of several threads writing to same file.

I traced the issue to the begining, and have found the cause for the
problem. Some of the file descriptors (fd) are set to 0 from the
start, from the open() function:

static int file_open(URLContext *h, const char *filename, int flags)
{
...
    fd = open(filename, access, 0666); /* fd gets 0 */
...
    h->priv_data = (void *)(size_t)fd; /* priv_data gets 0 as well */
}

This happens for several threads in the same process. AFAIK open()
should gurantee unique fd, but this is not the case here.

Can anyone advice what should be done here?




More information about the ffmpeg-devel mailing list