| 3791 | } |
| 3792 | |
| 3793 | static void parse_dbresponse(CDB2DBINFORESPONSE *dbinfo_response, char valid_hosts[][CDB2HOSTNAME_LEN], |
| 3794 | int *valid_ports, int *master_node, int *num_valid_hosts, int *num_valid_sameroom_hosts, |
| 3795 | int debug_trace, peer_ssl_mode *s_mode) |
| 3796 | { |
| 3797 | if (log_calls) |
| 3798 | fprintf(stderr, "td %" PRIxPTR "%s:%d\n", (intptr_t)pthread_self(), __func__, |
| 3799 | __LINE__); |
| 3800 | int num_hosts = dbinfo_response->n_nodes; |
| 3801 | *num_valid_hosts = 0; |
| 3802 | if (num_valid_sameroom_hosts) |
| 3803 | *num_valid_sameroom_hosts = 0; |
| 3804 | int myroom = 0; |
| 3805 | int i = 0; |
| 3806 | |
| 3807 | if (debug_trace) { |
| 3808 | /* Print a list of nodes received via dbinforesponse. */ |
| 3809 | fprintf(stderr, "dbinforesponse:\n%s (master)\n", |
| 3810 | dbinfo_response->master->name); |
| 3811 | for (i = 0; i < num_hosts; i++) { |
| 3812 | CDB2DBINFORESPONSE__Nodeinfo *currnode = dbinfo_response->nodes[i]; |
| 3813 | if (strcmp(dbinfo_response->master->name, currnode->name) == 0) { |
| 3814 | continue; |
| 3815 | } |
| 3816 | fprintf(stderr, "%s\n", currnode->name); |
| 3817 | } |
| 3818 | } |
| 3819 | |
| 3820 | for (i = 0; i < num_hosts; i++) { |
| 3821 | CDB2DBINFORESPONSE__Nodeinfo *currnode = dbinfo_response->nodes[i]; |
| 3822 | if (!myroom) { |
| 3823 | if (currnode->has_room) { |
| 3824 | myroom = currnode->room; |
| 3825 | } else { |
| 3826 | myroom = -1; |
| 3827 | } |
| 3828 | } |
| 3829 | if (currnode->incoherent) |
| 3830 | continue; |
| 3831 | |
| 3832 | if (strlen(currnode->name) >= CDB2HOSTNAME_LEN) |
| 3833 | continue; |
| 3834 | |
| 3835 | strncpy(valid_hosts[*num_valid_hosts], currnode->name, CDB2HOSTNAME_LEN); |
| 3836 | if (currnode->has_port) { |
| 3837 | valid_ports[*num_valid_hosts] = currnode->port; |
| 3838 | } else { |
| 3839 | valid_ports[*num_valid_hosts] = -1; |
| 3840 | } |
| 3841 | if (strcmp(currnode->name, dbinfo_response->master->name) == 0) |
| 3842 | *master_node = *num_valid_hosts; |
| 3843 | |
| 3844 | if (log_calls) |
| 3845 | fprintf(stderr, "td %" PRIxPTR "%s:%d, %d) host=%s(%d)%s\n", |
| 3846 | (intptr_t) pthread_self(), __func__, __LINE__, |
| 3847 | *num_valid_hosts, valid_hosts[*num_valid_hosts], |
| 3848 | valid_ports[*num_valid_hosts], |
| 3849 | (*master_node == *num_valid_hosts) ? "*" : ""); |
| 3850 |
no outgoing calls
no test coverage detected