Commit b10eb7ae authored by Ole André Vadla Ravnås's avatar Ole André Vadla Ravnås Committed by Olivier Crête

iostream: Implement close() for ICE-TCP also

parent 462a3629
...@@ -393,6 +393,35 @@ nice_component_close (NiceAgent *agent, NiceStream *stream, NiceComponent *cmp) ...@@ -393,6 +393,35 @@ nice_component_close (NiceAgent *agent, NiceStream *stream, NiceComponent *cmp)
cmp->rfc4571_buffer = NULL; cmp->rfc4571_buffer = NULL;
} }
void
nice_component_shutdown (NiceComponent *component, gboolean shutdown_read,
gboolean shutdown_write)
{
GSList *i;
g_assert (shutdown_read || shutdown_write);
if (!pseudo_tcp_socket_is_closed (component->tcp)) {
PseudoTcpShutdown how;
if (shutdown_read && shutdown_write)
how = PSEUDO_TCP_SHUTDOWN_RDWR;
else if (shutdown_read)
how = PSEUDO_TCP_SHUTDOWN_RD;
else
how = PSEUDO_TCP_SHUTDOWN_WR;
pseudo_tcp_socket_shutdown (component->tcp, how);
}
for (i = component->socket_sources; i; i = i->next) {
SocketSource *source = i->data;
NiceSocket *sock = source->socket;
if (sock->type == NICE_SOCKET_TYPE_TCP_BSD)
g_socket_shutdown (sock->fileno, shutdown_read, shutdown_write, NULL);
}
}
/* /*
* Finds a candidate pair that has matching foundation ids. * Finds a candidate pair that has matching foundation ids.
* *
......
...@@ -266,6 +266,10 @@ void ...@@ -266,6 +266,10 @@ void
nice_component_close (NiceAgent *agent, NiceStream *stream, nice_component_close (NiceAgent *agent, NiceStream *stream,
NiceComponent *component); NiceComponent *component);
void
nice_component_shutdown (NiceComponent *component, gboolean shutdown_read,
gboolean shutdown_write);
gboolean gboolean
nice_component_find_pair (NiceComponent *component, NiceAgent *agent, nice_component_find_pair (NiceComponent *component, NiceAgent *agent,
const gchar *lfoundation, const gchar *rfoundation, CandidatePair *pair); const gchar *lfoundation, const gchar *rfoundation, CandidatePair *pair);
......
...@@ -333,7 +333,6 @@ nice_input_stream_close (GInputStream *stream, GCancellable *cancellable, ...@@ -333,7 +333,6 @@ nice_input_stream_close (GInputStream *stream, GCancellable *cancellable,
{ {
NiceInputStreamPrivate *priv = NICE_INPUT_STREAM (stream)->priv; NiceInputStreamPrivate *priv = NICE_INPUT_STREAM (stream)->priv;
NiceComponent *component = NULL; NiceComponent *component = NULL;
NiceStream *_stream = NULL;
NiceAgent *agent; /* owned */ NiceAgent *agent; /* owned */
/* Has the agent disappeared? */ /* Has the agent disappeared? */
...@@ -343,11 +342,10 @@ nice_input_stream_close (GInputStream *stream, GCancellable *cancellable, ...@@ -343,11 +342,10 @@ nice_input_stream_close (GInputStream *stream, GCancellable *cancellable,
agent_lock (agent); agent_lock (agent);
/* Shut down the read side of the pseudo-TCP stream, if it still exists. */ /* Shut down the read side of the TCP stream, if it still exists. */
if (agent_find_component (agent, priv->stream_id, priv->component_id, if (agent_find_component (agent, priv->stream_id, priv->component_id, NULL,
&_stream, &component) && agent->reliable && &component)) {
!pseudo_tcp_socket_is_closed (component->tcp)) { nice_component_shutdown (component, TRUE, FALSE);
pseudo_tcp_socket_shutdown (component->tcp, PSEUDO_TCP_SHUTDOWN_RD);
} }
agent_unlock (agent); agent_unlock (agent);
......
...@@ -477,7 +477,6 @@ nice_output_stream_close (GOutputStream *stream, GCancellable *cancellable, ...@@ -477,7 +477,6 @@ nice_output_stream_close (GOutputStream *stream, GCancellable *cancellable,
{ {
NiceOutputStreamPrivate *priv = NICE_OUTPUT_STREAM (stream)->priv; NiceOutputStreamPrivate *priv = NICE_OUTPUT_STREAM (stream)->priv;
NiceComponent *component = NULL; NiceComponent *component = NULL;
NiceStream *_stream = NULL;
NiceAgent *agent; /* owned */ NiceAgent *agent; /* owned */
/* Has the agent disappeared? */ /* Has the agent disappeared? */
...@@ -487,11 +486,10 @@ nice_output_stream_close (GOutputStream *stream, GCancellable *cancellable, ...@@ -487,11 +486,10 @@ nice_output_stream_close (GOutputStream *stream, GCancellable *cancellable,
agent_lock (agent); agent_lock (agent);
/* Shut down the write side of the pseudo-TCP stream. */ /* Shut down the write side of the TCP stream. */
if (agent_find_component (agent, priv->stream_id, priv->component_id, if (agent_find_component (agent, priv->stream_id, priv->component_id, NULL,
&_stream, &component) && agent->reliable && &component)) {
!pseudo_tcp_socket_is_closed (component->tcp)) { nice_component_shutdown (component, FALSE, TRUE);
pseudo_tcp_socket_shutdown (component->tcp, PSEUDO_TCP_SHUTDOWN_WR);
} }
agent_unlock (agent); agent_unlock (agent);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment