[FFmpeg-devel] [PATCH 9/9] Add http multi-client example code

Nicolas George george at nsup.org
Mon Jul 6 20:20:04 CEST 2015

Le sextidi 16 messidor, an CCXXIII, Stephan Holljes a écrit :
> Yes, I tested it with multiple simultaneous wget instances and with
> siege (a benchmark tool for webservers).

Good. Although you should also test manually, with socat / nc / telnet.

> I see that I missed closing the client context in the server process,
> but I think the server context is being closed when the client process
> reaches the end label.

Yes, but that is too late: imagine you want to restart the server while some
clients are still alive. It is good practice to close file descriptors as
soon as possible, and with forking servers it is especially important to
follow that practice.

Of course, with example code, following good practices can be dispensed
with, but if it does not make the code more complex there is no reason to.

In fact, I believe you should move all client-related code in a separate

void client(AVIOContext *client)

    if (pid == 0) {

That way, changing it into a thread (less isolation) or a separate program
(fork+exec, more isolation) becomes trivial.

This makes sharing the error reporting code less straightforward, but
sharing the error reporting is always awkward: sometimes you need context,
sometime you do not, some you need more than context, etc. IMHO, with the
simplistic error system in FFmpeg, it is best to put the error message at
the place of the error, even if that means more av_log() and more braces.

Unrelated: when you resend a full patch series, try to remember to annotate
the patches with a few words to say what changed since last version. The
lines between the first "---" and the first "diff --git" where Git puts
ASCII-art histograms are purely informational and can be used for that. You
can use "git send-email --annotate" to get an editor to edit them.

Personally, I always use --annotate because it gives me an extra chance to
re-read the patch series.


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150706/dae456f6/attachment.sig>

More information about the ffmpeg-devel mailing list