Debian Codegraph @

lib/freeDiameter-1.2.1/libfdproto/sessions.c

raw symbols SCIP
1 /*********************************************************************************************************
2 * Software License Agreement (BSD License) *
3 * Author: Sebastien Decugis <[email protected]> *
4 * *
5 * Copyright (c) 2013, WIDE Project and NICT *
6 * All rights reserved. *
7 * *
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
9 * permitted provided that the following conditions are met: *
10 * *
11 * * Redistributions of source code must retain the above *
12 * copyright notice, this list of conditions and the *
13 * following disclaimer. *
14 * *
15 * * Redistributions in binary form must reproduce the above *
16 * copyright notice, this list of conditions and the *
17 * following disclaimer in the documentation and/or other *
18 * materials provided with the distribution. *
19 * *
20 * * Neither the name of the WIDE Project or NICT nor the *
21 * names of its contributors may be used to endorse or *
22 * promote products derived from this software without *
23 * specific prior written permission of WIDE Project and *
24 * NICT. *
25 * *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
34 *********************************************************************************************************/
35
36 /* Sessions module.
37 *
38 * Basic functionalities to help implementing User sessions state machines from RFC3588.
39 */
40
41 #include "fdproto-internal.h"cxx . . $ `<file>/lib/freeDiameter-1.2.1/libfdproto/fdproto-internal.h`/
42
43 /*********************** Parameters **********************/
44
45 /* Size of the hash table containing the session objects (pow of 2. ex: 6 => 2^6 = 64). must be between 0 and 31. */
46 #ifndef SESS_HASH_SIZE
47 #define SESS_HASH_SIZEcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:47:9`! 6
48 #endif /* SESS_HASH_SIZE */
49
50 /* Default lifetime of a session, in seconds. (31 days = 2678400 seconds) */
51 #ifndef SESS_DEFAULT_LIFETIME
52 #define SESS_DEFAULT_LIFETIMEcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:52:9`! 2678400
53 #endif /* SESS_DEFAULT_LIFETIME */
54
55 /********************** /Parameters **********************/
56
57 /* Eyescatchers definitions */
58 #define SH_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:58:9`! 0x53554AD1
59 #define SD_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:59:9`! 0x5355D474
60 #define SI_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:60:9`! 0x53551D
61
62 /* Macro to check an object is valid */
63 #define VALIDATE_SHcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:63:9`!( _obj ) ( ((_obj) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && ( ((struct session_handler *)(_obj))->eyec == SH_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:58:9`!) )
64 #define VALIDATE_SIcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:64:9`!( _obj ) ( ((_obj) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && ( ((struct session *)(_obj))->eyec == SI_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:60:9`!) )
65
66
67 /* Handlers registered by users of the session module */
68 struct session_handlercxx . . $ session_handler# {
69 int eyeccxx . . $ session_handler#eyec.; /* An eye catcher also used to ensure the object is valid, must be SH_EYEC */
70 int idcxx . . $ session_handler#id.; /* A unique integer to identify this handler */
71 void (*cleanupcxx . . $ session_handler#cleanup.)(struct sess_statecxx . . $ sess_state# *, os0_tcxx . . $ os0_t#, void *); /* The cleanup function to be called for cleaning a state */
72 session_state_dumpcxx . . $ session_state_dump# state_dumpcxx . . $ session_handler#state_dump.; /* dumper function */
73 void *opaquecxx . . $ session_handler#opaque.; /* a value that is passed as is to the cleanup callback */
74 };
75
76 static int hdl_idcxx . . $ hdl_id. = 0; /* A global counter to initialize the id field */
77 static pthread_mutex_tcxx . . $ pthread_mutex_t# hdl_lockcxx . . $ hdl_lock. = PTHREAD_MUTEX_INITIALIZERcxx . . $ `<external>/14712363683955484316/pthread.h:90:9`!; /* lock to protect hdl_id; we could use atomic operations otherwise (less portable) */
78
79
80 /* Data structures linked from the sessions, containing the applications states */
81 struct statecxx . . $ state# {
82 int eyeccxx . . $ state#eyec.; /* Must be SD_EYEC */
83 struct sess_statecxx . . $ sess_state# *statecxx . . $ state#state.; /* The state registered by the application, never NULL (or the whole object is deleted) */
84 struct fd_listcxx . . $ fd_list# chaincxx . . $ state#chain.; /* Chaining in the list of session's states ordered by hdl->id */
85 unioncxx . . $ state#$anonymous_type_0# {
86 struct session_handlercxx . . $ session_handler# *hdlcxx . . $ state#$anonymous_type_0#hdl.; /* The handler for which this state was registered */
87 os0_tcxx . . $ os0_t# sidcxx . . $ state#$anonymous_type_0#sid.; /* For deleted state, the sid of the session it belong to */
88 };
89 };
90
91 /* Session object, one for each value of Session-Id AVP */
92 struct sessioncxx . . $ session# {
93 int eyeccxx . . $ session#eyec.; /* Eyecatcher, SI_EYEC */
94
95 os0_tcxx . . $ os0_t# sidcxx . . $ session#sid.; /* The \0-terminated Session-Id */
96 size_t sidlencxx . . $ session#sidlen.; /* cached length of sid */
97 uint32_tcxx . . $ uint32_t# hashcxx . . $ session#hash.; /* computed hash of sid */
98 struct fd_listcxx . . $ fd_list# chain_hcxx . . $ session#chain_h.;/* chaining in the hash table of sessions. */
99
100 struct timespeccxx . . $ timespec# timeoutcxx . . $ session#timeout.;/* Timeout date for the session */
101 struct fd_listcxx . . $ fd_list# expirecxx . . $ session#expire.; /* List of expiring sessions, ordered by timeouts. */
102
103 pthread_mutex_tcxx . . $ pthread_mutex_t# stlockcxx . . $ session#stlock.; /* A lock to protect the list of states associated with this session */
104 struct fd_listcxx . . $ fd_list# statescxx . . $ session#states.; /* Sentinel for the list of states of this session. */
105 int msg_cntcxx . . $ session#msg_cnt.;/* Reference counter for the messages pointing to this session */
106 int is_destroyedcxx . . $ session#is_destroyed.; /* boolean telling if fd_sess_detroy has been called on this */
107 };
108
109 /* Sessions hash table, to allow fast sid to session retrieval */
110 static structcxx . . $ $anonymous_type_eed3f54e7105150d_1# {
111 struct fd_listcxx . . $ fd_list# sentinelcxx . . $ $anonymous_type_eed3f54e7105150d_1#sentinel.; /* sentinel element for this sublist. The sublist is ordered by hash value, then fd_os_cmp(sid). */
112 pthread_mutex_tcxx . . $ pthread_mutex_t# lockcxx . . $ $anonymous_type_eed3f54e7105150d_1#lock.; /* the mutex for this sublist -- we might probably change it to rwlock for a little optimization */
113 } sess_hashcxx . . $ sess_hash. [ 1 << SESS_HASH_SIZEcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:47:9`! ] ;
114 #define H_MASKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:114:9`!( __hash ) ((__hash) & (( 1 << SESS_HASH_SIZEcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:47:9`! ) - 1))
115 #define H_LISTcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:115:9`!( _hash ) (&(sess_hash[H_MASKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:114:9`!(_hash)].sentinel))
116 #define H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!( _hash ) (&(sess_hash[H_MASKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:114:9`!(_hash)].lock ))
117
118 static uint32_tcxx . . $ uint32_t# sess_cntcxx . . $ sess_cnt. = 0; /* counts all active session (that are in the expiry list) */
119
120 /* The following are used to generate sid values that are eternaly unique */
121 static uint32_tcxx . . $ uint32_t# sid_hcxx . . $ sid_h.; /* initialized to the current time in fd_sess_init */
122 static uint32_tcxx . . $ uint32_t# sid_lcxx . . $ sid_l.; /* incremented each time a session id is created */
123 static pthread_mutex_tcxx . . $ pthread_mutex_t# sid_lockcxx . . $ sid_lock. = PTHREAD_MUTEX_INITIALIZERcxx . . $ `<external>/14712363683955484316/pthread.h:90:9`!;
124
125 /* Expiring sessions management */
126 static struct fd_listcxx . . $ fd_list# exp_sentinelcxx . . $ exp_sentinel. = FD_LIST_INITIALIZERcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:902:9`!(exp_sentinel); /* list of sessions ordered by their timeout date */
127 static pthread_mutex_tcxx . . $ pthread_mutex_t# exp_lockcxx . . $ exp_lock. = PTHREAD_MUTEX_INITIALIZERcxx . . $ `<external>/14712363683955484316/pthread.h:90:9`!; /* lock protecting the list. */
128 static pthread_cond_tcxx . . $ pthread_cond_t# exp_condcxx . . $ exp_cond. = PTHREAD_COND_INITIALIZERcxx . . $ `<external>/14712363683955484316/pthread.h:155:9`!; /* condvar used by the expiry mecahinsm. */
129 static pthread_tcxx . . $ pthread_t# exp_thrcxx . . $ exp_thr. = (pthread_tcxx . . $ pthread_t#)NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; /* The expiry thread that handles cleanup of expired sessions */
130
131 /* Hierarchy of the locks, to avoid deadlocks:
132 * hash lock > state lock > expiry lock
133 * i.e. state lock can be taken while holding the hash lock, but not while holding the expiry lock.
134 * As well, the hash lock cannot be taken while holding a state lock.
135 */
136
137 /********************************************************************************************************/
138
139 /* Initialize a session object. It is not linked now. sid must be already malloc'ed. The hash has already been computed. */
140 static struct sessioncxx . . $ session# * new_sessioncxx . . $ new_session(7bb7488621768b2f).(os0_tcxx . . $ os0_t# sid, size_t sidlen, uint32_tcxx . . $ uint32_t# hash)
141 {
142 struct sessioncxx . . $ session# * sess;
143
144 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %zd", sid, sidlen);
145 CHECK_PARAMS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:575:10`!( sid && sidlen, return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! );
146
147 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( sess = malloc(sizeof(struct session)), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! );
148 memsetcxx . . $ memset(d1de1e4fb215f1c6).(sess, 0, sizeof(struct sessioncxx . . $ session#));
149
150 sess->eyeccxx . . $ session#eyec. = SI_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:60:9`!;
151
152 sess->sidcxx . . $ session#sid. = sid;
153 sess->sidlencxx . . $ session#sidlen. = sidlen;
154 sess->hashcxx . . $ session#hash. = hash;
155 fd_list_initcxx . . $ fd_list_init(a68d7934af8ecc50).(&sess->chain_hcxx . . $ session#chain_h., sess);
156
157 CHECK_SYS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:530:10`!( clock_gettime(CLOCK_REALTIMEcxx . . $ `<external>/89459239771508533/time.h:46:10`!, &sess->timeout), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! );
158 sess->timeoutcxx . . $ session#timeout..tv_seccxx . . $ timespec#tv_sec. += SESS_DEFAULT_LIFETIMEcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:52:9`!;
159 fd_list_initcxx . . $ fd_list_init(a68d7934af8ecc50).(&sess->expirecxx . . $ session#expire., sess);
160
161 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_init(&sess->stlock, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! );
162 fd_list_initcxx . . $ fd_list_init(a68d7934af8ecc50).(&sess->statescxx . . $ session#states., sess);
163
164 return sess;
165 }
166
167 /* destroy the session object. It should really be already unlinked... */
168 static void del_sessioncxx . . $ del_session(d19d4aaba4356b91).(struct sessioncxx . . $ session# * s)
169 {
170 ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(FD_IS_LIST_EMPTYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:909:9`!(&s->states));
171 freecxx . . $ free(5d22bdacc48458e8).(s->sidcxx . . $ session#sid.);
172 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).(&s->chain_hcxx . . $ session#chain_h.);
173 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).(&s->expirecxx . . $ session#expire.);
174 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_destroy(&s->stlock), /* continue */ );
175 freecxx . . $ free(5d22bdacc48458e8).(s);
176 }
177
178 /* The expiry thread */
179 static void * exp_fctcxx . . $ exp_fct(9f162e79bfc6c74).(void * arg)
180 {
181 fd_log_threadnamecxx . . $ fd_log_threadname(85c52e162fed56f9). ( "Session/expire" );
182 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "" );
183
184
185 do {
186 struct timespeccxx . . $ timespec# now;
187 struct sessioncxx . . $ session# * first;
188
189 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_lock(&exp_lock), break );
190 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fd_cleanup_mutex, &exp_lock );
191 again:
192 /* Check if there are expiring sessions available */
193 if (FD_IS_LIST_EMPTYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:909:9`!(&exp_sentinel)) {
194 /* Just wait for a change or cancelation */
195 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_cond_wait( &exp_cond, &exp_lock ), break /* this might not pop the cleanup handler, but since we ASSERT(0), it is not the big issue... */ );
196 /* Restart the loop on wakeup */
197 goto again;
198 }
199
200 /* Get the pointer to the session that expires first */
201 first = (struct sessioncxx . . $ session# *)(exp_sentinelcxx . . $ exp_sentinel..nextcxx . . $ fd_list#next.->ocxx . . $ fd_list#o.);
202 ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!( VALIDATE_SIcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:64:9`!(first) );
203
204 /* Get the current time */
205 CHECK_SYS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:530:10`!( clock_gettime(CLOCK_REALTIMEcxx . . $ `<external>/89459239771508533/time.h:46:10`!, &now), break );
206
207 /* If first session is not expired, we just wait until it happens */
208 if ( TS_IS_INFERIORcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:716:9`!( &now, &first->timeout ) ) {
209
210 CHECK_POSIX_DO2cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:543:10`!( pthread_cond_timedwait( &exp_cond, &exp_lock, &first->timeout ),
211 ETIMEDOUTcxx . . $ `<external>/17922322188510340118/errno.h:94:9`!, /* ETIMEDOUT is a normal error, continue */,
212 /* on other error, */ break );
213
214 /* on wakeup, loop */
215 goto again;
216 }
217
218 /* Now, the first session in the list is expired; destroy it */
219 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!( 0 );
220 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock(&exp_lock), break );
221
222 CHECK_FCT_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:587:10`!( fd_sess_destroy( &first ), break );
223
224 } while (1);
225
226 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "A system error occurred in session module! Expiry thread is terminating...");
227 ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0);
228 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
229 }
230
231
232
233 /********************************************************************************************************/
234
235 /* Initialize the session module */
236 int fd_sess_initcxx . . $ fd_sess_init(b126dc7c1de90089).(void)
237 {
238 int i;
239
240 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "" );
241
242 /* Initialize the global counters */
243 sid_hcxx . . $ sid_h. = (uint32_tcxx . . $ uint32_t#) timecxx . . $ time(7f38134db6521d23).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
244 sid_lcxx . . $ sid_l. = 0;
245
246 /* Initialize the hash table */
247 for (i = 0; i < sizeof(sess_hashcxx . . $ sess_hash.) / sizeof(sess_hashcxx . . $ sess_hash.[0]); i++) {
248 fd_list_initcxx . . $ fd_list_init(a68d7934af8ecc50).( &sess_hashcxx . . $ sess_hash.[i].sentinelcxx . . $ $anonymous_type_eed3f54e7105150d_1#sentinel., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! );
249 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_init(&sess_hash[i].lock, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) );
250 }
251
252 return 0;
253 }
254
255 /* Run this when initializations are complete. */
256 int fd_sess_startcxx . . $ fd_sess_start(b126dc7c1de90089).(void)
257 {
258 /* Start session garbage collector (expiry) */
259 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_create(&exp_thr, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, exp_fct, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) );
260
261 return 0;
262 }
263
264 /* Terminate */
265 void fd_sess_finicxx . . $ fd_sess_fini(49f6e7a06ebc5aa8).(void)
266 {
267 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("");
268 CHECK_FCT_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:587:10`!( fd_thr_term(&exp_thr), /* continue */ );
269
270 /* Destroy all sessions in the hash table, and the hash table itself? -- How to do it without a race condition ? */
271
272 return;
273 }
274
275 /* Create a new handler */
276 int fd_sess_handler_createcxx . . $ fd_sess_handler_create(779ce813148712ca). ( struct session_handlercxx . . $ session_handler# ** handler, void (*cleanup)(struct sess_statecxx . . $ sess_state# *, os0_tcxx . . $ os0_t#, void *), session_state_dumpcxx . . $ session_state_dump# dumper, void * opaque )
277 {
278 struct session_handlercxx . . $ session_handler# *new;
279
280 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %p", handler, cleanup);
281
282 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( handler && cleanup );
283
284 CHECK_MALLOCcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:572:10`!( new = malloc(sizeof(struct session_handler)) );
285 memsetcxx . . $ memset(d1de1e4fb215f1c6).(new, 0, sizeof(struct session_handlercxx . . $ session_handler#));
286
287 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock(&hdl_lock) );
288 new->idcxx . . $ session_handler#id. = ++hdl_idcxx . . $ hdl_id.;
289 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock(&hdl_lock) );
290
291 new->eyeccxx . . $ session_handler#eyec. = SH_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:58:9`!;
292 new->cleanupcxx . . $ session_handler#cleanup. = cleanup;
293 new->state_dumpcxx . . $ session_handler#state_dump. = dumper;
294 new->opaquecxx . . $ session_handler#opaque. = opaque;
295
296 *handler = new;
297 return 0;
298 }
299
300 /* Destroy a handler, and all states attached to this handler. This operation is very slow but we don't care since it's rarely used.
301 * Note that it's better to call this function after all sessions have been deleted... */
302 int fd_sess_handler_destroycxx . . $ fd_sess_handler_destroy(c50df1a60f408fee). ( struct session_handlercxx . . $ session_handler# ** handler, void ** opaque )
303 {
304 struct session_handlercxx . . $ session_handler# * del;
305 /* place to save the list of states to be cleaned up. We do it after finding them to avoid deadlocks. the "o" field becomes a copy of the sid. */
306 struct fd_listcxx . . $ fd_list# deleted_states = FD_LIST_INITIALIZERcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:902:9`!( deleted_states );
307 int i;
308
309 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p", handler);
310 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( handler && VALIDATE_SHcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:63:9`!(*handler) );
311
312 del = *handler;
313 *handler = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
314
315 del->eyeccxx . . $ session_handler#eyec. = 0xdead; /* The handler is not valid anymore for any other operation */
316
317 /* Now find all sessions with data registered for this handler, and move this data to the deleted_states list. */
318 for (i = 0; i < sizeof(sess_hashcxx . . $ sess_hash.) / sizeof(sess_hashcxx . . $ sess_hash.[0]); i++) {
319 struct fd_listcxx . . $ fd_list# * li_si;
320 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock(&sess_hash[i].lock) );
321
322 for (li_si = sess_hashcxx . . $ sess_hash.[i].sentinelcxx . . $ $anonymous_type_eed3f54e7105150d_1#sentinel..nextcxx . . $ fd_list#next.; li_si != &sess_hashcxx . . $ sess_hash.[i].sentinelcxx . . $ $anonymous_type_eed3f54e7105150d_1#sentinel.; li_si = li_si->nextcxx . . $ fd_list#next.) { /* for each session in the hash line */
323 struct fd_listcxx . . $ fd_list# * li_st;
324 struct sessioncxx . . $ session# * sess = (struct sessioncxx . . $ session# *)(li_si->ocxx . . $ fd_list#o.);
325 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock(&sess->stlock) );
326 for (li_st = sess->statescxx . . $ session#states..nextcxx . . $ fd_list#next.; li_st != &sess->statescxx . . $ session#states.; li_st = li_st->nextcxx . . $ fd_list#next.) { /* for each state in this session */
327 struct statecxx . . $ state# * st = (struct statecxx . . $ state# *)(li_st->ocxx . . $ fd_list#o.);
328 /* The list is ordered */
329 if (st->hdlcxx . . $ state#$anonymous_type_0#hdl.->idcxx . . $ session_handler#id. < del->idcxx . . $ session_handler#id.)
330 continue;
331 if (st->hdlcxx . . $ state#$anonymous_type_0#hdl.->idcxx . . $ session_handler#id. == del->idcxx . . $ session_handler#id.) {
332 /* This state belongs to the handler we are deleting, move the item to the deleted_states list */
333 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).(&st->chaincxx . . $ state#chain.);
334 st->sidcxx . . $ state#$anonymous_type_0#sid. = sess->sidcxx . . $ session#sid.;
335 fd_list_insert_beforecxx . . $ fd_list_insert_before(3eafa2e8bb09a989).(&deleted_states, &st->chaincxx . . $ state#chain.);
336 }
337 break;
338 }
339 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock(&sess->stlock) );
340 }
341 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock(&sess_hash[i].lock) );
342 }
343
344 /* Now, delete all states after calling their cleanup handler */
345 while (!FD_IS_LIST_EMPTYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:909:9`!(&deleted_states)) {
346 struct statecxx . . $ state# * st = (struct statecxx . . $ state# *)(deleted_states.nextcxx . . $ fd_list#next.->ocxx . . $ fd_list#o.);
347 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Calling cleanup handler for session '%s' and data %p", st->sid, st->state);
348 (*del->cleanupcxx . . $ session_handler#cleanup.)(st->statecxx . . $ state#state., st->sidcxx . . $ state#$anonymous_type_0#sid., del->opaquecxx . . $ session_handler#opaque.);
349 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).(&st->chaincxx . . $ state#chain.);
350 freecxx . . $ free(5d22bdacc48458e8).(st);
351 }
352
353 if (opaque)
354 *opaque = del->opaquecxx . . $ session_handler#opaque.;
355
356 /* Free the handler */
357 freecxx . . $ free(5d22bdacc48458e8).(del);
358
359 return 0;
360 }
361
362
363
364 /* Create a new session object with the default timeout value, and link it. The refcount is increased by 1, whether the session existed or not */
365 int fd_sess_newcxx . . $ fd_sess_new(72a46c1fa282e299). ( struct sessioncxx . . $ session# ** session, DiamId_tcxx . . $ DiamId_t# diamid, size_t diamidlen, uint8_tcxx . . $ uint8_t# * opt, size_t optlen )
366 {
367 os0_tcxx . . $ os0_t# sid = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
368 size_t sidlen;
369 uint32_tcxx . . $ uint32_t# hash;
370 struct sessioncxx . . $ session# * sess;
371 struct fd_listcxx . . $ fd_list# * li;
372 int found = 0;
373 int ret = 0;
374
375 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %p %zd %p %zd", session, diamid, diamidlen, opt, optlen);
376 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( session && (diamid || opt) );
377
378 if (diamid) {
379 if (!diamidlen) {
380 diamidlen = strlencxx . . $ strlen(751346f8406fd082).(diamid);
381 }
382 /* We check if the string is a valid DiameterIdentity */
383 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( fd_os_is_valid_DiameterIdentity((uint8_t *)diamid, diamidlen) );
384 } else {
385 diamidlen = 0;
386 }
387 if (opt) {
388 if (!optlen) {
389 optlen = strlencxx . . $ strlen(751346f8406fd082).((char *)opt);
390 } else {
391 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( fd_os_is_valid_os0(opt, optlen) );
392 }
393 } else {
394 optlen = 0;
395 }
396
397 /* Ok, first create the identifier for the string */
398 if (diamid == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
399 /* opt is the full string */
400 CHECK_MALLOCcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:572:10`!( sid = os0dupcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:769:9`!(opt, optlen) );
401 sidlen = optlen;
402 } else {
403 uint32_tcxx . . $ uint32_t# sid_h_cpy;
404 uint32_tcxx . . $ uint32_t# sid_l_cpy;
405 /* "<diamId>;<high32>;<low32>[;opt]" */
406 sidlen = diamidlen;
407 sidlen += 22; /* max size of ';<high32>;<low32>' */
408 if (opt)
409 sidlen += 1 + optlen; /* ';opt' */
410 sidlen++; /* space for the final \0 also */
411 CHECK_MALLOCcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:572:10`!( sid = malloc(sidlen) );
412
413 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock(&sid_lock) );
414 if ( ++sid_lcxx . . $ sid_l. == 0 ) /* overflow */
415 ++sid_hcxx . . $ sid_h.;
416 sid_h_cpy = sid_hcxx . . $ sid_h.;
417 sid_l_cpy = sid_lcxx . . $ sid_l.;
418 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock(&sid_lock) );
419
420 if (opt) {
421 sidlen = snprintfcxx . . $ snprintf(ea502d73e74c754c).((char*)sid, sidlen, "%.*s;%u;%u;%.*s", (int)diamidlen, diamid, sid_h_cpy, sid_l_cpy, (int)optlen, opt);
422 } else {
423 sidlen = snprintfcxx . . $ snprintf(ea502d73e74c754c).((char*)sid, sidlen, "%.*s;%u;%u", (int)diamidlen, diamid, sid_h_cpy, sid_l_cpy);
424 }
425 }
426
427 hash = fd_os_hashcxx . . $ fd_os_hash(8cbb85865c56216f).(sid, sidlen);
428
429 /* Now find the place to add this object in the hash table. */
430 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(hash) ) );
431 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fd_cleanup_mutex, H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(hash) );
432
433 for (li = H_LISTcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:115:9`!(hash)->nextcxx . . $ fd_list#next.; li != H_LISTcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:115:9`!(hash); li = li->nextcxx . . $ fd_list#next.) {
434 int cmp;
435 struct sessioncxx . . $ session# * s = (struct sessioncxx . . $ session# *)(li->ocxx . . $ fd_list#o.);
436
437 /* The list is ordered by hash and sid (in case of collisions) */
438 if (s->hashcxx . . $ session#hash. < hash)
439 continue;
440 if (s->hashcxx . . $ session#hash. > hash)
441 break;
442
443 cmp = fd_os_cmpcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:800:9`!(s->sid, s->sidlen, sid, sidlen);
444 if (cmp < 0)
445 continue;
446 if (cmp > 0)
447 break;
448
449 /* A session with the same sid was already in the hash table */
450 found = 1;
451 *session = s;
452 break;
453 }
454
455 /* If the session did not exist, we can create it & link it in global tables */
456 if (!found) {
457 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!(sess = new_session(sid, sidlen, hash),
458 {
459 ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
460 free(sid);
461 goto out;
462 } );
463
464 fd_list_insert_beforecxx . . $ fd_list_insert_before(3eafa2e8bb09a989).(li, &sess->chain_hcxx . . $ session#chain_h.); /* hash table */
465 sess->msg_cntcxx . . $ session#msg_cnt.++;
466 } else {
467 freecxx . . $ free(5d22bdacc48458e8).(sid);
468
469 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock(&(*session)->stlock) );
470 (*session)->msg_cntcxx . . $ session#msg_cnt.++;
471 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock(&(*session)->stlock) );
472
473 /* it was found: was it previously destroyed? */
474 if ((*session)->is_destroyedcxx . . $ session#is_destroyed. == 0) {
475 ret = EALREADYcxx . . $ `<external>/17922322188510340118/errno.h:98:9`!;
476 goto out;
477 } else {
478 /* the session was marked destroyed, let's re-activate it. */
479 sess = *session;
480 sess->is_destroyedcxx . . $ session#is_destroyed. = 0;
481
482 /* update the expiry time */
483 CHECK_SYS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:530:10`!( clock_gettime(CLOCK_REALTIMEcxx . . $ `<external>/89459239771508533/time.h:46:10`!, &sess->timeout), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); } );
484 sess->timeoutcxx . . $ session#timeout..tv_seccxx . . $ timespec#tv_sec. += SESS_DEFAULT_LIFETIMEcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:52:9`!;
485 }
486 }
487
488 /* We must insert in the expiry list */
489 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &exp_lock ) );
490 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fd_cleanup_mutex, &exp_lock );
491
492 /* Find the position in that list. We take it in reverse order */
493 for (li = exp_sentinelcxx . . $ exp_sentinel..prevcxx . . $ fd_list#prev.; li != &exp_sentinelcxx . . $ exp_sentinel.; li = li->prevcxx . . $ fd_list#prev.) {
494 struct sessioncxx . . $ session# * s = (struct sessioncxx . . $ session# *)(li->ocxx . . $ fd_list#o.);
495 if (TS_IS_INFERIORcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:716:9`!( &s->timeout, &sess->timeout ) )
496 break;
497 }
498 fd_list_insert_aftercxx . . $ fd_list_insert_after(3eafa2e8bb09a989).( li, &sess->expirecxx . . $ session#expire. );
499 sess_cntcxx . . $ sess_cnt.++;
500
501 /* We added a new expiring element, we must signal */
502 if (li == &exp_sentinelcxx . . $ exp_sentinel.) {
503 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_cond_signal(&exp_cond), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); } ); /* if it fails, we might not pop the cleanup handlers, but this should not happen -- and we'd have a serious problem otherwise */
504 }
505
506 /* We're done with the locked part */
507 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
508 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock( &exp_lock ), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); } ); /* if it fails, we might not pop the cleanup handler, but this should not happen -- and we'd have a serious problem otherwise */
509
510 out:
511 ;
512 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
513 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(hash) ) );
514
515 if (ret) /* in case of error */
516 return ret;
517
518 *session = sess;
519 return 0;
520 }
521
522 /* Find or create a session -- the msg refcount is increased */
523 int fd_sess_fromsid_msgcxx . . $ fd_sess_fromsid_msg(94fa8e19a952be92). ( uint8_tcxx . . $ uint8_t# * sid, size_t len, struct sessioncxx . . $ session# ** session, int * new)
524 {
525 int ret;
526
527 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %zd %p %p", sid, len, session, new);
528 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( sid && session );
529
530 if (!fd_os_is_valid_os0cxx . . $ fd_os_is_valid_os0(e44f9e08e4f6527d).(sid,len)) {
531 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Warning: a Session-Id value contains \\0 chars... (len:%zd, begin:'%.*s') => Debug messages may be truncated.", len, (int)len, sid);
532 }
533
534 /* All the work is done in sess_new */
535 ret = fd_sess_newcxx . . $ fd_sess_new(72a46c1fa282e299). ( session, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, sid, len );
536 switch (ret) {
537 case 0:
538 case EALREADYcxx . . $ `<external>/17922322188510340118/errno.h:98:9`!:
539 break;
540
541 default:
542 CHECK_FCTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:588:10`!(ret);
543 }
544
545 if (new)
546 *new = ret ? 0 : 1;
547
548 return 0;
549 }
550
551 /* Get the sid of a session */
552 int fd_sess_getsidcxx . . $ fd_sess_getsid(bb3c882b8729d3a1). ( struct sessioncxx . . $ session# * session, os0_tcxx . . $ os0_t# * sid, size_t * sidlen )
553 {
554 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %p", session, sid);
555
556 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( VALIDATE_SIcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:64:9`!(session) && sid );
557
558 *sid = session->sidcxx . . $ session#sid.;
559 if (sidlen)
560 *sidlen = session->sidlencxx . . $ session#sidlen.;
561
562 return 0;
563 }
564
565 /* Change the timeout value of a session */
566 int fd_sess_settimeoutcxx . . $ fd_sess_settimeout(d1d73e6bc1868094).( struct sessioncxx . . $ session# * session, const struct timespeccxx . . $ timespec# * timeout )
567 {
568 struct fd_listcxx . . $ fd_list# * li;
569
570 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %p", session, timeout);
571 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( VALIDATE_SIcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:64:9`!(session) && timeout );
572
573 /* Lock -- do we need to lock the hash table as well? I don't think so... */
574 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &exp_lock ) );
575 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fd_cleanup_mutex, &exp_lock );
576
577 /* Update the timeout */
578 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).(&session->expirecxx . . $ session#expire.);
579 memcpycxx . . $ memcpy(cc817cb175f282d).(&session->timeoutcxx . . $ session#timeout., timeout, sizeof(struct timespeccxx . . $ timespec#));
580
581 /* Find the new position in expire list. We take it in normal order */
582 for (li = exp_sentinelcxx . . $ exp_sentinel..nextcxx . . $ fd_list#next.; li != &exp_sentinelcxx . . $ exp_sentinel.; li = li->nextcxx . . $ fd_list#next.) {
583 struct sessioncxx . . $ session# * s = (struct sessioncxx . . $ session# *)(li->ocxx . . $ fd_list#o.);
584
585 if (TS_IS_INFERIORcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:716:9`!( &s->timeout, &session->timeout ) )
586 continue;
587
588 break;
589 }
590 fd_list_insert_beforecxx . . $ fd_list_insert_before(3eafa2e8bb09a989).( li, &session->expirecxx . . $ session#expire. );
591
592 /* We added a new expiring element, we must signal if it was in first position */
593 if (session->expirecxx . . $ session#expire..prevcxx . . $ fd_list#prev. == &exp_sentinelcxx . . $ exp_sentinel.) {
594 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_cond_signal(&exp_cond), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); /* so that we don't have a pending cancellation handler */ } );
595 }
596
597 /* We're done */
598 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
599 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &exp_lock ) );
600
601 return 0;
602 }
603
604 /* Destroy the states associated to a session, and mark it destroyed. */
605 int fd_sess_destroycxx . . $ fd_sess_destroy(b6ff2c635609c684). ( struct sessioncxx . . $ session# ** session )
606 {
607 struct sessioncxx . . $ session# * sess;
608 int destroy_now;
609 os0_tcxx . . $ os0_t# sid;
610 int ret = 0;
611
612 /* place to save the list of states to be cleaned up. We do it after finding them to avoid deadlocks. the "o" field becomes a copy of the sid. */
613 struct fd_listcxx . . $ fd_list# deleted_states = FD_LIST_INITIALIZERcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:902:9`!( deleted_states );
614
615 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p", session);
616 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( session && VALIDATE_SIcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:64:9`!(*session) );
617
618 sess = *session;
619 *session = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
620
621 /* Lock the hash line */
622 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(sess->hash) ) );
623 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fd_cleanup_mutex, H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(sess->hash) );
624
625 /* Unlink from the expiry list */
626 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_lock( &exp_lock ), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); /* otherwise cleanup handler is not pop'd */ } );
627 if (!FD_IS_LIST_EMPTYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:909:9`!(&sess->expire)) {
628 sess_cntcxx . . $ sess_cnt.--;
629 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).( &sess->expirecxx . . $ session#expire. ); /* no need to signal the condition here */
630 }
631 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock( &exp_lock ), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); /* otherwise cleanup handler is not pop'd */ } );
632
633 /* Now move all states associated to this session into deleted_states */
634 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_lock( &sess->stlock ), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); /* otherwise cleanup handler is not pop'd */ } );
635 while (!FD_IS_LIST_EMPTYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:909:9`!(&sess->states)) {
636 struct statecxx . . $ state# * st = (struct statecxx . . $ state# *)(sess->statescxx . . $ session#states..nextcxx . . $ fd_list#next.->ocxx . . $ fd_list#o.);
637 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).(&st->chaincxx . . $ state#chain.);
638 fd_list_insert_beforecxx . . $ fd_list_insert_before(3eafa2e8bb09a989).(&deleted_states, &st->chaincxx . . $ state#chain.);
639 }
640 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock( &sess->stlock ), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); /* otherwise cleanup handler is not pop'd */ } );
641
642 /* Mark the session as destroyed */
643 destroy_now = (sess->msg_cntcxx . . $ session#msg_cnt. == 0);
644 if (destroy_now) {
645 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).( &sess->chain_hcxx . . $ session#chain_h. );
646 sid = sess->sidcxx . . $ session#sid.;
647 } else {
648 sess->is_destroyedcxx . . $ session#is_destroyed. = 1;
649 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( sid = os0dupcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:769:9`!(sess->sid, sess->sidlen), ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`! );
650 }
651 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
652 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(sess->hash) ) );
653
654 if (ret)
655 return ret;
656
657 /* Now, really delete the states */
658 while (!FD_IS_LIST_EMPTYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:909:9`!(&deleted_states)) {
659 struct statecxx . . $ state# * st = (struct statecxx . . $ state# *)(deleted_states.nextcxx . . $ fd_list#next.->ocxx . . $ fd_list#o.);
660 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).(&st->chaincxx . . $ state#chain.);
661 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Calling handler %p cleanup for state %p registered with session '%s'", st->hdl, st, sid);
662 (*st->hdlcxx . . $ state#$anonymous_type_0#hdl.->cleanupcxx . . $ session_handler#cleanup.)(st->statecxx . . $ state#state., sid, st->hdlcxx . . $ state#$anonymous_type_0#hdl.->opaquecxx . . $ session_handler#opaque.);
663 freecxx . . $ free(5d22bdacc48458e8).(st);
664 }
665
666 /* Finally, destroy the session itself, if it is not referrenced by any message anymore */
667 if (destroy_now) {
668 del_sessioncxx . . $ del_session(d19d4aaba4356b91).(sess);
669 } else {
670 freecxx . . $ free(5d22bdacc48458e8).(sid);
671 }
672
673 return 0;
674 }
675
676 /* Destroy a session if it is not used */
677 int fd_sess_reclaimcxx . . $ fd_sess_reclaim(b6ff2c635609c684). ( struct sessioncxx . . $ session# ** session )
678 {
679 struct sessioncxx . . $ session# * sess;
680 uint32_tcxx . . $ uint32_t# hash;
681 int destroy_now = 0;
682
683 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p", session);
684 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( session && VALIDATE_SIcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:64:9`!(*session) );
685
686 sess = *session;
687 hash = sess->hashcxx . . $ session#hash.;
688 *session = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
689
690 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(hash) ) );
691 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fd_cleanup_mutex, H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(hash) );
692 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_lock( &sess->stlock ), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); /* otherwise, cleanup not poped on FreeBSD */ } );
693 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fd_cleanup_mutex, &sess->stlock );
694 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_lock( &exp_lock ), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); /* otherwise, cleanup not poped on FreeBSD */ } );
695
696 /* We only do something if the states list is empty */
697 if (FD_IS_LIST_EMPTYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:909:9`!(&sess->states)) {
698 /* In this case, we do as in destroy */
699 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).( &sess->expirecxx . . $ session#expire. );
700 destroy_now = (sess->msg_cntcxx . . $ session#msg_cnt. == 0);
701 if (destroy_now) {
702 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).(&sess->chain_hcxx . . $ session#chain_h.);
703 } else {
704 /* just mark it as destroyed, it will be freed when the last message stops referencing it */
705 sess->is_destroyedcxx . . $ session#is_destroyed. = 1;
706 }
707 }
708
709 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock( &exp_lock ), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); /* otherwise, cleanup not poped on FreeBSD */ } );
710 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
711 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock( &sess->stlock ), { ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(0); /* otherwise, cleanup not poped on FreeBSD */ } );
712 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
713 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(hash) ) );
714
715 if (destroy_now)
716 del_sessioncxx . . $ del_session(d19d4aaba4356b91).(sess);
717
718 return 0;
719 }
720
721 /* Save a state information with a session */
722 int fd_sess_state_storecxx . . $ fd_sess_state_store(bdbc85e002a2ad06). ( struct session_handlercxx . . $ session_handler# * handler, struct sessioncxx . . $ session# * session, struct sess_statecxx . . $ sess_state# ** state )
723 {
724 struct statecxx . . $ state# *new;
725 struct fd_listcxx . . $ fd_list# * li;
726 int already = 0;
727 int ret = 0;
728
729 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %p %p", handler, session, state);
730 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( handler && VALIDATE_SHcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:63:9`!(handler) && session && VALIDATE_SIcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:64:9`!(session) && (!session->is_destroyed) && state );
731
732 /* Lock the session state list */
733 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock(&session->stlock) );
734 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fd_cleanup_mutex, &session->stlock );
735
736 /* Create the new state object */
737 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!(new = malloc(sizeof(struct state)), { ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!; goto out; } );
738 memsetcxx . . $ memset(d1de1e4fb215f1c6).(new, 0, sizeof(struct statecxx . . $ state#));
739
740 new->eyeccxx . . $ state#eyec. = SD_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:59:9`!;
741 new->statecxx . . $ state#state.= *state;
742 fd_list_initcxx . . $ fd_list_init(a68d7934af8ecc50).(&new->chaincxx . . $ state#chain., new);
743 new->hdlcxx . . $ state#$anonymous_type_0#hdl. = handler;
744
745 /* find place for this state in the list */
746 for (li = session->statescxx . . $ session#states..nextcxx . . $ fd_list#next.; li != &session->statescxx . . $ session#states.; li = li->nextcxx . . $ fd_list#next.) {
747 struct statecxx . . $ state# * st = (struct statecxx . . $ state# *)(li->ocxx . . $ fd_list#o.);
748 /* The list is ordered by handler's id */
749 if (st->hdlcxx . . $ state#$anonymous_type_0#hdl.->idcxx . . $ session_handler#id. < handler->idcxx . . $ session_handler#id.)
750 continue;
751
752 if (st->hdlcxx . . $ state#$anonymous_type_0#hdl.->idcxx . . $ session_handler#id. == handler->idcxx . . $ session_handler#id.) {
753 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "A state was already stored for session '%s' and handler '%p', at location %p", session->sid, st->hdl, st->state);
754 already = EALREADYcxx . . $ `<external>/17922322188510340118/errno.h:98:9`!;
755 }
756
757 break;
758 }
759
760 if (!already) {
761 fd_list_insert_beforecxx . . $ fd_list_insert_before(3eafa2e8bb09a989).(li, &new->chaincxx . . $ state#chain.);
762 *state = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
763 } else {
764 freecxx . . $ free(5d22bdacc48458e8).(new);
765 }
766 out:
767 ;
768 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
769 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock(&session->stlock) );
770
771 return ret ?: already;
772 }
773
774 /* Get the data back */
775 int fd_sess_state_retrievecxx . . $ fd_sess_state_retrieve(bdbc85e002a2ad06). ( struct session_handlercxx . . $ session_handler# * handler, struct sessioncxx . . $ session# * session, struct sess_statecxx . . $ sess_state# ** state )
776 {
777 struct fd_listcxx . . $ fd_list# * li;
778 struct statecxx . . $ state# * st = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
779
780 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %p %p", handler, session, state);
781 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( handler && VALIDATE_SHcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:63:9`!(handler) && session && VALIDATE_SIcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:64:9`!(session) && state );
782
783 *state = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
784
785 /* Lock the session state list */
786 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock(&session->stlock) );
787 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fd_cleanup_mutex, &session->stlock );
788
789 /* find the state in the list */
790 for (li = session->statescxx . . $ session#states..nextcxx . . $ fd_list#next.; li != &session->statescxx . . $ session#states.; li = li->nextcxx . . $ fd_list#next.) {
791 st = (struct statecxx . . $ state# *)(li->ocxx . . $ fd_list#o.);
792
793 /* The list is ordered by handler's id */
794 if (st->hdlcxx . . $ state#$anonymous_type_0#hdl.->idcxx . . $ session_handler#id. > handler->idcxx . . $ session_handler#id.)
795 break;
796 }
797
798 /* If we found the state */
799 if (st && (st->hdlcxx . . $ state#$anonymous_type_0#hdl. == handler)) {
800 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).(&st->chaincxx . . $ state#chain.);
801 *state = st->statecxx . . $ state#state.;
802 freecxx . . $ free(5d22bdacc48458e8).(st);
803 }
804
805 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
806 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock(&session->stlock) );
807
808 return 0;
809 }
810
811 /* For the messages module */
812 int fd_sess_fromsidcxx . . $ fd_sess_fromsid(94fa8e19a952be92). ( uint8_tcxx . . $ uint8_t# * sid, size_t len, struct sessioncxx . . $ session# ** session, int * new)
813 {
814 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %zd %p %p", sid, len, session, new);
815 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( sid && len && session );
816
817 /* Get the session object */
818 CHECK_FCTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:588:10`!( fd_sess_fromsid_msg ( sid, len, session, new) );
819
820 /* Decrease the refcount */
821 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock(&(*session)->stlock) );
822 (*session)->msg_cntcxx . . $ session#msg_cnt.--; /* was increased in fd_sess_new */
823 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock(&(*session)->stlock) );
824
825 /* Done */
826 return 0;
827 }
828
829 int fd_sess_ref_msgcxx . . $ fd_sess_ref_msg(1bec1c0d38e029ad). ( struct sessioncxx . . $ session# * session )
830 {
831 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p", session);
832 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( VALIDATE_SIcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:64:9`!(session) );
833
834 /* Update the msg refcount */
835 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock(&session->stlock) );
836 session->msg_cntcxx . . $ session#msg_cnt.++;
837 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock(&session->stlock) );
838
839 return 0;
840 }
841
842 int fd_sess_reclaim_msgcxx . . $ fd_sess_reclaim_msg(b6ff2c635609c684). ( struct sessioncxx . . $ session# ** session )
843 {
844 int reclaim;
845 uint32_tcxx . . $ uint32_t# hash;
846
847 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p", session);
848 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( session && VALIDATE_SIcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:64:9`!(*session) );
849
850 /* Lock the hash line to avoid possibility that session is freed while we are reclaiming */
851 hash = (*session)->hashcxx . . $ session#hash.;
852 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(hash)) );
853 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fd_cleanup_mutex, H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(hash) );
854
855 /* Update the msg refcount */
856 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock(&(*session)->stlock) );
857 reclaim = (*session)->msg_cntcxx . . $ session#msg_cnt.;
858 (*session)->msg_cntcxx . . $ session#msg_cnt. = reclaim - 1;
859 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock(&(*session)->stlock) );
860
861 /* Ok, now unlock the hash line */
862 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!( 0 );
863 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( H_LOCKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:116:9`!(hash) ) );
864
865 /* and reclaim if no message references the session anymore */
866 if (reclaim == 1) {
867 CHECK_FCTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:588:10`!(fd_sess_reclaim ( session ));
868 } else {
869 *session = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
870 }
871 return 0;
872 }
873
874
875
876 /* Dump functions */
877 DECLARE_FD_DUMP_PROTOTYPEcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:241:9`!(fd_sess_dump, struct session * session, int with_states)
878 {
879 FD_DUMP_HANDLE_OFFSETcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:257:9`!();
880
881 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "{session}(@%p): ", session), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
882
883 if (!VALIDATE_SIcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:64:9`!(session)) {
884 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "INVALID/NULL"), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
885 } else {
886 char timebuf[30];
887 struct tmcxx . . $ tm# tm;
888
889 strftimecxx . . $ strftime(98e75925167c4f1b).(timebuf, sizeof(timebuf), "%D,%T", localtime_rcxx . . $ localtime_r(92e3d173686db852).( &session->timeoutcxx . . $ session#timeout..tv_seccxx . . $ timespec#tv_sec. , &tm ));
890 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "'%s'(%zd) h:%x m:%d d:%d to:%s.%06ld",
891 session->sid, session->sidlen, session->hash, session->msg_cnt, session->is_destroyed,
892 timebuf, session->timeout.tv_nsec/1000),
893 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
894
895 if (with_states) {
896 struct fd_listcxx . . $ fd_list# * li;
897 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_lock(&session->stlock), /* ignore */ );
898 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fd_cleanup_mutex, &session->stlock );
899
900 for (li = session->statescxx . . $ session#states..nextcxx . . $ fd_list#next.; li != &session->statescxx . . $ session#states.; li = li->nextcxx . . $ fd_list#next.) {
901 struct statecxx . . $ state# * st = (struct statecxx . . $ state# *)(li->ocxx . . $ fd_list#o.);
902 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "\n {state i:%d}(@%p): ", st->hdl->id, st), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
903 if (st->hdlcxx . . $ state#$anonymous_type_0#hdl.->state_dumpcxx . . $ session_handler#state_dump.) {
904 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( (*st->hdl->state_dump)( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, st->state),
905 fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "[dumper error]"));
906 } else {
907 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "<%p>", st->state), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
908 }
909 }
910
911 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
912 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock(&session->stlock), /* ignore */ );
913 }
914 }
915
916 return *buf;
917 }
918
919 DECLARE_FD_DUMP_PROTOTYPEcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:241:9`!(fd_sess_dump_hdl, struct session_handler * handler)
920 {
921 FD_DUMP_HANDLE_OFFSETcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:257:9`!();
922
923 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "{sesshdl}(@%p): ", handler), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
924
925 if (!VALIDATE_SHcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/sessions.c:63:9`!(handler)) {
926 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "INVALID/NULL"), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
927 } else {
928 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "i:%d cl:%p d:%p o:%p", handler->id, handler->cleanup, handler->state_dump, handler->opaque), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
929 }
930 return *buf;
931 }
932
933 int fd_sess_getcountcxx . . $ fd_sess_getcount(4ebf403dd87dd80).(uint32_tcxx . . $ uint32_t# *cnt)
934 {
935 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!(cnt);
936 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &exp_lock ) );
937 *cnt = sess_cntcxx . . $ sess_cnt.;
938 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &exp_lock ) );
939 return 0;
940 }