annotate freeDiameter/p_sr.c @ 258:5df55136361b

Updated copyright information
author Sebastien Decugis <sdecugis@nict.go.jp>
date Fri, 16 Apr 2010 17:04:15 +0900
parents 4679ff581d6a
children 5e5d8152c229
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) *
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 * *
258
5df55136361b Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 165
diff changeset
5 * Copyright (c) 2010, 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
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
9dcb1bd11a07 Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 73
diff changeset
38 #ifndef SR_DEBUG_LVL
9dcb1bd11a07 Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 73
diff changeset
39 #define SR_DEBUG_LVL ANNOYING
9dcb1bd11a07 Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 73
diff changeset
40 #endif /* SR_DEBUG_LVL */
9dcb1bd11a07 Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 73
diff changeset
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. */
165
4679ff581d6a Fix invalid restore of the hop-by-hop id on forwarded answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 74
diff changeset
46 uint32_t prevhbh;/* The value to set in the hbh header when the message is retrieved */
34
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
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
49 /* 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
50 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
51 {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
52 struct fd_list * li;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
53 *match = 0;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
54 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
55 uint32_t * nexthbh = li->o;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
56 if (*nexthbh < hbh)
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
57 continue;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
58 if (*nexthbh == hbh)
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
59 *match = 1;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
60 break;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
61 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
62 return li;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
63 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
64
71
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
65 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
66 {
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
67 struct fd_list * li;
74
9dcb1bd11a07 Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 73
diff changeset
68 if (!TRACE_BOOL(SR_DEBUG_LVL))
73
02db4d794ccf Lower trace level
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 71
diff changeset
69 return;
71
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
70 fd_log_debug("%sSentReq list @%p:\n", text, srlist);
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
71 for (li = srlist->next; li != srlist; li = li->next) {
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
72 struct sentreq * sr = (struct sentreq *)li;
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
73 uint32_t * nexthbh = li->o;
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
74 fd_log_debug(" - Next req (%x):\n", *nexthbh);
74
9dcb1bd11a07 Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 73
diff changeset
75 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
76 }
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
77 }
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
78
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
79 /* 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
80 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
81 {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
82 struct sentreq * sr;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
83 struct fd_list * next;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
84 int match;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
85
165
4679ff581d6a Fix invalid restore of the hop-by-hop id on forwarded answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 74
diff changeset
86 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
87 CHECK_PARAMS(srlist && req && *req && hbhloc);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
88
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
89 CHECK_MALLOC( sr = malloc(sizeof(struct sentreq)) );
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
90 memset(sr, 0, sizeof(struct sentreq));
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
91 fd_list_init(&sr->chain, hbhloc);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
92 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
93 sr->prevhbh = hbh_restore;
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
94
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
95 /* Search the place in the list */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
96 CHECK_POSIX( pthread_mutex_lock(&srlist->mtx) );
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
97 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
98 if (match) {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
99 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
100 free(sr);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
101 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
102 return EINVAL;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
103 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
104
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
105 /* Save in the list */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
106 *req = NULL;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
107 fd_list_insert_before(next, &sr->chain);
71
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
108 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
109 CHECK_POSIX( pthread_mutex_unlock(&srlist->mtx) );
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
110 return 0;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
111 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
112
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
113 /* Fetch a request by hbh */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
114 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
115 {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
116 struct sentreq * sr;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
117 int match;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
118
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
119 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
120 CHECK_PARAMS(srlist && req);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
121
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
122 /* Search the request in the list */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
123 CHECK_POSIX( pthread_mutex_lock(&srlist->mtx) );
71
cba30013d8f5 Added debug messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
124 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
125 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
126 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
127 TRACE_DEBUG(INFO, "There is no saved request with this hop-by-hop id (%x)", hbh);
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
128 *req = NULL;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
129 } 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
130 /* 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
131 *((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
132 /* Unlink */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
133 fd_list_unlink(&sr->chain);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
134 *req = sr->req;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
135 free(sr);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
136 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
137 CHECK_POSIX( pthread_mutex_unlock(&srlist->mtx) );
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 /* Done */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
140 return 0;
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
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
143 /* Failover requests (free or requeue routables) */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
144 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
145 {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
146 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
147 while (!FD_IS_LIST_EMPTY(&srlist->srs)) {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
148 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
149 fd_list_unlink(&sr->chain);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
150 if (fd_msg_is_routable(sr->req)) {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
151 struct msg_hdr * hdr = NULL;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
152
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
153 /* Set the 'T' flag */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154 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
155 if (hdr)
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
156 hdr->msg_flags |= CMD_FLAG_RETRANSMIT;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
157
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
158 /* Requeue for sending to another peer */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
159 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
160 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
161 } else {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
162 /* Just free the request... */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
163 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
164 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
165 free(sr);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
166 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
167 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
168 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
169
"Welcome to our mercurial repository"