Re: How do you deal with lengthy server tasks?
- From: "Biz.122" <biz 122 protonmail com>
- To: Guillaume Poirier-Morency <guillaumepoiriermorency gmail com>
- Cc: "libsoup-list gnome org" <libsoup-list gnome org>
- Subject: Re: How do you deal with lengthy server tasks?
- Date: Fri, 08 Feb 2019 11:35:17 +0000
Ok,
So far I got it working. I am doing it asynchronously, which seems to be working pretty well.
Since I am carrying my SoupMessage with me from the server callback (whether it is to a thread or an
asynchronous cb), occasionally I will get: soup_server_unpause_message: assertion 'SOUP_IS_MESSAGE (msg)'
failed. Gdb may step in and halt the execution; which is completely understandable.
Because I am out of the server-callback I currently don't know if the SoupMessage is still 'valid'.
How can I determine that the SoupMessage is still in the game?
Best regards,
Biz
Sent with ProtonMail Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, February 5, 2019 4:24 PM, Guillaume Poirier-Morency via libsoup-list <libsoup-list gnome org>
wrote:
Le dimanche 03 février 2019 à 18:26 +0000, Biz.122 via libsoup-list a
écrit :
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?
You can pause the message with soup_server_pause_message, launch the
task in background and resume it later with
soup_server_unpause_message.
To send data continuously, you can mix that with a chunked response.
soup_message_headers_set_encoding (msg, SOUP_ENCODING_CHUNKED);
soup_server_pause_message (msg);
g_thread_pool_push (pool, msg, NULL);
In the thread pool (or asynchronously via the GMainLoop):
soup_message_body_append_take (data, data_len);
soup_server_unpause_message (msg); // deliver the chunk
// later when done
soup_message_complete (msg);
soup_server_unpause_message (msg);
Best Regards,
Biz
Sent with ProtonMail Secure Email.
libsoup-list mailing list
libsoup-list gnome org
https://mail.gnome.org/mailman/listinfo/libsoup-list
--
Guillaume Poirier-Morency guillaumepoiriermorency gmail com
Étudiant à la maîtrise en informatique à l'Université de Montréal
Chercheur à l'IRIC
Mon blog: https://arteymix.github.io/
Clé PGP: B1AD6EA5
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]