@@ -2638,14 +2638,14 @@ static int sockpool_place_fd_in_pool(int fd)
26382638 for (int i = 0 ; i < sockpool_fd_count ; i ++ ) {
26392639 struct sockpool_fd_list * sp = & sockpool_fds [i ];
26402640 if (sp -> sockpool_fd == fd ) {
2641- assert (sp -> in_use == 1 );
2641+ // assert(sp->in_use == 1);
26422642 sp -> in_use = 0 ;
26432643 found = 1 ;
26442644 rc = 0 ;
26452645 break ;
26462646 }
26472647 if (sp -> sockpool_fd < 0 && empty_ix == -1 ) {
2648- assert (sp -> in_use == 0 );
2648+ // assert(sp->in_use == 0);
26492649 empty_ix = i ;
26502650 }
26512651 }
@@ -2674,7 +2674,7 @@ static void sockpool_remove_fd(int fd)
26742674 for (int i = 0 ; i < sockpool_fd_count ; i ++ ) {
26752675 struct sockpool_fd_list * sp = & sockpool_fds [i ];
26762676 if (sp -> sockpool_fd == fd ) {
2677- assert (sp -> in_use == 1 );
2677+ // assert(sp->in_use == 1);
26782678 sp -> sockpool_fd = -1 ;
26792679 sp -> in_use = 0 ;
26802680 break ;
@@ -3982,7 +3982,7 @@ static int cdb2portmux_get(cdb2_hndl_tp *hndl, const char *type,
39823982}
39833983
39843984/* try to connect to range from low (inclusive) to high (exclusive) starting with begin */
3985- static inline int cdb2_try_connect_range (cdb2_hndl_tp * hndl , int begin , int low , int high )
3985+ static inline int cdb2_try_connect_range (cdb2_hndl_tp * hndl , int begin , int low , int high , int check_ports )
39863986{
39873987 int max = high - low ;
39883988 /* Starting from `begin', try up to `max' times */
@@ -3992,7 +3992,8 @@ static inline int cdb2_try_connect_range(cdb2_hndl_tp *hndl, int begin, int low,
39923992 i = low ;
39933993
39943994 hndl -> node_seq = i + 1 ;
3995- if (i == hndl -> master || i == hndl -> connected_host || hndl -> hosts_connected [i ] == 1 )
3995+ if (i == hndl -> master || (check_ports && hndl -> ports [i ] <= 0 ) || i == hndl -> connected_host ||
3996+ hndl -> hosts_connected [i ] == 1 )
39963997 continue ;
39973998 if (newsql_connect (hndl , i ) == 0 )
39983999 return 0 ;
@@ -4080,13 +4081,13 @@ static int cdb2_connect_sqlhost(cdb2_hndl_tp *hndl)
40804081 (hndl -> num_hosts_sameroom > 0 )) {
40814082 hndl -> node_seq = getRandomExclude (0 , hndl -> num_hosts_sameroom , hndl -> master );
40824083 /* First try on same room. */
4083- if (0 == cdb2_try_connect_range (hndl , hndl -> node_seq , 0 , hndl -> num_hosts_sameroom ))
4084+ if (0 == cdb2_try_connect_range (hndl , hndl -> node_seq , 0 , hndl -> num_hosts_sameroom , 1 ))
40844085 return 0 ;
40854086 /* If we fail to connect to any of the nodes in our DC, choose a random start point from the other DC */
40864087 hndl -> node_seq = getRandomExclude (hndl -> num_hosts_sameroom , hndl -> num_hosts , hndl -> master );
40874088 }
40884089
4089- if (0 == cdb2_try_connect_range (hndl , hndl -> node_seq , 0 , hndl -> num_hosts ))
4090+ if (0 == cdb2_try_connect_range (hndl , hndl -> node_seq , 0 , hndl -> num_hosts , 0 ))
40904091 return 0 ;
40914092
40924093 if (hndl -> sb == NULL ) {
0 commit comments