| 61 | } |
| 62 | |
| 63 | static int get_sync_source(cluster_info_t *cluster, str *capability, |
| 64 | enum cl_node_match_op match_cond) |
| 65 | { |
| 66 | node_info_t *node; |
| 67 | struct remote_cap *cap; |
| 68 | |
| 69 | for (node = cluster->node_list; node; node = node->next) { |
| 70 | if (get_next_hop(node) == 0) |
| 71 | continue; |
| 72 | |
| 73 | if (!match_node(cluster->current_node, node, match_cond)) |
| 74 | continue; |
| 75 | |
| 76 | lock_get(node->lock); |
| 77 | for (cap = node->capabilities; cap; cap = cap->next) |
| 78 | if (!str_strcmp(capability, &cap->name)) |
| 79 | break; |
| 80 | |
| 81 | /* if the node does have the capability and it's in the OK state |
| 82 | * then it can be a source for syncing */ |
| 83 | if (cap && cap->flags & CAP_STATE_OK) { |
| 84 | lock_release(node->lock); |
| 85 | return node->node_id; |
| 86 | } |
| 87 | |
| 88 | lock_release(node->lock); |
| 89 | } |
| 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | int queue_sync_request(cluster_info_t *cluster, struct local_cap *lcap) |
| 95 | { |
no test coverage detected