Navigation


Changeset 253:ad6c0118fb50 in freeDiameter for freeDiameter/routing_dispatch.c


Ignore:
Timestamp:
Apr 13, 2010, 2:50:54 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Configurable number of server threads

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/routing_dispatch.c

    r241 r253  
    10701070/********************************************************************************/
    10711071
     1072static pthread_t * dispatch = NULL;
     1073static enum thread_state * disp_state = NULL;
     1074
    10721075/* Later: make this more dynamic */
    1073 static pthread_t dispatch = (pthread_t)NULL;
    1074 static enum thread_state disp_state = INITIAL;
    1075 
    10761076static pthread_t rt_out = (pthread_t)NULL;
    10771077static enum thread_state out_state = INITIAL;
     
    10831083int fd_rtdisp_init(void)
    10841084{
    1085         CHECK_POSIX( pthread_create( &dispatch, NULL, dispatch_thr, &disp_state ) );
     1085        int i;
     1086       
     1087        /* Prepare the array for dispatch */
     1088        CHECK_MALLOC( dispatch = calloc(fd_g_config->cnf_dispthr, sizeof(pthread_t)) );
     1089        CHECK_MALLOC( disp_state = calloc(fd_g_config->cnf_dispthr, sizeof(enum thread_state)) );
     1090       
     1091        /* Create the threads */
     1092        for (i=0; i < fd_g_config->cnf_dispthr; i++) {
     1093                CHECK_POSIX( pthread_create( &dispatch[i], NULL, dispatch_thr, &disp_state[i] ) );
     1094        }
    10861095        CHECK_POSIX( pthread_create( &rt_out, NULL, routing_out_thr, &out_state) );
    10871096        CHECK_POSIX( pthread_create( &rt_in,  NULL, routing_in_thr,  &in_state) );
     
    11391148int fd_rtdisp_fini(void)
    11401149{
     1150        int i;
     1151       
    11411152        /* Destroy the incoming queue */
    11421153        CHECK_FCT_DO( fd_queues_fini(&fd_g_incoming), /* ignore */);
     
    11551166       
    11561167        /* Stop the Dispatch thread */
    1157         stop_thread_delayed(&disp_state, &dispatch, "Dispatching");
     1168        for (i=0; i < fd_g_config->cnf_dispthr; i++) {
     1169                stop_thread_delayed(&disp_state[i], &dispatch[i], "Dispatching");
     1170        }
    11581171       
    11591172        return 0;
Note: See TracChangeset for help on using the changeset viewer.