annotate libfdcore/p_sr.c @ 1239:b059b9e8ef83

Update the sent request counter in case of expiry
author Sebastien Decugis <sdecugis@freediameter.net>
date Thu, 10 Oct 2013 16:19:23 +0200
parents 8f9684264fe0
children 0420ccc4671a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
740
4a9f08d6b6ba Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 706
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
1127
1af09cc156d6 Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1119
diff changeset
5 * Copyright (c) 2013, WIDE Project and NICT *
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 650
diff changeset
36 #include "fdcore-internal.h"
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38 /* Structure to store a sent request */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
39 struct sentreq {
1207
043b894b0511 Cleanups in failover situation to avoid deadlocks and corrupt messages ids. Tested OK now.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1188
diff changeset
40 struct fd_list chain; /* the "o" field points directly to the (new) hop-by-hop of the request (uint32_t *) */
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
41 struct msg *req; /* A request that was sent and not yet answered. */
1207
043b894b0511 Cleanups in failover situation to avoid deadlocks and corrupt messages ids. Tested OK now.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1188
diff changeset
42 uint32_t prevhbh;/* The value to set back in the hbh header when the message is retrieved */
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
43 struct fd_list expire; /* the list of expiring requests */
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
44 struct timespec timeout; /* Cache the expire date of the request so that the timeout thread does not need to get it each time. */
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
45 struct timespec added_on; /* the time the request was added */
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
46 };
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
47
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
48 /* Find an element in the hbh list, or the following one */
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
49 static struct fd_list * find_or_next(struct fd_list * srlist, uint32_t hbh, int * match)
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
50 {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
51 struct fd_list * li;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
52 *match = 0;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
53 for (li = srlist->next; li != srlist; li = li->next) {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
54 uint32_t * nexthbh = li->o;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
55 if (*nexthbh < hbh)
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
56 continue;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
57 if (*nexthbh == hbh)
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
58 *match = 1;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
59 break;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
60 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
61 return li;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
62 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
63
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
64 /* Similar but start from the end, since we add requests in growing hbh order usually */
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
65 static struct fd_list * find_or_prev(struct fd_list * srlist, uint32_t hbh, int * match)
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
66 {
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
67 struct fd_list * li;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
68 *match = 0;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
69 for (li = srlist->prev; li != srlist; li = li->prev) {
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
70 uint32_t * prevhbh = li->o;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
71 if (*prevhbh > hbh)
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
72 continue;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
73 if (*prevhbh == hbh)
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
74 *match = 1;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
75 break;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
76 }
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
77 return li;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
78 }
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
79
71
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
80 static void srl_dump(const char * text, struct fd_list * srlist)
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
81 {
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
82 struct fd_list * li;
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
83 struct timespec now;
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 691
diff changeset
84
1207
043b894b0511 Cleanups in failover situation to avoid deadlocks and corrupt messages ids. Tested OK now.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1188
diff changeset
85 LOG_D("%sSentReq list @%p:", text, srlist);
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 691
diff changeset
86
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
87 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), );
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 691
diff changeset
88
71
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
89 for (li = srlist->next; li != srlist; li = li->next) {
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
90 struct sentreq * sr = (struct sentreq *)li;
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
91 uint32_t * nexthbh = li->o;
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 691
diff changeset
92
1207
043b894b0511 Cleanups in failover situation to avoid deadlocks and corrupt messages ids. Tested OK now.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1188
diff changeset
93 LOG_D(" - Next req (hbh:0x%x, prev:0x%x): [since %ld.%06ld sec]", *nexthbh, sr->prevhbh,
1052
b3d623f04b6d Fix a number of remaining compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
94 (long)((now.tv_nsec >= sr->added_on.tv_nsec) ? (now.tv_sec - sr->added_on.tv_sec) : (now.tv_sec - sr->added_on.tv_sec - 1)),
b3d623f04b6d Fix a number of remaining compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
95 (long)((now.tv_nsec >= sr->added_on.tv_nsec) ? ((now.tv_nsec - sr->added_on.tv_nsec) / 1000) : ((now.tv_nsec - sr->added_on.tv_nsec + 1000000000) / 1000)));
71
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
96 }
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
97 }
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
98
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 691
diff changeset
99 /* thread that handles messages expiring. The thread is started only when needed */
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
100 static void * sr_expiry_th(void * arg) {
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
101 struct sr_list * srlist = arg;
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
102
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
103 TRACE_ENTRY("%p", arg);
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
104 CHECK_PARAMS_DO( arg, return NULL );
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
105
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
106 /* Set the thread name */
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
107 {
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
108 char buf[48];
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 691
diff changeset
109 snprintf(buf, sizeof(buf), "ReqExp/%s", ((struct fd_peer *)(srlist->exp.o))->p_hdr.info.pi_diamid);
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
110 fd_log_threadname ( buf );
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
111 }
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
112
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
113 do {
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
114 struct timespec now;
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
115 struct sentreq * first;
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
116 struct msg * request;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
117 struct fd_peer * sentto;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
118 void (*expirecb)(void *, DiamId_t, size_t, struct msg **);
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
119 void (*anscb)(void *, struct msg **);
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
120 void * data;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
121 int no_error;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
122
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
123 CHECK_POSIX_DO( pthread_mutex_lock(&srlist->mtx), return NULL );
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
124 pthread_cleanup_push( fd_cleanup_mutex, &srlist->mtx );
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
125
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
126 loop:
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
127 no_error = 0;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
128
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
129 /* Check if there are expiring requests available */
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
130 if (FD_IS_LIST_EMPTY(&srlist->exp)) {
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
131 /* Just wait for a change or cancelation */
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
132 CHECK_POSIX_DO( pthread_cond_wait( &srlist->cnd, &srlist->mtx ), goto unlock );
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
133 /* Restart the loop on wakeup */
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
134 goto loop;
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
135 }
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
136
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
137 /* Get the pointer to the request that expires first */
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
138 first = (struct sentreq *)(srlist->exp.next->o);
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
139
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
140 /* Get the current time */
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
141 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), goto unlock );
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
142
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
143 /* If first request is not expired, we just wait until it happens */
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
144 if ( TS_IS_INFERIOR( &now, &first->timeout ) ) {
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
145
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
146 CHECK_POSIX_DO2( pthread_cond_timedwait( &srlist->cnd, &srlist->mtx, &first->timeout ),
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
147 ETIMEDOUT, /* ETIMEDOUT is a normal return value, continue */,
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
148 /* on other error, */ goto unlock );
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
149
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
150 /* on wakeup, loop */
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
151 goto loop;
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
152 }
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
153
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
154 /* Now, the first request in the list is expired; remove it and call the expirecb for it */
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
155 request = first->req;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
156 sentto = first->chain.head->o;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
157
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
158 TRACE_DEBUG(FULL, "Request %x was not answered by %s within the timer delay", *((uint32_t *)first->chain.o), sentto->p_hdr.info.pi_diamid);
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
159
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
160 /* Restore the hbhid */
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
161 *((uint32_t *)first->chain.o) = first->prevhbh;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
162
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
163 /* Free the sentreq information */
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
164 fd_list_unlink(&first->chain);
1239
b059b9e8ef83 Update the sent request counter in case of expiry
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1238
diff changeset
165 srlist->cnt--;
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
166 fd_list_unlink(&first->expire);
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
167 free(first);
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
168
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
169 no_error = 1;
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
170 unlock:
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
171 ; /* pthread_cleanup_pop sometimes expands as "} ..." and the label before this cause some compilers to complain... */
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
172 pthread_cleanup_pop( 1 ); /* unlock the mutex */
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
173 if (!no_error)
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
174 break;
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
175
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
176
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
177 /* Retrieve callback in the message */
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
178 CHECK_FCT_DO( fd_msg_anscb_get( request, &anscb, &expirecb, &data ), break);
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
179 ASSERT(expirecb);
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
180
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
181 /* Clean up this expirecb from the message */
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
182 CHECK_FCT_DO( fd_msg_anscb_associate( request, anscb, data, NULL, NULL ), break);
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
183
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
184 /* Call it */
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
185 (*expirecb)(data, sentto->p_hdr.info.pi_diamid, sentto->p_hdr.info.pi_diamidlen, &request);
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
186
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
187 /* If the callback did not dispose of the message, do it now */
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
188 if (request) {
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
189 fd_hook_call(HOOK_MESSAGE_DROPPED, request, NULL, "Expiration period completed without an answer, and the expiry callback did not dispose of the message.", fd_msg_pmdl_get(request));
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
190 CHECK_FCT_DO( fd_msg_free(request), /* ignore */ );
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
191 }
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
192
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
193 } while (1);
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
194
691
78b665400097 Cleanup all pthread_cleanup_push / pop pairs so that pop is always called after push, or ASSERT(0) is some grave errors
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
195 ASSERT(0); /* we have encountered a problem, maybe time to signal the framework to terminate? */
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
196 return NULL;
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
197 }
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
198
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
199
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
200 /* Store a new sent request */
165
4679ff581d6a Fix invalid restore of the hop-by-hop id on forwarded answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 74
diff changeset
201 int fd_p_sr_store(struct sr_list * srlist, struct msg **req, uint32_t *hbhloc, uint32_t hbh_restore)
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
202 {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
203 struct sentreq * sr;
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
204 struct fd_list * prev;
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
205 int match;
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
206 struct timespec * ts;
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
207
165
4679ff581d6a Fix invalid restore of the hop-by-hop id on forwarded answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 74
diff changeset
208 TRACE_ENTRY("%p %p %p %x", srlist, req, hbhloc, hbh_restore);
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
209 CHECK_PARAMS(srlist && req && *req && hbhloc);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
210
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
211 CHECK_MALLOC( sr = malloc(sizeof(struct sentreq)) );
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
212 memset(sr, 0, sizeof(struct sentreq));
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
213 fd_list_init(&sr->chain, hbhloc);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
214 sr->req = *req;
165
4679ff581d6a Fix invalid restore of the hop-by-hop id on forwarded answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 74
diff changeset
215 sr->prevhbh = hbh_restore;
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
216 fd_list_init(&sr->expire, sr);
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
217 CHECK_SYS( clock_gettime(CLOCK_REALTIME, &sr->added_on) );
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
218
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
219 /* Search the place in the list */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
220 CHECK_POSIX( pthread_mutex_lock(&srlist->mtx) );
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
221 prev = find_or_prev(&srlist->srs, *hbhloc, &match);
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
222 if (match) {
1207
043b894b0511 Cleanups in failover situation to avoid deadlocks and corrupt messages ids. Tested OK now.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1188
diff changeset
223 TRACE_DEBUG(INFO, "A request with the same hop-by-hop Id (0x%x) was already sent: error", *hbhloc);
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
224 free(sr);
1207
043b894b0511 Cleanups in failover situation to avoid deadlocks and corrupt messages ids. Tested OK now.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1188
diff changeset
225 srl_dump("Current list of SR: ", &srlist->srs);
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
226 CHECK_POSIX_DO( pthread_mutex_unlock(&srlist->mtx), /* ignore */ );
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
227 return EINVAL;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
228 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
229
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
230 /* Save in the list */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
231 *req = NULL;
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
232 fd_list_insert_after(prev, &sr->chain);
938
4158151cc694 Add counter for number of requests pending answers
Sebastien Decugis <sdecugis@freediameter.net>
parents: 837
diff changeset
233 srlist->cnt++;
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
234
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
235 /* In case of request with a timeout, also store in the timeout list */
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
236 ts = fd_msg_anscb_gettimeout( sr->req );
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
237 if (ts) {
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
238 struct fd_list * li;
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
239
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
240 memcpy(&sr->timeout, ts, sizeof(struct timespec));
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
241
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
242 /* browse srlist->exp from the end */
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
243 for (li = srlist->exp.prev; li != &srlist->exp; li = li->prev) {
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
244 struct sentreq * s = (struct sentreq *)(li->o);
1232
9e92fa478c23 Performance improvements for fd_p_sr_store based on Guangming proposal http://lists.freediameter.net/pipermail/dev/2013-July/000225.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1207
diff changeset
245 if (TS_IS_INFERIOR(&s->timeout, ts))
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
246 break;
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
247 }
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
248
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
249 fd_list_insert_after(li, &sr->expire);
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
250
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
251 /* if the thread does not exist yet, create it */
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
252 if (srlist->thr == (pthread_t)NULL) {
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
253 CHECK_POSIX_DO( pthread_create(&srlist->thr, NULL, sr_expiry_th, srlist), /* continue anyway */);
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
254 } else {
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
255 /* or, if added in first position, signal the condvar to update the sleep time of the thread */
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
256 if (li == &srlist->exp) {
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
257 CHECK_POSIX_DO( pthread_cond_signal(&srlist->cnd), /* continue anyway */);
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
258 }
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
259 }
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
260 }
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
261
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
262 CHECK_POSIX( pthread_mutex_unlock(&srlist->mtx) );
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
263 return 0;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
264 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
265
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
266 /* Fetch a request by hbh */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
267 int fd_p_sr_fetch(struct sr_list * srlist, uint32_t hbh, struct msg **req)
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
268 {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
269 struct sentreq * sr;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
270 int match;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
271
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
272 TRACE_ENTRY("%p %x %p", srlist, hbh, req);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
273 CHECK_PARAMS(srlist && req);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
274
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
275 /* Search the request in the list */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
276 CHECK_POSIX( pthread_mutex_lock(&srlist->mtx) );
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
277 sr = (struct sentreq *)find_or_next(&srlist->srs, hbh, &match);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
278 if (!match) {
165
4679ff581d6a Fix invalid restore of the hop-by-hop id on forwarded answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 74
diff changeset
279 TRACE_DEBUG(INFO, "There is no saved request with this hop-by-hop id (%x)", hbh);
1207
043b894b0511 Cleanups in failover situation to avoid deadlocks and corrupt messages ids. Tested OK now.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1188
diff changeset
280 srl_dump("Current list of SR: ", &srlist->srs);
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
281 *req = NULL;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
282 } else {
165
4679ff581d6a Fix invalid restore of the hop-by-hop id on forwarded answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 74
diff changeset
283 /* Restore hop-by-hop id */
4679ff581d6a Fix invalid restore of the hop-by-hop id on forwarded answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 74
diff changeset
284 *((uint32_t *)sr->chain.o) = sr->prevhbh;
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
285 /* Unlink */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
286 fd_list_unlink(&sr->chain);
938
4158151cc694 Add counter for number of requests pending answers
Sebastien Decugis <sdecugis@freediameter.net>
parents: 837
diff changeset
287 srlist->cnt--;
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
288 fd_list_unlink(&sr->expire);
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
289 *req = sr->req;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
290 free(sr);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
291 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
292 CHECK_POSIX( pthread_mutex_unlock(&srlist->mtx) );
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
293
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
294 /* do not stop the expire thread here, it might cause creating/destroying it very often otherwise */
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
295
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
296 /* Done */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
297 return 0;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
298 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
299
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
300 /* Failover requests (free or requeue routables) */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
301 void fd_p_sr_failover(struct sr_list * srlist)
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
302 {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
303 CHECK_POSIX_DO( pthread_mutex_lock(&srlist->mtx), /* continue anyway */ );
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
304 while (!FD_IS_LIST_EMPTY(&srlist->srs)) {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
305 struct sentreq * sr = (struct sentreq *)(srlist->srs.next);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
306 fd_list_unlink(&sr->chain);
938
4158151cc694 Add counter for number of requests pending answers
Sebastien Decugis <sdecugis@freediameter.net>
parents: 837
diff changeset
307 srlist->cnt--;
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
308 fd_list_unlink(&sr->expire);
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
309 if (fd_msg_is_routable(sr->req)) {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
310 struct msg_hdr * hdr = NULL;
688
8c3dc8584dab Prepared capability for messages logging to separate files / folders
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
311 int ret;
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
312
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
313 /* Set the 'T' flag */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
314 CHECK_FCT_DO(fd_msg_hdr(sr->req, &hdr), /* continue */);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
315 if (hdr)
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
316 hdr->msg_flags |= CMD_FLAG_RETRANSMIT;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
317
1153
7a7ec1ad0c44 Another missing restore of the hop-by-hop ID upon failover situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
318 /* Restore the original hop-by-hop id of the request */
7a7ec1ad0c44 Another missing restore of the hop-by-hop ID upon failover situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
319 *((uint32_t *)sr->chain.o) = sr->prevhbh;
7a7ec1ad0c44 Another missing restore of the hop-by-hop ID upon failover situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
320
1113
eb4ce68b6e5c Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1110
diff changeset
321 fd_hook_call(HOOK_MESSAGE_FAILOVER, sr->req, (struct fd_peer *)srlist->srs.o, NULL, fd_msg_pmdl_get(sr->req));
eb4ce68b6e5c Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1110
diff changeset
322
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
323 /* Requeue for sending to another peer */
1188
f40de74bd1c7 Don't block PSM during failover
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1153
diff changeset
324 CHECK_FCT_DO( ret = fd_fifo_post_noblock(fd_g_outgoing, (void *)&sr->req),
688
8c3dc8584dab Prepared capability for messages logging to separate files / folders
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
325 {
1113
eb4ce68b6e5c Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1110
diff changeset
326 char buf[256];
eb4ce68b6e5c Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1110
diff changeset
327 snprintf(buf, sizeof(buf), "Internal error: error while requeuing during failover: %s", strerror(ret));
eb4ce68b6e5c Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1110
diff changeset
328 fd_hook_call(HOOK_MESSAGE_DROPPED, sr->req, NULL, buf, fd_msg_pmdl_get(sr->req));
688
8c3dc8584dab Prepared capability for messages logging to separate files / folders
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
329 CHECK_FCT_DO(fd_msg_free(sr->req), /* What can we do more? */)
8c3dc8584dab Prepared capability for messages logging to separate files / folders
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
330 });
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
331 } else {
688
8c3dc8584dab Prepared capability for messages logging to separate files / folders
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
332 /* Just free the request. */
1113
eb4ce68b6e5c Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1110
diff changeset
333 /* fd_hook_call(HOOK_MESSAGE_DROPPED, sr->req, NULL, "Sent & unanswered local message discarded during failover.", fd_msg_pmdl_get(sr->req)); */
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
334 CHECK_FCT_DO(fd_msg_free(sr->req), /* Ignore */);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
335 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
336 free(sr);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
337 }
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
338 /* The list of expiring requests must be empty now */
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
339 ASSERT( FD_IS_LIST_EMPTY(&srlist->exp) );
1238
8f9684264fe0 Change management of the p_reqin_count counter to be updated only on routable messages. This should limit the errors in the counter value resulting from rejected or discarded link-local messages.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1232
diff changeset
340 ASSERT( srlist->cnt == 0 ); /* debug the counter management if needed */
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
341
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
342 CHECK_POSIX_DO( pthread_mutex_unlock(&srlist->mtx), /* continue anyway */ );
649
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
343
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
344 /* Terminate the expiry thread (must be done when the lock can be taken) */
5e5d8152c229 Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
345 CHECK_FCT_DO( fd_thr_term(&srlist->thr), /* ignore error */ );
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
346 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
347
"Welcome to our mercurial repository"