Changeset 1121:ccbd1426e04a in freeDiameter
- Timestamp:
- May 14, 2013, 4:27:28 PM (11 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/dbg_msg_timings/dbg_msg_timings.c
r1103 r1121 78 78 TS_DIFFERENCE( &delay, &qpmd->sent_on, &pmd->received_on ); 79 79 CHECK_MALLOC_DO( fd_msg_dump_summary(&buf, &len, NULL, msg, NULL, 0, 1), return ); 80 LOG_N("[TIMING] RCV ANS %ld.%06ld sec : %s", (long)delay.tv_sec, delay.tv_nsec / 1000, buf);80 LOG_N("[TIMING] RCV ANS %ld.%06ld sec <-'%s': %s", (long)delay.tv_sec, delay.tv_nsec / 1000, peer ? peer->info.pi_diamid : "<unidentified>", buf); 81 81 } 82 82 } else if (type == HOOK_MESSAGE_SENT) { 83 83 DiamId_t source = NULL; 84 size_t slen = 0;85 84 86 85 (void)clock_gettime(CLOCK_REALTIME, &pmd->sent_on); 87 86 88 87 /* Is this a forwarded message ? */ 89 CHECK_FCT_DO( fd_msg_source_get(msg, &source, &slen), return );88 CHECK_FCT_DO( fd_msg_source_get(msg, &source, NULL), return ); 90 89 if (source) { 91 90 struct timespec delay; … … 93 92 TS_DIFFERENCE( &delay, &pmd->received_on, &pmd->sent_on ); 94 93 CHECK_MALLOC_DO( fd_msg_dump_summary(&buf, &len, NULL, msg, NULL, 0, 1), return ); 95 LOG_N("[TIMING] FWD %ld.%06ld sec : %s", (long)delay.tv_sec, delay.tv_nsec / 1000, buf);94 LOG_N("[TIMING] FWD %ld.%06ld sec '%s'->'%s': %s", (long)delay.tv_sec, delay.tv_nsec / 1000, source, peer ? peer->info.pi_diamid : "<unidentified>", buf); 96 95 } else if (hdr->msg_flags & CMD_FLAG_REQUEST) { 97 96 /* We are sending a request issued locally, nothing special to log */ … … 103 102 TS_DIFFERENCE( &delay, &qpmd->received_on, &pmd->sent_on ); 104 103 CHECK_MALLOC_DO( fd_msg_dump_summary(&buf, &len, NULL, msg, NULL, 0, 1), return ); 105 LOG_N("[TIMING] ANS %ld.%06ld sec : %s", (long)delay.tv_sec, delay.tv_nsec / 1000, buf);104 LOG_N("[TIMING] ANS %ld.%06ld sec ->'%s': %s", (long)delay.tv_sec, delay.tv_nsec / 1000, peer ? peer->info.pi_diamid : "<unidentified>", buf); 106 105 } 107 106 } -
extensions/dict_mip6a/dict_mip6a.c
r1120 r1121 405 405 struct dict_object * type; 406 406 struct dict_type_data tdata = { AVP_TYPE_INTEGER32, "Enumerated(MIP-Algorithm-Type)", NULL, NULL, NULL }; 407 struct dict_enumval_data t_2 = { "HMAC-SHA-1 ", { .i32 = 2 }};407 struct dict_enumval_data t_2 = { "HMAC-SHA-1 [HMAC]", { .i32 = 2 }}; 408 408 struct dict_avp_data data = { 409 409 345, /* Code */ -
libfdproto/dictionary.c
r1119 r1121 1909 1909 if (ret != 0) { 1910 1910 char * buf = NULL; 1911 size_t len = 0; 1912 1913 CHECK_MALLOC( dict_obj_info[CHECK_TYPE(type) ? type : 0].dump_data(&buf, &len, NULL, data) ); 1911 size_t len = 0, offset=0; 1912 1913 if (type == DICT_ENUMVAL) { 1914 CHECK_MALLOC( dump_enumval_data ( &buf, &len, &offset, data, parent->data.type.type_base )); 1915 } else { 1916 CHECK_MALLOC( dict_obj_info[CHECK_TYPE(type) ? type : 0].dump_data(&buf, &len, &offset, data) ); 1917 } 1918 1914 1919 TRACE_DEBUG(INFO, "An error occurred while adding the following data in the dictionary: %s", buf); 1915 1920 1916 1921 if (ret == EEXIST) { 1917 CHECK_MALLOC( dump_object(&buf, &len, NULL, locref, 0, 0, 0) ); 1922 offset=0; 1923 CHECK_MALLOC( dump_object(&buf, &len, &offset, locref, 0, 0, 0) ); 1918 1924 TRACE_DEBUG(INFO, "Conflicting entry in the dictionary: %s", buf); 1919 1925 } -
libfdproto/messages.c
r1120 r1121 885 885 while (inavp) { 886 886 struct avp * nextavp = NULL; 887 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL);888 887 CHECK_FCT_DO( fd_msg_browse ( inavp, MSG_BRW_NEXT, &nextavp, NULL ), inavp = NULL ); 889 888 CHECK_MALLOC_DO( avp_format_treeview(FD_DUMP_STD_PARAMS, inavp, level + 1, first, nextavp ? 0 : 1), return NULL); -
tests/testmesg_stress.c
r1119 r1121 35 35 36 36 #include "tests.h" 37 #include <dirent.h> 38 #include <libgen.h> 39 #include <dlfcn.h> 40 41 #ifndef BUILD_DIR 42 #error "Missing BUILD_DIR information" 43 #endif /* BUILD_DIR */ 44 37 45 38 46 /* The number of times each operation is repeated to measure the average operation time */ … … 47 55 } 48 56 49 57 struct ext_info { 58 struct fd_list chain; /* link in the list */ 59 void *handler; /* object returned by dlopen() */ 60 int (*init_cb)(int, int, char *); 61 char *ext_name; /* points to the extension name, either inside depends, or basename(filename) */ 62 int free_ext_name; /* must be freed if it was malloc'd */ 63 const char **depends; /* names of the other extensions this one depends on (if provided) */ 64 }; 65 66 static void load_all_extensions(char * prefix) 67 { 68 DIR *dir; 69 struct dirent *dp; 70 char fullname[512]; 71 int pathlen; 72 struct fd_list all_extensions = FD_LIST_INITIALIZER(all_extensions); 73 struct fd_list ext_with_depends = FD_LIST_INITIALIZER(ext_with_depends); 74 75 /* Find all extensions which have been compiled along the test */ 76 LOG_D("Loading %s*.fdx from: '%s'", BUILD_DIR "/extensions", prefix ?: ""); 77 CHECK( 0, (dir = opendir (BUILD_DIR "/extensions")) == NULL ? 1 : 0 ); 78 pathlen = snprintf(fullname, sizeof(fullname), BUILD_DIR "/extensions/"); 79 80 while ((dp = readdir (dir)) != NULL) { 81 char * dot = strrchr(dp->d_name, '.'); 82 if (dot && ((!prefix) || !(strncmp(dp->d_name, prefix, strlen(prefix)))) && (!(strcmp(dot, ".fdx")))) { 83 /* We found a file with name dict_*.fdx, attempt to load it */ 84 struct ext_info * new = malloc(sizeof(struct ext_info)); 85 CHECK( 1, new ? 1:0); 86 fd_list_init(&new->chain, new); 87 88 snprintf(fullname + pathlen, sizeof(fullname) - pathlen, "%s", dp->d_name); 89 90 LOG_D("Extension: '%s'", dp->d_name); 91 92 /* load */ 93 new->handler = dlopen(fullname, RTLD_NOW | RTLD_GLOBAL); 94 if (!new->handler) { 95 TRACE_DEBUG(INFO, "Unable to load '%s': %s.", fullname, dlerror()); 96 } 97 CHECK( 0, new->handler == NULL ? 1 : 0 ); 98 99 /* resolve entry */ 100 new->init_cb = dlsym( new->handler, "fd_ext_init" ); 101 if (!new->init_cb) { 102 TRACE_DEBUG(INFO, "No 'fd_ext_init' entry point in '%s': %s.", fullname, dlerror()); 103 } 104 CHECK( 0, new->init_cb == NULL ? 1 : 0 ); 105 106 new->depends = dlsym( new->handler, "fd_ext_depends" ); 107 if (new->depends) { 108 new->ext_name = (char *)new->depends[0]; 109 new->free_ext_name = 0; 110 if ( new->depends[1] ) { 111 fd_list_insert_before(&ext_with_depends, &new->chain); 112 } else { 113 fd_list_insert_before(&all_extensions, &new->chain); 114 } 115 } else { 116 new->ext_name = strdup(basename(dp->d_name)); 117 new->free_ext_name = 1; 118 fd_list_insert_before(&all_extensions, &new->chain); 119 } 120 121 } 122 } 123 124 /* Now, reorder the list by dependencies */ 125 { 126 int count, prevcount = 0; 127 struct fd_list * li; 128 do { 129 count = 0; 130 for (li=ext_with_depends.next; li != &ext_with_depends; li=li->next) { 131 struct ext_info * e = li->o; 132 int d; 133 int satisfied=0; 134 135 /* Can we satisfy all dependencies? */ 136 for (d=1; ;d++) { 137 struct fd_list * eli; 138 if (!e->depends[d]) { 139 satisfied = 1; 140 break; 141 } 142 143 /* can we find this dependency in the list? */ 144 for (eli=all_extensions.next; eli != &all_extensions; eli = eli->next) { 145 struct ext_info * de = eli->o; 146 if (!strcasecmp(de->ext_name, e->depends[d])) 147 break; /* this dependency is satisfied */ 148 } 149 150 if (eli == &all_extensions) { 151 satisfied = 0; 152 break; 153 } 154 } 155 156 if (satisfied) { 157 /* OK, we have all our dependencies in the list */ 158 li=li->prev; 159 fd_list_unlink(&e->chain); 160 fd_list_insert_before(&all_extensions, &e->chain); 161 } else { 162 count++; 163 } 164 } 165 166 if (prevcount && (prevcount == count)) { 167 LOG_E("Some extensions cannot have their dependencies satisfied, e.g.: %s", ((struct ext_info *)ext_with_depends.next->o)->ext_name); 168 CHECK(0, 1); 169 } 170 prevcount = count; 171 172 if (FD_IS_LIST_EMPTY(&ext_with_depends)) 173 break; 174 } while (1); 175 } 176 177 /* Now, load all the extensions */ 178 { 179 struct fd_list * li; 180 for (li=all_extensions.next; li != &all_extensions; li=li->next) { 181 struct ext_info * e = li->o; 182 int ret = (*e->init_cb)( FD_PROJECT_VERSION_MAJOR, FD_PROJECT_VERSION_MINOR, NULL ); 183 LOG_N("Initializing extension '%s': %s", e->ext_name, ret ? strerror(ret) : "Success"); 184 } 185 } 186 187 /* We should probably clean the list here ? */ 188 } 50 189 51 190 /* Main test routine */ … … 55 194 unsigned char * buf = NULL; 56 195 196 int dictionaries_loaded = 0; 197 57 198 test_parameter = DEFAULT_NUMBER_OF_SAMPLES; 58 199 59 200 /* First, initialize the daemon modules */ 60 201 INIT_FD(); 202 CHECK( 0, fd_queues_init() ); 203 CHECK( 0, fd_msg_init() ); 204 CHECK( 0, fd_rtdisp_init() ); 205 61 206 62 207 { … … 379 524 380 525 /* We have our "buf" now, length is 344 -- cf. testmesg.c. */ 381 526 redo: 382 527 /* Test the throughput of the different functions function */ 383 528 { … … 531 676 free(stress_array); 532 677 } 533 678 679 if (!dictionaries_loaded) { 680 load_all_extensions("dict_"); 681 dictionaries_loaded = 1; 682 printf("Loaded all dictionary extensions, restarting...\n"); 683 goto redo; 684 } 534 685 535 686 /* That's all for the tests yet */
Note: See TracChangeset
for help on using the changeset viewer.