Changeset 1397:239ba25870d8 in freeDiameter for libfdcore/routing_dispatch.c
- Timestamp:
- Nov 15, 2019, 7:40:37 PM (4 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/routing_dispatch.c
r1328 r1397 35 35 36 36 #include "fdcore-internal.h" 37 38 #ifdef linux 39 /* This needs -D_USE_GNU, and since I have no idea what else that does, let's simply copy the declaration. */ 40 41 /* Set thread name visible in the kernel and its interfaces. */ 42 extern int pthread_setname_np (pthread_t __target_thread, const char *__name); 43 #endif 37 44 38 45 /********************************************************************************/ … … 1153 1160 static enum thread_state * disp_state = NULL; 1154 1161 1155 /* Later: make this more dynamic */ 1156 static pthread_t rt_out = (pthread_t)NULL; 1157 static enum thread_state out_state = NOTRUNNING; 1158 1159 static pthread_t rt_in = (pthread_t)NULL; 1160 static enum thread_state in_state = NOTRUNNING; 1162 static pthread_t * rt_out = NULL; 1163 static enum thread_state * out_state = NULL; 1164 1165 static pthread_t * rt_in = NULL; 1166 static enum thread_state * in_state = NULL; 1161 1167 1162 1168 /* Initialize the routing and dispatch threads */ … … 1165 1171 int i; 1166 1172 1167 /* Prepare the array for dispatch*/1173 /* Prepare the array for threads */ 1168 1174 CHECK_MALLOC( disp_state = calloc(fd_g_config->cnf_dispthr, sizeof(enum thread_state)) ); 1169 1175 CHECK_MALLOC( dispatch = calloc(fd_g_config->cnf_dispthr, sizeof(pthread_t)) ); 1176 CHECK_MALLOC( out_state = calloc(fd_g_config->cnf_rtoutthr, sizeof(enum thread_state)) ); 1177 CHECK_MALLOC( rt_out = calloc(fd_g_config->cnf_rtoutthr, sizeof(pthread_t)) ); 1178 CHECK_MALLOC( in_state = calloc(fd_g_config->cnf_rtinthr, sizeof(enum thread_state)) ); 1179 CHECK_MALLOC( rt_in = calloc(fd_g_config->cnf_rtinthr, sizeof(pthread_t)) ); 1170 1180 1171 1181 /* Create the threads */ 1172 1182 for (i=0; i < fd_g_config->cnf_dispthr; i++) { 1173 1183 CHECK_POSIX( pthread_create( &dispatch[i], NULL, dispatch_thr, &disp_state[i] ) ); 1174 } 1175 CHECK_POSIX( pthread_create( &rt_out, NULL, routing_out_thr, &out_state) ); 1176 CHECK_POSIX( pthread_create( &rt_in, NULL, routing_in_thr, &in_state) ); 1184 #ifdef linux 1185 pthread_setname_np(dispatch[i], "fd-dispatch"); 1186 #endif 1187 } 1188 for (i=0; i < fd_g_config->cnf_rtoutthr; i++) { 1189 CHECK_POSIX( pthread_create( &rt_out[i], NULL, routing_out_thr, &out_state[i] ) ); 1190 #ifdef linux 1191 pthread_setname_np(rt_out[i], "fd-routing-out"); 1192 #endif 1193 } 1194 for (i=0; i < fd_g_config->cnf_rtinthr; i++) { 1195 CHECK_POSIX( pthread_create( &rt_in[i], NULL, routing_in_thr, &in_state[i] ) ); 1196 #ifdef linux 1197 pthread_setname_np(rt_in[i], "fd-routing-in"); 1198 #endif 1199 } 1177 1200 1178 1201 /* Later: TODO("Set the thresholds for the queues to create more threads as needed"); */ … … 1245 1268 1246 1269 /* Stop the routing IN thread */ 1247 stop_thread_delayed(&in_state, &rt_in, "IN routing"); 1270 if (rt_in != NULL) { 1271 for (i=0; i < fd_g_config->cnf_rtinthr; i++) { 1272 stop_thread_delayed(&in_state[i], &rt_in[i], "IN routing"); 1273 } 1274 free(rt_in); 1275 rt_in = NULL; 1276 } 1277 if (in_state != NULL) { 1278 free(in_state); 1279 in_state = NULL; 1280 } 1248 1281 1249 1282 /* Destroy the outgoing queue */ … … 1251 1284 1252 1285 /* Stop the routing OUT thread */ 1253 stop_thread_delayed(&out_state, &rt_out, "OUT routing"); 1286 if (rt_out != NULL) { 1287 for (i=0; i < fd_g_config->cnf_rtinthr; i++) { 1288 stop_thread_delayed(&out_state[i], &rt_out[i], "OUT routing"); 1289 } 1290 free(rt_out); 1291 rt_out = NULL; 1292 } 1293 if (out_state != NULL) { 1294 free(out_state); 1295 out_state = NULL; 1296 } 1254 1297 1255 1298 /* Destroy the local queue */
Note: See TracChangeset
for help on using the changeset viewer.