Commit 5c235a86 authored by Olivier Crête's avatar Olivier Crête

Remove the "to" parameter from NiceOutputMessage

We never send multiple messages to separate targets in practice, so
this will simplify the code
parent a5c8a141
......@@ -1316,10 +1316,9 @@ pseudo_tcp_socket_write_packet (PseudoTcpSocket *socket,
local_buf.size = len;
local_message.buffers = &local_buf;
local_message.n_buffers = 1;
local_message.to = addr;
local_message.length = len;
if (nice_socket_send_messages (sock, &local_message, 1)) {
if (nice_socket_send_messages (sock, addr, &local_message, 1)) {
return WR_SUCCESS;
}
} else {
......@@ -3264,7 +3263,6 @@ nice_agent_send_messages_nonblocking (
} else if (component->selected_pair.local != NULL) {
NiceSocket *sock;
NiceAddress *addr;
guint i;
#ifndef NDEBUG
gchar tmpbuf[INET6_ADDRSTRLEN];
......@@ -3278,13 +3276,8 @@ nice_agent_send_messages_nonblocking (
sock = component->selected_pair.local->sockptr;
addr = &component->selected_pair.remote->addr;
/* Set the destination address. FIXME: This is ugly. */
for (i = 0; i < n_messages; i++) {
NiceOutputMessage *message = (NiceOutputMessage *) &messages[i];
message->to = addr;
}
n_sent_messages = nice_socket_send_messages (sock, messages, n_messages);
n_sent_messages = nice_socket_send_messages (sock, addr, messages,
n_messages);
if (n_sent_messages < 0) {
g_set_error (&child_error, G_IO_ERROR, G_IO_ERROR_FAILED,
......@@ -3327,7 +3320,7 @@ nice_agent_send (
const gchar *buf)
{
GOutputVector local_buf = { buf, len };
NiceOutputMessage local_message = { &local_buf, 1, NULL, len };
NiceOutputMessage local_message = { &local_buf, 1, len };
gint n_sent_messages;
n_sent_messages = nice_agent_send_messages_nonblocking (agent, stream_id,
......
......@@ -176,14 +176,12 @@ typedef struct {
* which contain data to transmit for this message
* @n_buffers: number of #GOutputVectors in @buffers, or -1 to indicate @buffers
* is %NULL-terminated
* @to: (allow-none): address of the peer to transmit the message to, or %NULL
* to use the default address for the outbound socket
* @length: total number of valid bytes contiguously stored in @buffers
*
* Represents a single message to transmit on the network. For reliable
* connections, this is essentially just an array of buffers (specifically,
* @to can be ignored). for non-reliable connections, it represents a single
* packet to send to the OS.
* Represents a single message to transmit on the network. For
* reliable connections, this is essentially just an array of
* buffer. for non-reliable connections, it represents a single packet
* to send to the OS.
*
* @n_buffers may be -1 to indicate that @buffers is terminated by a
* #GOutputVector with a %NULL buffer pointer.
......@@ -199,7 +197,6 @@ typedef struct {
typedef struct {
GOutputVector *buffers;
gint n_buffers;
const NiceAddress *to;
gsize length;
} NiceOutputMessage;
......
......@@ -403,9 +403,7 @@ nice_output_stream_write (GOutputStream *stream, const void *buffer, gsize count
do {
GOutputVector local_buf = { (const guint8 *) buffer + len, count - len };
NiceOutputMessage local_message = {
&local_buf, 1, NULL, count - len
};
NiceOutputMessage local_message = {&local_buf, 1, count - len};
/* Have to unlock while calling into the agent because
* it will take the agent lock which will cause a deadlock if one of
......@@ -525,7 +523,7 @@ nice_output_stream_write_nonblocking (GPollableOutputStream *stream,
NiceOutputStreamPrivate *priv = NICE_OUTPUT_STREAM (stream)->priv;
NiceAgent *agent; /* owned */
GOutputVector local_buf = { buffer, count };
NiceOutputMessage local_message = { &local_buf, 1, NULL, count };
NiceOutputMessage local_message = { &local_buf, 1, count };
gint n_sent_messages;
/* Closed streams are not writeable. */
......
......@@ -92,12 +92,12 @@ struct to_be_sent {
static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock,
static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock);
static void add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages);
static void add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages);
static void free_to_be_sent (struct to_be_sent *tbs);
......@@ -165,10 +165,9 @@ nice_http_socket_new (NiceSocket *base_socket,
local_bufs.size = strlen (msg);
local_messages.buffers = &local_bufs;
local_messages.n_buffers = 1;
local_messages.to = NULL;
local_messages.length = local_bufs.size;
nice_socket_send_messages (priv->base_socket, &local_messages, 1);
nice_socket_send_messages (priv->base_socket, NULL, &local_messages, 1);
priv->state = HTTP_STATE_INIT;
g_free (msg);
}
......@@ -547,8 +546,7 @@ retry:
/* Send the pending data */
while ((tbs = g_queue_pop_head (&priv->send_queue))) {
nice_socket_send (priv->base_socket, &tbs->to,
tbs->length, tbs->buf);
nice_socket_send (priv->base_socket, &tbs->to, tbs->length, tbs->buf);
g_free (tbs->buf);
g_slice_free (struct to_be_sent, tbs);
}
......@@ -576,8 +574,8 @@ retry:
}
static gint
socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages)
socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages)
{
HttpPriv *priv = sock->priv;
......@@ -586,11 +584,12 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
if (!priv->base_socket)
return -1;
return nice_socket_send_messages (priv->base_socket, messages, n_messages);
return nice_socket_send_messages (priv->base_socket, to, messages,
n_messages);
} else if (priv->state == HTTP_STATE_ERROR) {
return -1;
} else {
add_to_be_sent (sock, messages, n_messages);
add_to_be_sent (sock, to, messages, n_messages);
}
return n_messages;
......@@ -605,8 +604,8 @@ socket_is_reliable (NiceSocket *sock)
static void
add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages)
add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages)
{
HttpPriv *priv = sock->priv;
guint i;
......@@ -628,8 +627,8 @@ add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
tbs = g_slice_new0 (struct to_be_sent);
tbs->buf = g_malloc (message->length);
tbs->length = message->length;
if (message->to)
tbs->to = *message->to;
if (to)
tbs->to = *to;
g_queue_push_tail (&priv->send_queue, tbs);
for (j = 0;
......
......@@ -91,12 +91,12 @@ static const gchar SSL_CLIENT_HANDSHAKE[] = {
static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock,
static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock);
static void add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages);
static void add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages);
static void free_to_be_sent (struct to_be_sent *tbs);
......@@ -190,8 +190,8 @@ socket_recv_messages (NiceSocket *sock,
}
static gint
socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages)
socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages)
{
PseudoSSLPriv *priv = sock->priv;
......@@ -201,9 +201,10 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
if (priv->base_socket == NULL)
return FALSE;
return nice_socket_send_messages (priv->base_socket, messages, n_messages);
return nice_socket_send_messages (priv->base_socket, to, messages,
n_messages);
} else {
add_to_be_sent (sock, messages, n_messages);
add_to_be_sent (sock, to, messages, n_messages);
}
return TRUE;
}
......@@ -217,8 +218,8 @@ socket_is_reliable (NiceSocket *sock)
static void
add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages)
add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages)
{
PseudoSSLPriv *priv = sock->priv;
guint i;
......@@ -234,8 +235,8 @@ add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
/* Compact the buffer. */
tbs->buf = g_malloc (message->length);
tbs->length = message->length;
if (message->to != NULL)
tbs->to = *message->to;
if (to != NULL)
tbs->to = *to;
g_queue_push_tail (&priv->send_queue, tbs);
for (j = 0;
......
......@@ -129,13 +129,13 @@ nice_socket_recv_messages (NiceSocket *sock,
* Since: 0.1.5
*/
gint
nice_socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages)
nice_socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages)
{
g_return_val_if_fail (sock != NULL, -1);
g_return_val_if_fail (n_messages == 0 || messages != NULL, -1);
return sock->send_messages (sock, messages, n_messages);
return sock->send_messages (sock, to, messages, n_messages);
}
/* Convenience wrapper around nice_socket_send_messages(). Returns the number of
......@@ -146,10 +146,10 @@ nice_socket_send (NiceSocket *sock, const NiceAddress *to, gsize len,
const gchar *buf)
{
GOutputVector local_buf = { buf, len };
NiceOutputMessage local_message = { &local_buf, 1, to, len };
NiceOutputMessage local_message = { &local_buf, 1, len };
gint ret;
ret = nice_socket_send_messages (sock, &local_message, 1);
ret = sock->send_messages (sock, to, &local_message, 1);
if (ret == 1)
return len;
return ret;
......
......@@ -64,8 +64,8 @@ struct _NiceSocket
gint (*recv_messages) (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages);
/* As above, @n_messages may be zero. Iff so, @messages may be %NULL. */
gint (*send_messages) (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages);
gint (*send_messages) (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages);
gboolean (*is_reliable) (NiceSocket *sock);
void (*close) (NiceSocket *sock);
void *priv;
......@@ -77,8 +77,8 @@ nice_socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages);
gint
nice_socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages);
nice_socket_send_messages (NiceSocket *sock, const NiceAddress *addr,
const NiceOutputMessage *messages, guint n_messages);
gssize
nice_socket_send (NiceSocket *sock, const NiceAddress *addr, gsize len,
const gchar *buf);
......
......@@ -78,12 +78,12 @@ struct to_be_sent {
static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock,
static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock);
static void add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages);
static void add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages);
static void free_to_be_sent (struct to_be_sent *tbs);
......@@ -419,8 +419,8 @@ socket_recv_messages (NiceSocket *sock,
}
static gint
socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages)
socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages)
{
Socks5Priv *priv = sock->priv;
......@@ -429,11 +429,12 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
if (priv->base_socket == NULL)
return FALSE;
return nice_socket_send_messages (priv->base_socket, messages, n_messages);
return nice_socket_send_messages (priv->base_socket, to, messages,
n_messages);
} else if (priv->state == SOCKS_STATE_ERROR) {
return FALSE;
} else {
add_to_be_sent (sock, messages, n_messages);
add_to_be_sent (sock, to, messages, n_messages);
}
return TRUE;
}
......@@ -447,8 +448,8 @@ socket_is_reliable (NiceSocket *sock)
static void
add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages)
add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages)
{
Socks5Priv *priv = sock->priv;
guint i;
......@@ -464,8 +465,8 @@ add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
/* Compact the buffer. */
tbs->buf = g_malloc (message->length);
tbs->length = message->length;
if (message->to != NULL)
tbs->to = *message->to;
if (to != NULL)
tbs->to = *to;
g_queue_push_tail (&priv->send_queue, tbs);
for (j = 0;
......
......@@ -72,7 +72,7 @@ struct to_be_sent {
static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock,
static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock);
......@@ -316,8 +316,8 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
* dropped if the bandwidth isn't fast enough. So do not send a message in
* multiple chunks. */
static gint
socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages)
socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages)
{
guint i;
......@@ -389,9 +389,7 @@ socket_send_more (
if (gerr != NULL &&
g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
GOutputVector local_buf = { tbs->buf, tbs->length };
NiceOutputMessage local_message = {
&local_buf, 1, NULL, local_buf.size
};
NiceOutputMessage local_message = {&local_buf, 1, local_buf.size};
add_to_be_sent (sock, &local_message, 0, TRUE);
free_to_be_sent (tbs);
......@@ -401,9 +399,7 @@ socket_send_more (
g_error_free (gerr);
} else if (ret < (int) tbs->length) {
GOutputVector local_buf = { tbs->buf + ret, tbs->length - ret };
NiceOutputMessage local_message = {
&local_buf, 1, NULL, local_buf.size
};
NiceOutputMessage local_message = {&local_buf, 1, local_buf.size};
add_to_be_sent (sock, &local_message, 0, TRUE);
free_to_be_sent (tbs);
......
......@@ -69,7 +69,7 @@ typedef struct {
static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock,
static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock);
......@@ -223,7 +223,8 @@ socket_recv_messages (NiceSocket *socket,
}
static gssize
socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
socket_send_message (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *message)
{
TurnTcpPriv *priv = sock->priv;
guint8 padbuf[3] = {0, 0, 0};
......@@ -249,7 +250,6 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
local_bufs = g_malloc_n (n_bufs + 2, sizeof (GOutputVector));
local_message.buffers = local_bufs;
local_message.n_buffers = n_bufs + 2;
local_message.to = message->to;
local_message.length = message->length;
/* Copy the existing buffers across. */
......@@ -284,7 +284,7 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
local_message.n_buffers--;
}
ret = nice_socket_send_messages (priv->base_socket, &local_message, 1);
ret = nice_socket_send_messages (priv->base_socket, to, &local_message, 1);
g_free (local_bufs);
......@@ -294,8 +294,8 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
}
static gint
socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages)
socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages)
{
guint i;
......@@ -303,7 +303,7 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
const NiceOutputMessage *message = &messages[i];
gssize len;
len = socket_send_message (sock, message);
len = socket_send_message (sock, to, message);
if (len < 0) {
/* Error. */
......
......@@ -116,7 +116,7 @@ typedef struct {
static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock,
static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock);
......@@ -548,7 +548,8 @@ socket_dequeue_all_data (TurnPriv *priv, const NiceAddress *to)
static gssize
socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
socket_send_message (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *message)
{
TurnPriv *priv = (TurnPriv *) sock->priv;
StunMessage msg;
......@@ -564,13 +565,13 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
for (; i; i = i->next) {
ChannelBinding *b = i->data;
if (nice_address_equal (&b->peer, message->to)) {
if (nice_address_equal (&b->peer, to)) {
binding = b;
break;
}
}
nice_address_copy_to_sockaddr (message->to, &sa.addr);
nice_address_copy_to_sockaddr (to, &sa.addr);
if (binding) {
if (priv->compatibility == NICE_TURN_SOCKET_COMPATIBILITY_DRAFT9 ||
......@@ -608,11 +609,11 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
}
} else {
NiceOutputMessage local_message = {
message->buffers, message->n_buffers, &priv->server_addr,
message->length
message->buffers, message->n_buffers, message->length
};
ret = nice_socket_send_messages (priv->base_socket, &local_message, 1);
ret = nice_socket_send_messages (priv->base_socket, &priv->server_addr,
&local_message, 1);
if (ret == 1)
return message->length;
return ret;
......@@ -651,7 +652,7 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
if (priv->compatibility == NICE_TURN_SOCKET_COMPATIBILITY_GOOGLE &&
priv->current_binding &&
nice_address_equal (&priv->current_binding->peer, message->to)) {
nice_address_equal (&priv->current_binding->peer, to)) {
stun_message_append32 (&msg, STUN_ATTRIBUTE_OPTIONS, 1);
}
}
......@@ -695,23 +696,22 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
if (msg_len > 0) {
if (priv->compatibility == NICE_TURN_SOCKET_COMPATIBILITY_RFC5766 &&
!priv_has_permission_for_peer (priv, message->to)) {
if (!priv_has_sent_permission_for_peer (priv, message->to)) {
priv_send_create_permission (priv, NULL, message->to);
!priv_has_permission_for_peer (priv, to)) {
if (!priv_has_sent_permission_for_peer (priv, to)) {
priv_send_create_permission (priv, NULL, to);
}
/* enque data */
nice_debug ("enqueuing data");
socket_enqueue_data(priv, message->to, msg_len, (gchar *)buffer);
socket_enqueue_data(priv, to, msg_len, (gchar *)buffer);
return msg_len;
} else {
GOutputVector local_buf = { buffer, msg_len };
NiceOutputMessage local_message = {
&local_buf, 1, &priv->server_addr, msg_len
};
NiceOutputMessage local_message = {&local_buf, 1, msg_len};
ret = nice_socket_send_messages (priv->base_socket, &local_message, 1);
ret = nice_socket_send_messages (priv->base_socket, &priv->server_addr,
&local_message, 1);
if (ret == 1)
return msg_len;
return ret;
......@@ -720,15 +720,15 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
send:
/* Error condition pass through to the base socket. */
ret = nice_socket_send_messages (priv->base_socket, message, 1);
ret = nice_socket_send_messages (priv->base_socket, to, message, 1);
if (ret == 1)
return message->length;
return ret;
}
static gint
socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages)
socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages)
{
guint i;
......@@ -736,7 +736,7 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
const NiceOutputMessage *message = &messages[i];
gssize len;
len = socket_send_message (sock, message);
len = socket_send_message (sock, to, message);
if (len < 0) {
/* Error. */
......
......@@ -59,7 +59,7 @@
static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock,
static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock);
......@@ -225,33 +225,32 @@ socket_recv_messages (NiceSocket *sock,
}
static gssize
socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
socket_send_message (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *message)
{
struct UdpBsdSocketPrivate *priv = sock->priv;
GError *child_error = NULL;
gssize len;
if (!nice_address_is_valid (&priv->niceaddr) ||
!nice_address_equal (&priv->niceaddr, message->to)) {
!nice_address_equal (&priv->niceaddr, to)) {
union {
struct sockaddr_storage storage;
struct sockaddr addr;
} sa;
GSocketAddress *gaddr;
g_assert (message->to != NULL);
if (priv->gaddr)
g_object_unref (priv->gaddr);
nice_address_copy_to_sockaddr (message->to, &sa.addr);
nice_address_copy_to_sockaddr (to, &sa.addr);
gaddr = g_socket_address_new_from_native (&sa.addr, sizeof(sa));
priv->gaddr = gaddr;
if (gaddr == NULL)
return -1;
priv->niceaddr = *message->to;
priv->niceaddr = *to;
}
len = g_socket_send_message (sock->fileno, priv->gaddr, message->buffers,
......@@ -268,8 +267,8 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
}
static gint
socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
guint n_messages)
socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages)
{
guint i;
......@@ -277,7 +276,7 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
const NiceOutputMessage *message = &messages[i];
gssize len;
len = socket_send_message (sock, message);
len = socket_send_message (sock, to, message);
if (len < 0) {
/* Error. */
......
......@@ -144,9 +144,9 @@ test_zero_send_recv (void)
g_assert_cmpint (socket_recv (sock, &tmp, 0, NULL), ==, 0);
/* And again with messages. */
g_assert_cmpint (nice_socket_send_messages (sock,
g_assert_cmpint (nice_socket_send_messages (sock, &tmp,
&local_out_message, 0), ==, 0);
g_assert_cmpint (nice_socket_send_messages (sock, NULL, 0), ==, 0);
g_assert_cmpint (nice_socket_send_messages (sock, &tmp, NULL, 0), ==, 0);
g_assert_cmpint (nice_socket_recv_messages (sock,
&local_in_message, 0), ==, 0);
......@@ -273,7 +273,6 @@ test_multi_message_recv (guint n_sends, guint n_receives,
send_messages[i].buffers = send_bufs + i * n_bufs_per_message;
send_messages[i].n_buffers = n_bufs_per_message;
send_messages[i].to = &tmp;
send_messages[i].length = 0;
}
......@@ -301,7 +300,7 @@ test_multi_message_recv (guint n_sends, guint n_receives,
/* Send multiple packets. */
g_assert_cmpint (
nice_socket_send_messages (client, send_messages, n_sends), ==,
nice_socket_send_messages (client, &tmp, send_messages, n_sends), ==,
expected_n_sent_messages);
/* Receive things. */
......
......@@ -554,7 +554,6 @@ generate_messages_to_transmit (TestIOStreamThreadData *data,
generate_buffer_count (test_data->transmit.buffer_count_strategy,
test_data->transmit_size_rand, buffer_offset);
message->buffers = g_malloc_n (message->n_buffers, sizeof (GOutputVector));
message->to = NULL;
message->length = 0;
/* Limit the overall message size to the smaller of (n_bytes / n_messages)
......
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