diff options
author | Carlos Garcia Campos <cgarcia@igalia.com> | 2020-11-06 14:06:01 +0100 |
---|---|---|
committer | Carlos Garcia Campos <cgarcia@igalia.com> | 2020-11-06 14:35:22 +0100 |
commit | 97bb05552104615e1c9c9b53180e2f30a2ecb225 (patch) | |
tree | 4087e7550a6fa624d94ccb4547b42b4996de5922 | |
parent | 1827eeda856214b26b7222eb57b77b37558df334 (diff) | |
download | libsoup-carlosgc/message-flags.tar.gz |
message: remove SOUP_MESSAGE_IGNORE_CONNECTION_LIMITS flagcarlosgc/message-flags
This was added for a very specific case of WebKit and it's no longer
needed. Nobody else seems to be using it and it complicates the
connection creation algorithm, so better remove it.
-rw-r--r-- | libsoup/soup-message-queue.h | 1 | ||||
-rw-r--r-- | libsoup/soup-message.c | 6 | ||||
-rw-r--r-- | libsoup/soup-message.h | 3 | ||||
-rw-r--r-- | libsoup/soup-session.c | 59 | ||||
-rw-r--r-- | tests/connection-test.c | 17 |
5 files changed, 15 insertions, 71 deletions
diff --git a/libsoup/soup-message-queue.h b/libsoup/soup-message-queue.h index 934b108a..d38c1f3b 100644 --- a/libsoup/soup-message-queue.h +++ b/libsoup/soup-message-queue.h @@ -51,7 +51,6 @@ struct _SoupMessageQueueItem { guint io_started : 1; guint async : 1; guint async_pending : 1; - guint conn_is_dedicated : 1; guint connect_only : 1; guint priority : 3; guint resend_count : 5; diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c index 809731ee..1a63bf79 100644 --- a/libsoup/soup-message.c +++ b/libsoup/soup-message.c @@ -1347,12 +1347,6 @@ soup_message_cleanup_response (SoupMessage *msg) * regardless its #SoupMessage:method, and allows reuse of existing * idle connections, instead of always requiring a new one, unless * #SOUP_MESSAGE_NEW_CONNECTION is set. - * @SOUP_MESSAGE_IGNORE_CONNECTION_LIMITS: Request that a new connection is - * created for the message if there aren't idle connections available - * and it's not possible to create new connections due to any of the - * connection limits has been reached. If a dedicated connection is - * eventually created for this message, it will be dropped when the - * message finishes. Since 2.50 * @SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE: The #SoupAuthManager should not use * the credentials cache for this message, neither to use cached credentials * to automatically authenticate this message nor to cache the credentials diff --git a/libsoup/soup-message.h b/libsoup/soup-message.h index 36094843..f4fb6c4f 100644 --- a/libsoup/soup-message.h +++ b/libsoup/soup-message.h @@ -77,8 +77,7 @@ typedef enum { SOUP_MESSAGE_NO_REDIRECT = (1 << 1), SOUP_MESSAGE_NEW_CONNECTION = (1 << 2), SOUP_MESSAGE_IDEMPOTENT = (1 << 3), - SOUP_MESSAGE_IGNORE_CONNECTION_LIMITS = (1 << 4), - SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE = (1 << 5) + SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE = (1 << 4) } SoupMessageFlags; SOUP_AVAILABLE_IN_2_4 diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c index e427ffa4..c4b95bfe 100644 --- a/libsoup/soup-session.c +++ b/libsoup/soup-session.c @@ -892,7 +892,6 @@ soup_session_set_item_connection (SoupSession *session, { g_clear_object (&item->conn); item->conn = conn ? g_object_ref (conn) : NULL; - item->conn_is_dedicated = FALSE; soup_message_set_connection (item->msg, conn); } @@ -1127,14 +1126,11 @@ soup_session_unqueue_item (SoupSession *session, { SoupSessionPrivate *priv = soup_session_get_instance_private (session); SoupSessionHost *host; - SoupConnection *dedicated_conn = NULL; GSList *f; if (item->conn) { - if (item->conn_is_dedicated) - dedicated_conn = g_object_ref (item->conn); - else if (soup_message_get_method (item->msg) != SOUP_METHOD_CONNECT || - !SOUP_STATUS_IS_SUCCESSFUL (soup_message_get_status (item->msg))) + if (soup_message_get_method (item->msg) != SOUP_METHOD_CONNECT || + !SOUP_STATUS_IS_SUCCESSFUL (soup_message_get_status (item->msg))) soup_connection_set_state (item->conn, SOUP_CONNECTION_IDLE); soup_session_set_item_connection (session, item, NULL); } @@ -1149,21 +1145,9 @@ soup_session_unqueue_item (SoupSession *session, g_mutex_lock (&priv->conn_lock); host = get_host_for_message (session, item->msg); host->num_messages--; - if (dedicated_conn) { - /* FIXME: Do not drop the connection if current number of connections - * is no longer over the limits, just mark it as IDLE so it can be reused. - */ - g_hash_table_remove (priv->conns, dedicated_conn); - drop_connection (session, host, dedicated_conn); - } g_cond_broadcast (&priv->conn_cond); g_mutex_unlock (&priv->conn_lock); - if (dedicated_conn) { - soup_connection_disconnect (dedicated_conn); - g_object_unref (dedicated_conn); - } - /* g_signal_handlers_disconnect_by_func doesn't work if you * have a metamarshal, meaning it doesn't work with * soup_message_add_header_handler() @@ -1446,9 +1430,7 @@ get_connection_for_host (SoupSession *session, SoupMessageQueueItem *item, SoupSessionHost *host, gboolean need_new_connection, - gboolean ignore_connection_limits, - gboolean *try_cleanup, - gboolean *is_dedicated_connection) + gboolean *try_cleanup) { SoupSessionPrivate *priv = soup_session_get_instance_private (session); SoupConnection *conn; @@ -1476,30 +1458,18 @@ get_connection_for_host (SoupSession *session, /* Limit the number of pending connections; num_messages / 2 * is somewhat arbitrary... */ - if (num_pending > host->num_messages / 2) { - if (!ignore_connection_limits) - return NULL; - - *is_dedicated_connection = TRUE; - } + if (num_pending > host->num_messages / 2) + return NULL; if (host->num_conns >= priv->max_conns_per_host) { - if (!ignore_connection_limits) { - if (need_new_connection) - *try_cleanup = TRUE; - return NULL; - } - - *is_dedicated_connection = TRUE; + if (need_new_connection) + *try_cleanup = TRUE; + return NULL; } if (priv->num_conns >= priv->max_conns) { - if (!ignore_connection_limits) { - *try_cleanup = TRUE; - return NULL; - } - - *is_dedicated_connection = TRUE; + *try_cleanup = TRUE; + return NULL; } ensure_socket_props (session); @@ -1540,8 +1510,6 @@ get_connection (SoupMessageQueueItem *item, gboolean *should_cleanup) SoupConnection *conn = NULL; gboolean my_should_cleanup = FALSE; gboolean need_new_connection; - gboolean ignore_connection_limits; - gboolean is_dedicated_connection = FALSE; soup_session_cleanup_connections (session, FALSE); @@ -1549,17 +1517,13 @@ get_connection (SoupMessageQueueItem *item, gboolean *should_cleanup) (soup_message_query_flags (item->msg, SOUP_MESSAGE_NEW_CONNECTION)) || (!soup_message_query_flags (item->msg, SOUP_MESSAGE_IDEMPOTENT) && !SOUP_METHOD_IS_IDEMPOTENT (soup_message_get_method (item->msg))); - ignore_connection_limits = - soup_message_query_flags (item->msg, SOUP_MESSAGE_IGNORE_CONNECTION_LIMITS); g_mutex_lock (&priv->conn_lock); host = get_host_for_message (session, item->msg); while (TRUE) { conn = get_connection_for_host (session, item, host, need_new_connection, - ignore_connection_limits, - &my_should_cleanup, - &is_dedicated_connection); + &my_should_cleanup); if (conn || item->async) break; @@ -1583,7 +1547,6 @@ get_connection (SoupMessageQueueItem *item, gboolean *should_cleanup) } soup_session_set_item_connection (session, item, conn); - item->conn_is_dedicated = is_dedicated_connection; if (soup_connection_get_state (item->conn) != SOUP_CONNECTION_NEW) { item->state = SOUP_MESSAGE_READY; diff --git a/tests/connection-test.c b/tests/connection-test.c index 6a9141d1..040f5fdd 100644 --- a/tests/connection-test.c +++ b/tests/connection-test.c @@ -462,7 +462,7 @@ max_conns_message_complete (SoupMessage *msg, gpointer user_data) static void do_max_conns_test_for_session (SoupSession *session) { - SoupMessage *msgs[TEST_CONNS + 1]; + SoupMessage *msgs[TEST_CONNS]; int i; max_conns_loop = g_main_loop_new (NULL, TRUE); @@ -472,7 +472,7 @@ do_max_conns_test_for_session (SoupSession *session) g_signal_connect (session, "request-queued", G_CALLBACK (max_conns_request_queued), NULL); msgs_done = 0; - for (i = 0; i < TEST_CONNS - 1; i++) { + for (i = 0; i < TEST_CONNS; i++) { msgs[i] = soup_message_new_from_uri ("GET", base_uri); g_signal_connect (msgs[i], "finished", G_CALLBACK (max_conns_message_complete), NULL); @@ -486,20 +486,9 @@ do_max_conns_test_for_session (SoupSession *session) g_source_remove (quit_loop_timeout); quit_loop_timeout = g_timeout_add (1000, quit_loop, NULL); - for (i = 0; i < TEST_CONNS - 1; i++) + for (i = 0; i < TEST_CONNS; i++) g_signal_handlers_disconnect_by_func (msgs[i], max_conns_message_started, NULL); - /* Message with SOUP_MESSAGE_IGNORE_CONNECTION_LIMITS should start */ - msgs[i] = soup_message_new_from_uri ("GET", base_uri); - soup_message_add_flags (msgs[i], SOUP_MESSAGE_IGNORE_CONNECTION_LIMITS); - g_signal_connect (msgs[i], "finished", - G_CALLBACK (max_conns_message_complete), NULL); - soup_session_send_async (session, msgs[i], G_PRIORITY_DEFAULT, NULL, NULL, NULL); - - g_main_loop_run (max_conns_loop); - g_assert_cmpint (msgs_done, ==, MAX_CONNS + 1); - g_signal_handlers_disconnect_by_func (session, max_conns_request_queued, NULL); - msgs_done = 0; g_idle_add (idle_start_server, NULL); if (quit_loop_timeout) |