Changeset 686:f83d9878bf66 in freeDiameter for libfdcore/routing_dispatch.c
- Timestamp:
- Jan 19, 2011, 2:35:14 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/routing_dispatch.c
r662 r686 973 973 974 974 /* Threads report their status */ 975 enum thread_state { INITIAL = 0, RUNNING = 1, TERMINATED = 2};975 enum thread_state { NOTRUNNING = 0, RUNNING = 1 }; 976 976 static void cleanup_state(void * state_loc) 977 977 { 978 978 if (state_loc) 979 *(enum thread_state *)state_loc = TERMINATED;979 *(enum thread_state *)state_loc = NOTRUNNING; 980 980 } 981 981 … … 1080 1080 /* Later: make this more dynamic */ 1081 1081 static pthread_t rt_out = (pthread_t)NULL; 1082 static enum thread_state out_state = INITIAL;1082 static enum thread_state out_state = NOTRUNNING; 1083 1083 1084 1084 static pthread_t rt_in = (pthread_t)NULL; 1085 static enum thread_state in_state = INITIAL;1085 static enum thread_state in_state = NOTRUNNING; 1086 1086 1087 1087 /* Initialize the routing and dispatch threads */ … … 1091 1091 1092 1092 /* Prepare the array for dispatch */ 1093 CHECK_MALLOC( disp_state = calloc(fd_g_config->cnf_dispthr, sizeof(enum thread_state)) ); 1093 1094 CHECK_MALLOC( dispatch = calloc(fd_g_config->cnf_dispthr, sizeof(pthread_t)) ); 1094 CHECK_MALLOC( disp_state = calloc(fd_g_config->cnf_dispthr, sizeof(enum thread_state)) );1095 1095 1096 1096 /* Create the threads */ … … 1126 1126 /* Wait for a second for the thread to complete, by monitoring my_state */ 1127 1127 fd_cpu_flush_cache(); 1128 if (*st != TERMINATED) {1128 if (*st != NOTRUNNING) { 1129 1129 TRACE_DEBUG(INFO, "Waiting for the %s thread to have a chance to terminate", th_name); 1130 1130 do { … … 1137 1137 1138 1138 while (TS_IS_INFERIOR( &ts, &ts_final )) { 1139 if (*st == TERMINATED) 1139 fd_cpu_flush_cache(); 1140 if (*st == NOTRUNNING) 1140 1141 break; 1141 1142 … … 1171 1172 CHECK_FCT_DO( fd_queues_fini(&fd_g_local), /* ignore */); 1172 1173 1173 /* Stop the Dispatch thread */ 1174 for (i=0; i < fd_g_config->cnf_dispthr; i++) { 1175 stop_thread_delayed(&disp_state[i], &dispatch[i], "Dispatching"); 1174 /* Stop the Dispatch threads */ 1175 if (dispatch != NULL) { 1176 for (i=0; i < fd_g_config->cnf_dispthr; i++) { 1177 stop_thread_delayed(&disp_state[i], &dispatch[i], "Dispatching"); 1178 } 1179 free(dispatch); 1180 dispatch = NULL; 1181 } 1182 if (disp_state != NULL) { 1183 free(disp_state); 1184 disp_state = NULL; 1176 1185 } 1177 1186
Note: See TracChangeset
for help on using the changeset viewer.