7474
7575#define CLIENT_NALLOC 32
7676
77+ const booth_transport_table_t booth__transport ;
78+
7779static int daemonize = 1 ;
7880int enable_stderr = 0 ;
7981timetype start_time ;
8082
83+ static struct booth_config * booth_conf ;
8184
8285/** Structure for "clients".
8386 * Filehandles with incoming data get registered here (and in pollfds),
@@ -104,10 +107,6 @@ typedef enum
104107} BOOTH_DAEMON_STATE ;
105108
106109int poll_timeout ;
107-
108-
109-
110- struct booth_config * booth_conf ;
111110struct command_line cl ;
112111
113112static void client_alloc (void )
@@ -365,7 +364,7 @@ static int setup_config(struct booth_config **conf_pptr, int type)
365364
366365 assert (conf_pptr != NULL );
367366
368- rv = read_config (conf_pptr , cl .configfile , type );
367+ rv = read_config (conf_pptr , & booth__transport , cl .configfile , type );
369368 if (rv < 0 )
370369 goto out ;
371370
@@ -413,17 +412,20 @@ static int setup_config(struct booth_config **conf_pptr, int type)
413412 return rv ;
414413}
415414
416- static int setup_transport (void )
415+ static int setup_transport (struct booth_config * conf_ptr )
417416{
418417 int rv ;
419418
420- rv = transport ()-> init (message_recv );
419+ assert (conf_ptr != NULL && conf_ptr -> transport != NULL );
420+
421+ rv = transport (conf_ptr )-> init (conf_ptr , message_recv );
421422 if (rv < 0 ) {
422- log_error ("failed to init booth_transport %s" , transport ()-> name );
423+ log_error ("failed to init booth_transport %s" ,
424+ transport (conf_ptr )-> name );
423425 goto out ;
424426 }
425427
426- rv = booth_transport [TCP ].init (NULL );
428+ rv = ( * conf_ptr -> transport ) [TCP ].init (conf_ptr , NULL );
427429 if (rv < 0 ) {
428430 log_error ("failed to init booth_transport[TCP]" );
429431 goto out ;
@@ -497,7 +499,7 @@ static int loop(struct booth_config *conf_ptr, int fd)
497499 void (* deadfn ) (int ci );
498500 int rv , i ;
499501
500- rv = setup_transport ();
502+ rv = setup_transport (conf_ptr );
501503 if (rv < 0 )
502504 goto fail ;
503505
@@ -661,6 +663,8 @@ static int query_get_string_answer(struct booth_config *conf_ptr,
661663 size_t msg_size ;
662664 void * request ;
663665
666+ assert (conf_ptr != NULL && conf_ptr -> transport != NULL );
667+
664668 if (cl .type == GEOSTORE ) {
665669 test_reply_f = test_attr_reply ;
666670 msg_size = sizeof (cl .attr_msg );
@@ -683,7 +687,7 @@ static int query_get_string_answer(struct booth_config *conf_ptr,
683687 goto out ;
684688 }
685689
686- tpt = booth_transport + TCP ;
690+ tpt = * conf_ptr -> transport + TCP ;
687691 rv = tpt -> open (site );
688692 if (rv < 0 )
689693 goto out_close ;
@@ -740,6 +744,8 @@ static int do_command(struct booth_config *conf_ptr,
740744 int reply_cnt = 0 , msg_logged = 0 ;
741745 const char * op_str = "" ;
742746
747+ assert (conf_ptr != NULL && conf_ptr -> transport != NULL );
748+
743749 if (cmd == CMD_GRANT )
744750 op_str = "grant" ;
745751 else if (cmd == CMD_REVOKE )
@@ -749,7 +755,7 @@ static int do_command(struct booth_config *conf_ptr,
749755 site = NULL ;
750756
751757 /* Always use TCP for client - at least for now. */
752- tpt = booth_transport + TCP ;
758+ tpt = * conf_ptr -> transport + TCP ;
753759
754760 if (!* cl .site )
755761 site = local ;
0 commit comments