summaryrefslogtreecommitdiff
path: root/socket/tcp-bsd.c
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2014-04-02 21:53:12 -0400
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>2014-05-15 09:38:52 -0400
commit2243ba07b9700a6adbd9fce4d11f9ccce5751454 (patch)
tree598ab4e0be9b7ea3ad368a98725702115d46c0d7 /socket/tcp-bsd.c
parent48428cdac69503053469d2361ce8c2b43394dae4 (diff)
downloadlibnice-2243ba07b9700a6adbd9fce4d11f9ccce5751454.tar.gz
Allow tcp-bsd to act as reliable or non reliable transport and fix is_reliable on other sockets
Diffstat (limited to 'socket/tcp-bsd.c')
-rw-r--r--socket/tcp-bsd.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/socket/tcp-bsd.c b/socket/tcp-bsd.c
index 474251f..6e3f2e4 100644
--- a/socket/tcp-bsd.c
+++ b/socket/tcp-bsd.c
@@ -59,6 +59,7 @@ typedef struct {
GMainContext *context;
GSource *io_source;
gboolean error;
+ gboolean reliable;
} TcpPriv;
struct to_be_sent {
@@ -84,7 +85,7 @@ static gboolean socket_send_more (GSocket *gsocket, GIOCondition condition,
gpointer data);
NiceSocket *
-nice_tcp_bsd_socket_new (GMainContext *ctx, NiceAddress *addr)
+nice_tcp_bsd_socket_new (GMainContext *ctx, NiceAddress *addr, gboolean reliable)
{
union {
struct sockaddr_storage storage;
@@ -171,6 +172,7 @@ nice_tcp_bsd_socket_new (GMainContext *ctx, NiceAddress *addr)
priv->context = g_main_context_ref (ctx);
priv->server_addr = *addr;
priv->error = FALSE;
+ priv->reliable = reliable;
sock->type = NICE_SOCKET_TYPE_TCP_BSD;
sock->fileno = gsock;
@@ -292,6 +294,9 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
add_to_be_sent (sock, message, ret, message_len, TRUE);
ret = message_len;
}
+ } else if (priv->reliable) {
+ /* Reliable TCP, so we shouldn't drop any messages or queue them */
+ ret = 0;
} else {
/* FIXME: This dropping will break http/socks5/etc
* We probably need a way to the upper layer to control reliability
@@ -350,7 +355,9 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to,
static gboolean
socket_is_reliable (NiceSocket *sock)
{
- return TRUE;
+ TcpPriv *priv = sock->priv;
+
+ return priv->reliable;
}