@@ -801,20 +801,34 @@ get_main_control()
801
801
return main_ctl ;
802
802
}
803
803
804
- void
805
- start_login_frp_server (struct event_base * base )
806
- {
804
+ static int init_frp_connection (struct bufferevent * * bev_out , struct event_base * base ) {
807
805
struct common_conf * c_conf = get_common_config ();
806
+ if (!c_conf ) {
807
+ debug (LOG_ERR , "Failed to get common config" );
808
+ return -1 ;
809
+ }
810
+
808
811
struct bufferevent * bev = connect_server (base , c_conf -> server_addr , c_conf -> server_port );
809
812
if (!bev ) {
810
- debug (LOG_DEBUG ,
811
- "Connect server [%s:%d] failed" ,
812
- c_conf -> server_addr ,
813
- c_conf -> server_port );
813
+ debug (LOG_ERR , "Failed to connect to server [%s:%d]" ,
814
+ c_conf -> server_addr , c_conf -> server_port );
815
+ return -1 ;
816
+ }
817
+
818
+ * bev_out = bev ;
819
+ return 0 ;
820
+ }
821
+
822
+ void start_login_frp_server (struct event_base * base )
823
+ {
824
+ struct bufferevent * bev = NULL ;
825
+ if (init_frp_connection (& bev , base ) != 0 ) {
814
826
return ;
815
827
}
816
828
817
- debug (LOG_INFO , "Xfrpc login: connect server [%s:%d] ..." , c_conf -> server_addr , c_conf -> server_port );
829
+ struct common_conf * c_conf = get_common_config ();
830
+ debug (LOG_INFO , "Xfrpc login: connecting to server [%s:%d]..." ,
831
+ c_conf -> server_addr , c_conf -> server_port );
818
832
819
833
bufferevent_enable (bev , EV_WRITE |EV_READ );
820
834
bufferevent_setcb (bev , NULL , NULL , connect_event_cb , NULL );
0 commit comments