annotate extensions/rt_busypeers/rtbusy.c @ 1283:f09f16f432e6

Updated copyright information
author Sebastien Decugis <sdecugis@freediameter.net>
date Fri, 02 Jan 2015 20:37:31 +0100
parents ab6457399be2
children 38e4a7c318ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1020
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
1 /*********************************************************************************************************
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
4 * *
1283
f09f16f432e6 Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
5 * Copyright (c) 2015, WIDE Project and NICT *
1020
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
6 * All rights reserved. *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
7 * *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
10 * *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
13 * following disclaimer. *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
14 * *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
18 * materials provided with the distribution. *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
19 * *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
22 * promote products derived from this software without *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
24 * NICT. *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
25 * *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
34 *********************************************************************************************************/
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
35
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
36 /* See doc/rt_busypeers.conf.sample for more details about the features of this extension */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
37 #include "rtbusy.h"
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
38
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
39 /* The configuration structure */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
40 struct rtbusy_conf rtbusy_conf;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
41
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
42 static struct fd_rt_fwd_hdl * rt_busy_hdl = NULL;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
43
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
44 static void rtbusy_expirecb(void * data, DiamId_t sentto, size_t senttolen, struct msg ** req);
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
45
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
46 /* The function that does the actual work */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
47 int rt_busy_process_busy(struct msg ** pmsg, int is_req, DiamId_t sentto, size_t senttolen, union avp_value *oh)
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
48 {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
49 struct msg * qry = NULL;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
50 struct rt_data * rtd = NULL;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
51 struct fd_list * candidates = NULL;
1279
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
52 int sendingattempts;
1020
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
53 int resend = 1;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
54
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
55
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
56 TRACE_ENTRY("%p(%p) %d %p %p", pmsg, pmsg?*pmsg:NULL, is_req, sentto, oh);
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
57
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
58 if (is_req) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
59 qry = *pmsg;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
60 } else {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
61 CHECK_FCT( fd_msg_answ_getq( *pmsg, &qry ) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
62 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
63
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
64 CHECK_FCT( fd_msg_rt_get ( qry, &rtd ) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
65 ASSERT(rtd);
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
66
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
67 /* rtd is the routing data associated with the query that was sent */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
68
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
69 /* Store the error in this routing data, this avoids sending the message to the same peer again */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
70 CHECK_FCT( fd_rtd_error_add(rtd,
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
71 sentto, senttolen,
1047
a130b6a13abb Fix some compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1020
diff changeset
72 (uint8_t *)(oh ? (DiamId_t)oh->os.data : fd_g_config->cnf_diamid), oh ? oh->os.len : fd_g_config->cnf_diamid_len ,
1020
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
73 ER_DIAMETER_TOO_BUSY,
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
74 &candidates,
1279
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
75 &sendingattempts) );
1020
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
76
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
77 /* Now we need to decide if we re-send this query to a different peer or return an error to upstream */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
78
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
79 /* First, are we exceeding the allowed attempts? */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
80 if (rtbusy_conf.RetryMaxPeers != 0) {
1279
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
81 if (sendingattempts >= rtbusy_conf.RetryMaxPeers) {
1020
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
82 TRACE_DEBUG(FULL, "Maximum number of sending attempts reached for message %p, returning an error upstream", qry);
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
83 resend = 0;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
84 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
85 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
86
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
87 if (resend) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
88 /* Check if we have any valid candidate left for sending the message. This may not be 100% accurate but there should not be
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
89 any situation where this is actually an issue. */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
90 if (FD_IS_LIST_EMPTY(candidates)) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
91 resend = 0;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
92 } else {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
93 struct rtd_candidate * first = candidates->next->o;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
94 if (first->score < 0) /* No more candidate available */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
95 resend = 0;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
96 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
97 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
98
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
99 /* Ok, now act on the message, we know what to do */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
100 if (resend) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
101 if (!is_req) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
102 /* We must free the answer we received, and send the query again */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
103 CHECK_FCT( fd_msg_answ_detach(*pmsg) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
104 CHECK_FCT( fd_msg_free(*pmsg) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
105 *pmsg = qry;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
106 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
107 /* Send the query again. We need to re-associate the expirecb which was cleaned, if it is used */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
108 if (rtbusy_conf.RelayTimeout) {
1279
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
109 char *buf = NULL;
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
110 size_t len;
1115
a325f95de659 Set absolute timeout in second place.
Thomas Klausner <tk@giga.or.at>
parents: 1109
diff changeset
111 struct timespec expire;
a325f95de659 Set absolute timeout in second place.
Thomas Klausner <tk@giga.or.at>
parents: 1109
diff changeset
112 CHECK_SYS( clock_gettime(CLOCK_REALTIME, &expire) );
a325f95de659 Set absolute timeout in second place.
Thomas Klausner <tk@giga.or.at>
parents: 1109
diff changeset
113 expire.tv_sec += rtbusy_conf.RelayTimeout/1000 + ((expire.tv_nsec + (1000000LL * (rtbusy_conf.RelayTimeout % 1000))) / 1000000000LL);
a325f95de659 Set absolute timeout in second place.
Thomas Klausner <tk@giga.or.at>
parents: 1109
diff changeset
114 expire.tv_nsec = (expire.tv_nsec + (1000000LL * (rtbusy_conf.RelayTimeout % 1000))) % 1000000000LL;
1279
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
115 CHECK_MALLOC_DO( fd_msg_dump_full(&buf, &len, NULL, *pmsg, fd_g_config->cnf_dict, 0, 1), /* nothing */);
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
116 TRACE_ERROR( "No answer received for message from peer '%.*s' before timeout (%dms), re-sending: %s", senttolen, sentto,
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
117 rtbusy_conf.RelayTimeout, buf);
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
118 free(buf);
1115
a325f95de659 Set absolute timeout in second place.
Thomas Klausner <tk@giga.or.at>
parents: 1109
diff changeset
119 CHECK_FCT( fd_msg_send_timeout( pmsg, NULL, NULL, rtbusy_expirecb, &expire ) );
1020
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
120 } else {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
121 CHECK_FCT( fd_msg_send(pmsg, NULL, NULL) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
122 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
123
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
124 } else {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
125 if (is_req) {
1279
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
126 char *buf = NULL;
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
127 size_t len;
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
128
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
129 CHECK_MALLOC_DO( fd_msg_dump_full(&buf, &len, NULL, *pmsg, fd_g_config->cnf_dict, 0, 1), /* nothing */);
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
130 TRACE_ERROR( "No answer received for message from peer '%.*s' before timeout (%dms), giving up and sending error reply: %s", senttolen, sentto,
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
131 rtbusy_conf.RelayTimeout, buf);
a1685a53fe97 When requests fall into timeout, log them, the timeout, and the slow peer.
Thomas Klausner <tk@giga.or.at>
parents: 1127
diff changeset
132 free(buf);
1020
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
133 /* We must create an answer */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
134 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, pmsg, MSGFL_ANSW_ERROR ) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
135
1108
7ee7b95701c9 Change the rt_busy parameter to milliseconds
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
136 CHECK_FCT( fd_msg_rescode_set(*pmsg, "DIAMETER_TOO_BUSY", "[rt_busypeers] Timeout reached while waiting for an answer", NULL, 1 ) );
1020
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
137
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
138 CHECK_FCT( fd_msg_send(pmsg, NULL, NULL) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
139 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
140 /* Otherwise, we have nothing to do at all, the answer will be forwarded upstream as part of the normal processing */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
141
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
142 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
143
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
144 return 0;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
145 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
146
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
147 /* Callback called on expiry of the timeout timer */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
148 static void rtbusy_expirecb(void * data, DiamId_t sentto, size_t senttolen, struct msg ** preq)
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
149 {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
150 CHECK_FCT_DO( rt_busy_process_busy(preq, 1, sentto, senttolen, NULL), /* continue */ );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
151 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
152
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
153 /* the routing callback that handles all the tasks of this extension */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
154 static int rtbusy_fwd_cb(void * cbdata, struct msg ** pmsg)
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
155 {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
156 struct msg_hdr * hdr;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
157 struct avp * avp;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
158 union avp_value *a_rc = NULL, *a_oh = NULL;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
159 DiamId_t sentto = NULL;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
160 size_t senttolen;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
161
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
162 /* Get the header of the message */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
163 CHECK_FCT( fd_msg_hdr(*pmsg, &hdr) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
164
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
165 /* If the message is a request, we only associate the timeout */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
166 if (hdr->msg_flags & CMD_FLAG_REQUEST) {
1109
4f33090b96bf Fix handling of the timeout value
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1108
diff changeset
167 struct timespec expire;
4f33090b96bf Fix handling of the timeout value
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1108
diff changeset
168 CHECK_SYS( clock_gettime(CLOCK_REALTIME, &expire) );
4f33090b96bf Fix handling of the timeout value
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1108
diff changeset
169 expire.tv_sec += rtbusy_conf.RelayTimeout/1000 + ((expire.tv_nsec + (1000000LL * (rtbusy_conf.RelayTimeout % 1000))) / 1000000000LL);
4f33090b96bf Fix handling of the timeout value
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1108
diff changeset
170 expire.tv_nsec = (expire.tv_nsec + (1000000LL * (rtbusy_conf.RelayTimeout % 1000))) % 1000000000LL;
4f33090b96bf Fix handling of the timeout value
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1108
diff changeset
171 CHECK_FCT( fd_msg_anscb_associate( *pmsg, NULL, NULL, rtbusy_expirecb, &expire ) );
1020
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
172 return 0;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
173 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
174
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
175 /* From this point, the message is an answer; we need to check if the E flag is set and if the Result-Code is DIAMETER_TOO_BUSY */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
176
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
177 if (!(hdr->msg_flags & CMD_FLAG_ERROR)) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
178 /* This answer does not have the E flag, no need to process further */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
179 return 0;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
180 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
181
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
182 CHECK_FCT( fd_msg_source_get( *pmsg, &sentto, &senttolen ) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
183
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
184 /* Now get the AVPs we are interested in */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
185 CHECK_FCT( fd_msg_browse(*pmsg, MSG_BRW_FIRST_CHILD, &avp, NULL) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
186 while (avp) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
187 struct avp_hdr * ahdr;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
188
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
189 CHECK_FCT( fd_msg_avp_hdr( avp, &ahdr ) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
190 if (! (ahdr->avp_flags & AVP_FLAG_VENDOR)) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
191 switch (ahdr->avp_code) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
192 case AC_ORIGIN_HOST:
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
193 /* Parse this AVP */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
194 CHECK_FCT( fd_msg_parse_dict ( avp, fd_g_config->cnf_dict, NULL ) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
195 ASSERT( ahdr->avp_value );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
196 a_oh = ahdr->avp_value;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
197 break;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
198
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
199 case AC_RESULT_CODE:
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
200 /* Parse this AVP */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
201 CHECK_FCT( fd_msg_parse_dict ( avp, fd_g_config->cnf_dict, NULL ) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
202 ASSERT( ahdr->avp_value );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
203 a_rc = ahdr->avp_value;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
204
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
205 if (a_rc->u32 != ER_DIAMETER_TOO_BUSY) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
206 /* It is not a TOO_BUSY error, we don't do anything */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
207 goto out;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
208 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
209 break;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
210 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
211
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
212 if (a_rc && a_oh)
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
213 break;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
214 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
215
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
216 /* Go to next AVP */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
217 CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
218 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
219
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
220 /* Check we have received the necessary information */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
221 if (!a_rc) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
222 TRACE_ERROR( "Invalid Diameter answer without a Result-Code AVP, rt_busypeer module gave up processing");
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
223 goto out;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
224 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
225
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
226 if (!a_oh) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
227 TRACE_ERROR( "Invalid Diameter answer without an Origin-Host AVP, rt_busypeer module gave up processing");
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
228 goto out;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
229 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
230
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
231 /* Pass this error to the function that processes BUSY status */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
232 CHECK_FCT( rt_busy_process_busy(pmsg, 0, sentto, senttolen, a_oh) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
233
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
234 out:
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
235 return 0;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
236 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
237
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
238
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
239 /* entry point */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
240 static int rtbusy_entry(char * conffile)
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
241 {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
242 enum fd_rt_fwd_dir dir = RT_FWD_ANS;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
243 TRACE_ENTRY("%p", conffile);
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
244
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
245 /* Initialize the configuration */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
246 memset(&rtbusy_conf, 0, sizeof(rtbusy_conf));
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
247
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
248 /* Parse the configuration file */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
249 CHECK_FCT( rtbusy_conf_handle(conffile) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
250
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
251 if (rtbusy_conf.SkipTooBusyErrors && !rtbusy_conf.RelayTimeout) {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
252 TRACE_NOTICE("[rt_busypeers] Configuration file does not specify any behavior (no effect)!");
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
253 return 0;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
254 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
255
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
256 if (rtbusy_conf.SkipTooBusyErrors)
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
257 dir = RT_FWD_REQ; /* in this case, RelayTimeout is not 0 */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
258 else if (rtbusy_conf.RelayTimeout)
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
259 dir = RT_FWD_ALL;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
260
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
261 /* Register the callback */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
262 CHECK_FCT( fd_rt_fwd_register ( rtbusy_fwd_cb, NULL, dir, &rt_busy_hdl ) );
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
263
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
264 /* We're done */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
265 return 0;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
266 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
267
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
268 /* Unload */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
269 void fd_ext_fini(void)
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
270 {
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
271 TRACE_ENTRY();
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
272
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
273 /* Unregister the cb */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
274 if (rt_busy_hdl)
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
275 CHECK_FCT_DO( fd_rt_fwd_unregister ( rt_busy_hdl, NULL), /* continue */);
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
276
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
277 /* Done */
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
278 return ;
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
279 }
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
280
8110a781116a New extension rt_busypeers. See doc/rt_busypeers.conf.sample for more information. This code is not tested yet
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
281 EXTENSION_ENTRY("rt_busypeers", rtbusy_entry);
"Welcome to our mercurial repository"