Re: How do you deal with lengthy server tasks?



On 2/3/19 1:26 PM, Biz.122 via libsoup-list wrote:
Hey,
I would like to stream some audio with soup server. How would you go
about something like that? Each browser request will launch the server
callback that does all processing, but I cannot stay in there looping
and sending data. This will block any other requests.

I looked around a bit and found this:
https://github.com/GNOME/libsoup/blob/54014b2d8a7b579b832372cb4dd22df04fefd45e/tests/context-test.c#L41

Look at the "SlowData / soup_add_timeout" example.
Is this how you would typically perform streaming tasks or large file
transfers, and not completely locking up your server callback?

Yeah, kinda. The libsoup tests are generally not great examples to
follow because they are often doing weird things so as to test specific
codepaths or to confirm that old bugs are still fixed.

That said, tests/streaming-test.c is probably a better example to follow
that tests/context-test.c. The example there is written to send each new
chunk of response data immediately after the previous chunk is sent (by
using the "wrote_chunk" signal on the message) but you could have the
callback be triggered by something external instead. It's fine if you
queue up data faster than it gets written to the network, and it's fine
if you "underflow" and don't write data fast enough; the I/O will just
pause until you write the next chunk.

There's an old bug about adding "streaming-style" APIs to SoupServer
(https://gitlab.gnome.org/GNOME/libsoup/issues/67) that would work like
soup_session_send(), but it has never been implemented.

-- Dan


Best Regards,
Biz


Sent with ProtonMail <https://protonmail.com> Secure Email.


_______________________________________________
libsoup-list mailing list
libsoup-list gnome org
https://mail.gnome.org/mailman/listinfo/libsoup-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]