diff options
author | Jens Georg <mail@jensge.org> | 2022-10-25 23:28:21 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2022-10-25 23:28:21 +0200 |
commit | 6175fe91f240e0e17cb75dac548da4fa939456b3 (patch) | |
tree | 434a6ec88bc7e1100ffaa65d974049e272b0c96f | |
parent | 2a9c4f3e3f8e305b617c89d229dda6eceb9bf1ec (diff) | |
download | gupnp-6175fe91f240e0e17cb75dac548da4fa939456b3.tar.gz |
ControlPoint: Fix error handling of description
Do not assert_not_reached() on errors, but handle timeouts with retry
and other errors like other parsing errors
-rw-r--r-- | libgupnp/gupnp-control-point.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/libgupnp/gupnp-control-point.c b/libgupnp/gupnp-control-point.c index aedcdf2..7c5405e 100644 --- a/libgupnp/gupnp-control-point.c +++ b/libgupnp/gupnp-control-point.c @@ -579,6 +579,7 @@ got_description_url (GObject *source, GUPnPXMLDoc *doc; GUPnPControlPointPrivate *priv; GError *error = NULL; + gboolean retry = FALSE; SoupMessage *message = soup_session_get_async_result_message (SOUP_SESSION (source), res); @@ -590,9 +591,17 @@ got_description_url (GObject *source, if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) goto out; + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_TIMED_OUT)) { + g_clear_error (&error); + retry = TRUE; + } + // FIXME: This needs better handling - if (error != NULL) - g_assert_not_reached (); + if (error != NULL) { + g_warning ("Retrieving the description document failed: %s", + error->message); + goto out; + } priv = gupnp_control_point_get_instance_private (data->control_point); @@ -611,7 +620,8 @@ got_description_url (GObject *source, } /* Not cached */ - if (SOUP_STATUS_IS_SUCCESSFUL (soup_message_get_status (message))) { + if (!retry && + SOUP_STATUS_IS_SUCCESSFUL (soup_message_get_status (message))) { xmlDoc *xml_doc; gsize length; gconstpointer body_data; @@ -656,7 +666,9 @@ got_description_url (GObject *source, g_warning ( "Failed to GET %s: %s, retrying in %d seconds", data->description_url, - soup_message_get_reason_phrase (message), + !retry ? soup_message_get_reason_phrase ( + message) + : "Timed out", data->timeout); data->timeout_source = g_timeout_source_new_seconds @@ -699,6 +711,8 @@ load_description (GUPnPControlPoint *control_point, GUPnPXMLDoc *doc; GUPnPControlPointPrivate *priv; + g_debug ("Loading description document %s", description_url); + priv = gupnp_control_point_get_instance_private (control_point); doc = g_hash_table_lookup (priv->doc_cache, description_url); |