Mercurial > hg > freeDiameter
annotate freeDiameter/p_sr.c @ 74:9dcb1bd11a07
Some cleanups
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Tue, 01 Dec 2009 14:14:34 +0900 |
parents | 02db4d794ccf |
children | 4679ff581d6a |
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) * |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> * |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 * * |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
5 * Copyright (c) 2009, WIDE Project and NICT * |
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 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 #include "fD.h" |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 |
74 | 38 #ifndef SR_DEBUG_LVL |
39 #define SR_DEBUG_LVL ANNOYING | |
40 #endif /* SR_DEBUG_LVL */ | |
41 | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
42 /* Structure to store a sent request */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
43 struct sentreq { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
44 struct fd_list chain; /* the "o" field points directly to the hop-by-hop of the request (uint32_t *) */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
45 struct msg *req; /* A request that was sent and not yet answered. */ |
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 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
48 /* Find an element in the list, or the following one */ |
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 |
71
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
64 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
|
65 { |
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
66 struct fd_list * li; |
74 | 67 if (!TRACE_BOOL(SR_DEBUG_LVL)) |
73 | 68 return; |
71
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
69 fd_log_debug("%sSentReq list @%p:\n", text, srlist); |
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
70 for (li = srlist->next; li != srlist; li = li->next) { |
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
71 struct sentreq * sr = (struct sentreq *)li; |
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
72 uint32_t * nexthbh = li->o; |
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
73 fd_log_debug(" - Next req (%x):\n", *nexthbh); |
74 | 74 fd_msg_dump_one(SR_DEBUG_LVL + 1, sr->req); |
71
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
75 } |
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
76 } |
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
77 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
78 /* Store a new sent request */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
79 int fd_p_sr_store(struct sr_list * srlist, struct msg **req, uint32_t *hbhloc) |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
80 { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
81 struct sentreq * sr; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
82 struct fd_list * next; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
83 int match; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
84 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
85 TRACE_ENTRY("%p %p %p", srlist, req, hbhloc); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
86 CHECK_PARAMS(srlist && req && *req && hbhloc); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
87 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
88 CHECK_MALLOC( sr = malloc(sizeof(struct sentreq)) ); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
89 memset(sr, 0, sizeof(struct sentreq)); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
90 fd_list_init(&sr->chain, hbhloc); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
91 sr->req = *req; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
92 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
93 /* Search the place in the list */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
94 CHECK_POSIX( pthread_mutex_lock(&srlist->mtx) ); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
95 next = find_or_next(&srlist->srs, *hbhloc, &match); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
96 if (match) { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
97 TRACE_DEBUG(INFO, "A request with the same hop-by-hop Id was already sent: error"); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
98 free(sr); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
99 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
|
100 return EINVAL; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
101 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
102 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
103 /* Save in the list */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
104 *req = NULL; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
105 fd_list_insert_before(next, &sr->chain); |
71
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
106 srl_dump("Saved new request, ", &srlist->srs); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
107 CHECK_POSIX( pthread_mutex_unlock(&srlist->mtx) ); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
108 return 0; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
109 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
110 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
111 /* Fetch a request by hbh */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
112 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
|
113 { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
114 struct sentreq * sr; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
115 int match; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
116 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
117 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
|
118 CHECK_PARAMS(srlist && req); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
119 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
120 /* Search the request in the list */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
121 CHECK_POSIX( pthread_mutex_lock(&srlist->mtx) ); |
71
cba30013d8f5
Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
122 srl_dump("Fetching a request, ", &srlist->srs); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
123 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
|
124 if (!match) { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
125 TRACE_DEBUG(INFO, "There is no saved request with this hop-by-hop id"); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
126 *req = NULL; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
127 } else { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
128 /* Unlink */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
129 fd_list_unlink(&sr->chain); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
130 *req = sr->req; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
131 free(sr); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
132 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
133 CHECK_POSIX( pthread_mutex_unlock(&srlist->mtx) ); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
134 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
135 /* Done */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
136 return 0; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
137 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
138 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
139 /* Failover requests (free or requeue routables) */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
140 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
|
141 { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
142 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
|
143 while (!FD_IS_LIST_EMPTY(&srlist->srs)) { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
144 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
|
145 fd_list_unlink(&sr->chain); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
146 if (fd_msg_is_routable(sr->req)) { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
147 struct msg_hdr * hdr = NULL; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
148 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
149 /* Set the 'T' flag */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
150 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
|
151 if (hdr) |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
152 hdr->msg_flags |= CMD_FLAG_RETRANSMIT; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
153 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
154 /* Requeue for sending to another peer */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
155 CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &sr->req), |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
156 CHECK_FCT_DO(fd_msg_free(sr->req), /* What can we do more? */)); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
157 } else { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
158 /* Just free the request... */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
159 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
|
160 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
161 free(sr); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
162 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
163 CHECK_POSIX_DO( pthread_mutex_unlock(&srlist->mtx), /* continue anyway */ ); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
164 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
165 |