Handle error cases

Add a link state
Add error quark
Track the state of node we create and error when it is in error.
Handle stream error states when negotiating
Make the node error when a link is in error
This commit is contained in:
Wim Taymans 2016-09-16 13:13:41 +02:00
parent 6497c82a7d
commit 2bf322ee71
15 changed files with 422 additions and 71 deletions

View file

@ -230,6 +230,34 @@ stream_set_state (PinosStream *stream,
}
}
static void
on_node_info (PinosContext *c,
const PinosNodeInfo *info,
gpointer user_data)
{
PinosStream *stream = PINOS_STREAM (user_data);
if (info->state == PINOS_NODE_STATE_ERROR) {
g_debug ("stream %p: node %s in error", stream, info->node_path);
stream_set_state (stream,
PINOS_STREAM_STATE_ERROR,
g_error_new (PINOS_ERROR,
PINOS_ERROR_NODE_STATE,
"node is in error"));
}
}
static void
info_ready (GObject *o, GAsyncResult *res, gpointer user_data)
{
GError *error = NULL;
if (!pinos_context_info_finish (o, res, &error)) {
g_printerr ("introspection failure: %s\n", error->message);
g_clear_error (&error);
}
}
static void
subscription_cb (PinosSubscribe *subscribe,
PinosSubscriptionEvent event,
@ -250,6 +278,16 @@ subscription_cb (PinosSubscribe *subscribe,
G_IO_ERROR_CLOSED,
"Node disappeared"));
}
} else if (event == PINOS_SUBSCRIPTION_EVENT_CHANGE) {
if (object == priv->node && !priv->disconnecting) {
pinos_context_get_node_info_by_id (priv->context,
object,
PINOS_NODE_INFO_FLAGS_NONE,
on_node_info,
NULL,
info_ready,
stream);
}
}
break;