[telepathy-sofiasip/master] Don't delay the final 200 response to incoming messages
Mikhail Zabaluev
mikhail.zabaluev at nokia.com
Fri Aug 21 03:07:02 PDT 2009
Delaying the final response until client acknowledgement is harmful,
because the sender would still retransmit the MESSAGE request every
4 seconds by default, and times out the transaction after 32 seconds.
---
src/sip-text-channel.c | 22 ----------------------
src/sip-text-channel.h | 1 -
src/text-factory.c | 15 +++++++--------
3 files changed, 7 insertions(+), 31 deletions(-)
diff --git a/src/sip-text-channel.c b/src/sip-text-channel.c
index ef330f2..b926596 100644
--- a/src/sip-text-channel.c
+++ b/src/sip-text-channel.c
@@ -108,7 +108,6 @@ struct _TpsipTextPendingMessage
gchar *text;
nua_handle_t *nh;
- nua_saved_event_t saved_event[1];
};
typedef struct _TpsipTextChannelPrivate TpsipTextChannelPrivate;
@@ -144,24 +143,12 @@ static void tpsip_text_pending_free (TpsipTextPendingMessage *msg,
g_free (msg->text);
- if (msg->saved_event[0])
- nua_destroy_event (msg->saved_event);
-
if (msg->nh)
nua_handle_unref (msg->nh);
g_slice_free (TpsipTextPendingMessage, msg);
}
-static inline void
-tpsip_text_pending_respond (TpsipTextPendingMessage *msg)
-{
- nua_respond (msg->nh,
- SIP_200_OK,
- NUTAG_WITH_SAVED(msg->saved_event),
- TAG_END());
-}
-
static void
tpsip_text_channel_init (TpsipTextChannel *obj)
{
@@ -578,8 +565,6 @@ tpsip_text_channel_acknowledge_pending_messages(TpSvcChannelTypeText *iface,
g_queue_remove (priv->pending_messages, msg);
- tpsip_text_pending_respond (msg);
-
tpsip_text_pending_free (msg, contact_repo);
}
@@ -797,7 +782,6 @@ tpsip_text_channel_list_pending_messages(TpSvcChannelTypeText *iface,
{
TpsipTextPendingMessage * msg = (TpsipTextPendingMessage *) cur->data;
tpsip_pending_message_list_add (messages, msg);
- tpsip_text_pending_respond (msg);
tpsip_text_pending_free (msg, contact_repo);
}
}
@@ -972,7 +956,6 @@ tpsip_text_channel_nua_r_message_cb (TpsipTextChannel *self,
void tpsip_text_channel_receive(TpsipTextChannel *chan,
nua_t *nua,
- nua_handle_t *nh,
TpHandle sender,
const char *text,
gsize len)
@@ -985,17 +968,12 @@ void tpsip_text_channel_receive(TpsipTextChannel *chan,
msg->id = priv->recv_id++;
msg->timestamp = time(NULL);
- msg->nh = nh;
msg->sender = sender;
msg->type = TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL;
msg->text = g_strndup (text, len);
- nua_save_event (nua, msg->saved_event);
-
g_queue_push_tail(priv->pending_messages, msg);
- nua_handle_ref (nh);
-
contact_repo = tp_base_connection_get_handles (
(TpBaseConnection *)(priv->conn), TP_HANDLE_TYPE_CONTACT);
diff --git a/src/sip-text-channel.h b/src/sip-text-channel.h
index 323e71e..d8c17cb 100644
--- a/src/sip-text-channel.h
+++ b/src/sip-text-channel.h
@@ -60,7 +60,6 @@ GType tpsip_text_channel_get_type(void);
void tpsip_text_channel_receive (TpsipTextChannel *obj,
nua_t *nua,
- nua_handle_t *nh,
TpHandle sender,
const char *text,
gsize len);
diff --git a/src/text-factory.c b/src/text-factory.c
index 1350d40..874b573 100644
--- a/src/text-factory.c
+++ b/src/text-factory.c
@@ -569,6 +569,12 @@ tpsip_nua_i_message_cb (TpBaseConnection *conn,
goto end;
}
+ /* Send the final response immediately as recommended by RFC 3428 */
+ nua_respond (ev->nua_handle,
+ SIP_200_OK,
+ NUTAG_WITH_THIS(ev->nua),
+ TAG_END());
+
DEBUG("Got incoming message from <%s>",
tp_handle_inspect (contact_repo, handle));
@@ -578,15 +584,8 @@ tpsip_nua_i_message_cb (TpBaseConnection *conn,
channel = tpsip_text_factory_new_channel (fac,
handle, handle, NULL);
- /* Return a provisional response to quench retransmissions.
- * The acknowledgement will be signalled later with 200 OK */
- nua_respond (ev->nua_handle,
- SIP_182_QUEUED,
- NUTAG_WITH_THIS(ev->nua),
- TAG_END());
-
tpsip_text_channel_receive (channel,
- ev->nua, ev->nua_handle, handle, text, len);
+ ev->nua, handle, text, len);
tp_handle_unref (contact_repo, handle);
--
1.5.6.5
More information about the telepathy-commits
mailing list