After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 696277 - Add a priority system to message queue
Add a priority system to message queue
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: HTTP Transport
2.41.x
Other Linux
: Normal normal
: ---
Assigned To: Sergio Villar
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2013-03-21 11:51 UTC by Sergio Villar
Modified: 2013-04-17 08:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (8.69 KB, patch)
2013-03-21 12:18 UTC, Sergio Villar
reviewed Details | Review
Patch (13.02 KB, patch)
2013-03-21 17:06 UTC, Sergio Villar
committed Details | Review

Description Sergio Villar 2013-03-21 11:51:08 UTC
It should be possible to specify a priority for each message added to the queue. A typical use case could be a web browser wanting to prioritize JavaScript or HTML resources over small images.
Comment 1 Sergio Villar 2013-03-21 12:18:33 UTC
Created attachment 239460 [details] [review]
Patch

Didn't add the "Since:" to the docs because I don't know if we want to add this for 2.42
Comment 2 Dan Winship 2013-03-21 12:48:13 UTC
(In reply to comment #1)
> Didn't add the "Since:" to the docs because I don't know if we want to add this
> for 2.42

hard code freeze was Monday, so it will be 2.44
Comment 3 Dan Winship 2013-03-21 13:06:44 UTC
Comment on attachment 239460 [details] [review]
Patch

(Too late for 2.42, but since I'm already reading this bug...)

Basically looks good. For some reason, I was thinking it was going to have to be more complicated than this.

>+	/**
>+	 * SOUP_MESSAGE_PRIORITY:
>+	 *
>+	 * Alias for the #SoupMessage:priority property (the
>+	 * message's priority).
>+	 **/

You should override the default g_param_spec-generated doc with a SoupMessage:priority gtk-doc, and put "see soup_message_set_priority() for more details" there. (Or else include the relevant bits from those docs in the property docs as well.)

>+ * Sets the priority of a message. Note that this won't have any
>+ * effect unless used before the message is added to the message
>+ * processing queue

If this restriction turns out to be a problem, the queue could connect to notify::priority and re-sort itself when a message changes priority. But we don't need to implement that unless we need it later.

>    either by calling soup_session_queue_message(),
>+ * soup_session_send_message(), soup_session_send() or
>+ * soup_session_send_async().

As currently written, the code will not work with SoupSessionSync (or with synchronous messages on a plain SoupSession), because in the synchronous/blocking case, priority ends up being determined semi-randomly by thread scheduling. I want to fix that some day, but for now I'd say just document that it doesn't work in that case. Oh, and you forgot soup_request_send*(). Actually, you probably don't need to list the specific methods, you can just say "added to the session's message processing queue" or something like that.
Comment 4 Dan Winship 2013-03-21 13:07:04 UTC
oh, needs a test :)
Comment 5 Sergio Villar 2013-03-21 13:18:14 UTC
(In reply to comment #3)
> (From update of attachment 239460 [details] [review])

> >    either by calling soup_session_queue_message(),
> >+ * soup_session_send_message(), soup_session_send() or
> >+ * soup_session_send_async().
> 
> As currently written, the code will not work with SoupSessionSync (or with
> synchronous messages on a plain SoupSession), because in the
> synchronous/blocking case, priority ends up being determined semi-randomly by
> thread scheduling. I want to fix that some day, but for now I'd say just
> document that it doesn't work in that case. Oh, and you forgot
> soup_request_send*(). Actually, you probably don't need to list the specific
> methods, you can just say "added to the session's message processing queue" or
> something like that.

True, I always forget about the synchronous case.
Comment 6 Sergio Villar 2013-03-21 17:06:56 UTC
Created attachment 239483 [details] [review]
Patch
Comment 7 Dan Winship 2013-04-08 19:32:47 UTC
Comment on attachment 239483 [details] [review]
Patch

>+SOUP_VERSION_2_44

please add the version 2.44 stuff as a separate commit

>+	expected_priorities[0] = SOUP_MESSAGE_PRIORITY_HIGH;
>+	expected_priorities[1] = SOUP_MESSAGE_PRIORITY_NORMAL;
>+	expected_priorities[2] = SOUP_MESSAGE_PRIORITY_LOW;

Swap that around to HIGH, LOW, NORMAL. As it is now, the test will pass even if priorities are completely broken, because the default would be for the first-queued message to run first, then the second, then the third.


Other than that, this looks good. I haven't branched yet, so this has to wait until after then (next Monday).
Comment 8 Sergio Villar 2013-04-09 08:25:37 UTC
(In reply to comment #7)
> (From update of attachment 239483 [details] [review])
> >+SOUP_VERSION_2_44
> 
> please add the version 2.44 stuff as a separate commit

OK, I'll do

> >+	expected_priorities[0] = SOUP_MESSAGE_PRIORITY_HIGH;
> >+	expected_priorities[1] = SOUP_MESSAGE_PRIORITY_NORMAL;
> >+	expected_priorities[2] = SOUP_MESSAGE_PRIORITY_LOW;
> 
> Swap that around to HIGH, LOW, NORMAL. As it is now, the test will pass even if
> priorities are completely broken, because the default would be for the
> first-queued message to run first, then the second, then the third.

Not really because the priorities are set using the priorities[] array not that one, and thus are set to LOW, HIGH, NORMAL, which will be the expected result without priorities.
Comment 9 Dan Winship 2013-04-09 14:54:31 UTC
ah, right. ok, so it's good to commit post-freeze, with the 2.44 defines split out separately first
Comment 10 Dan Winship 2013-04-16 17:40:50 UTC
Comment on attachment 239483 [details] [review]
Patch

libsoup is branched now
Comment 11 Sergio Villar 2013-04-17 08:21:58 UTC
Fixed in master c146806d