Commit eaeed326 authored by Pekka Pessi's avatar Pekka Pessi

Added TPTAG_FRESH() and a test for it.

darcs-hash:20051230122555-65a35-d0fb6fac94046ef2eb177acd74139828df2e66a1.gz
parent 0bbeb5a4
......@@ -31,7 +31,6 @@
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
*
* @date Created: Wed Apr 3 11:25:13 2002 ppessi
* @date Last modified: Tue Nov 8 12:14:17 2005 ppessi
*/
#include "config.h"
......@@ -898,9 +897,29 @@ static int reuse_test(tp_test_t *tt)
TEST(tport_test_run(tt, 5), 1);
msg_destroy(tt->tt_rmsg), tt->tt_rmsg = NULL;
TEST_1(tp = tport_by_name(tt->tt_tports, tpn));
TEST_1(tport_is_primary(tp));
TEST(tport_set_params(tp, TPTAG_REUSE(1), TAG_END()), 1);
/* Send a single message with different connection */
TEST_1(!new_test_msg(tt, &msg, "fresh-1", 1, 1024));
TEST_1(tp = tport_tsend(tt->tt_tports, msg, tt->tt_tcp_name,
TPTAG_FRESH(1),
TPTAG_REUSE(1),
TAG_END()));
TEST_S(tport_name(tp)->tpn_ident, "client");
TEST_1(tport_incref(tp) != tp1); tport_decref(&tp);
msg_destroy(msg);
TEST(tport_test_run(tt, 5), 1);
TEST_1(!check_msg(tt, tt->tt_rmsg, "fresh-1"));
msg_destroy(tt->tt_rmsg), tt->tt_rmsg = NULL;
TEST_1(tport_shutdown(tp0, 2) >= 0);
TEST_1(tport_shutdown(tp1, 2) >= 0);
TEST_1(tport_shutdown(tp0, 1) >= 0);
TEST(tport_shutdown(NULL, 0), -1);
tport_decref(&tp0);
......
......@@ -3985,7 +3985,7 @@ tport_t *tport_tsend(tport_t *self,
{
ta_list ta;
tagi_t const *t;
int reuse, sdwn_after, close_after, resolved = 0;
int reuse, sdwn_after, close_after, resolved = 0, fresh;
unsigned mtu;
su_addrinfo_t *ai;
tport_primary_t *primary;
......@@ -4017,6 +4017,7 @@ tport_t *tport_tsend(tport_t *self,
ta_start(ta, tag, value);
reuse = primary->pri_primary->tp_reusable && self->tp_reusable;
fresh = 0;
sdwn_after = 0;
close_after = 0;
mtu = 0;
......@@ -4034,12 +4035,16 @@ tport_t *tport_tsend(tport_t *self,
sdwn_after = t->t_value != 0;
else if (tptag_close_after == tt)
close_after = t->t_value != 0;
else if (tptag_fresh == tt)
fresh = t->t_value != 0;
else if (tptag_compartment == tt)
cc = (struct sigcomp_compartment *)t->t_value;
}
ta_end(ta);
fresh = fresh || !reuse;
ai = msg_addrinfo(msg);
ai->ai_flags = 0;
......@@ -4059,7 +4064,11 @@ tport_t *tport_tsend(tport_t *self,
if (close_after)
ai->ai_flags |= TP_AI_CLOSE;
if (reuse) {
if (fresh) {
/* Select a primary protocol, make a fresh connection */
self = primary->pri_primary;
}
else {
if (tport_is_secondary(self) &&
tport_is_registered(self) &&
self->tp_reusable &&
......@@ -4084,9 +4093,6 @@ tport_t *tport_tsend(tport_t *self,
self = primary->pri_primary;
}
}
else {
self = primary->pri_primary; /* Use a primary protocol */
}
if (tport_is_primary(self)) {
/* If primary, resolve the destination address, store it in the msg */
......
......@@ -30,7 +30,6 @@
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
*
* @date Created: Thu Jun 29 15:58:06 2000 ppessi
* @date Last modified: Fri Sep 9 10:56:41 2005 ppessi
*/
#ifndef SU_H
......
......@@ -33,7 +33,6 @@
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
*
* @date Created: Thu Jun 6 00:38:07 2002 ppessi
* @date Last modified: Wed Jul 20 20:36:01 2005 kaiv
*/
#include "config.h"
......@@ -77,6 +76,7 @@ tagi_t tport_tags[] =
tag_typedef_t tptag_ident = CSTRTAG_TYPEDEF(ident);
tag_typedef_t tptag_reuse = BOOLTAG_TYPEDEF(reuse);
tag_typedef_t tptag_fresh = BOOLTAG_TYPEDEF(fresh);
tag_typedef_t tptag_server = BOOLTAG_TYPEDEF(server);
tag_typedef_t tptag_mtu = UINTTAG_TYPEDEF(mtu);
tag_typedef_t tptag_connect = BOOLTAG_TYPEDEF(connect);
......
......@@ -31,7 +31,6 @@
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
*
* @date Created: Sat Oct 12 18:39:48 2002 ppessi
* @date Last modified: Wed Jul 20 20:36:01 2005 kaiv
*/
#ifndef TPORT_DLL
......@@ -57,12 +56,19 @@ TPORT_DLL extern tag_typedef_t tptag_ident_ref;
#define TPTAG_IDENT_REF(x) tptag_ident_ref, tag_str_vr(&(x))
TPORT_DLL extern tag_typedef_t tptag_reuse;
/** Reuse transport connection (true by default). */
/** Allow reusing transport connection (true by default). */
#define TPTAG_REUSE(x) tptag_reuse, tag_bool_v((x))
TPORT_DLL extern tag_typedef_t tptag_reuse_ref;
#define TPTAG_REUSE_REF(x) tptag_reuse_ref, tag_bool_vr(&(x))
TPORT_DLL extern tag_typedef_t tptag_fresh;
/** Create new connection (but allow reusing new one). */
#define TPTAG_FRESH(x) tptag_fresh, tag_bool_v((x))
TPORT_DLL extern tag_typedef_t tptag_fresh_ref;
#define TPTAG_FRESH_REF(x) tptag_fresh_ref, tag_bool_vr(&(x))
TPORT_DLL extern tag_typedef_t tptag_server;
/** Bind server sockets (true by default, disable with TPTAG_SERVER(0)). */
#define TPTAG_SERVER(x) tptag_server, tag_bool_v((x))
......
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