Changeset 1372:6b1a2405cebb in freeDiameter for extensions/test_cc/test_cc.c
- Timestamp:
- Jun 12, 2019, 9:54:35 PM (5 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/test_cc/test_cc.c
r1365 r1372 42 42 #define MODULE_NAME "test_cc" 43 43 44 struct statistics { 45 uint64_t sent; 46 time_t first; 47 time_t last; 48 } statistics; 49 50 void print_statistics(void) { 51 if (statistics.first == 0 || statistics.last == 0 || statistics.last == statistics.first) { 52 return; 53 } 54 55 fd_log_error("%s: %lld CCA messages sent in %llds (%.2f messages/second)", fd_g_config->cnf_diamid, 56 (long long)statistics.sent, (long long)(statistics.last-statistics.first), (float)statistics.sent / (statistics.last-statistics.first)); 57 } 58 44 59 static int ccr_handler(struct msg ** msg, struct avp * avp, struct session * sess, void * data, enum disp_action * act) 45 60 { 46 61 struct msg_hdr *hdr = NULL; 62 time_t now; 47 63 48 64 TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act); … … 134 150 /* Send the answer */ 135 151 CHECK_FCT(fd_msg_send(msg, NULL, NULL)); 152 now = time(NULL); 153 if (!statistics.first) { 154 statistics.first = now; 155 } 156 if (statistics.last != now) { 157 print_statistics(); 158 } 159 statistics.last = now; 160 statistics.sent++; 136 161 fd_log_debug("reply sent"); 137 162 } else { … … 171 196 } 172 197 198 /* And terminate it */ 199 void fd_ext_fini(void) 200 { 201 /* Unregister the callbacks */ 202 if (ccr_handler_hdl) { 203 CHECK_FCT_DO( fd_disp_unregister(&ccr_handler_hdl, NULL), ); 204 ccr_handler_hdl = NULL; 205 } 206 207 print_statistics(); 208 209 return; 210 } 211 212 173 213 EXTENSION_ENTRY(MODULE_NAME, cc_entry);
Note: See TracChangeset
for help on using the changeset viewer.