| 175 | } |
| 176 | |
| 177 | int receive_sync_request(int node_id) |
| 178 | { |
| 179 | int i; |
| 180 | lcache_col_t *col; |
| 181 | lcache_entry_t *data; |
| 182 | bin_packet_t *sync_packet; |
| 183 | lcache_t* cache_htable; |
| 184 | |
| 185 | for ( col=lcache_collection; col; col=col->next ) { |
| 186 | LM_DBG("Found collection %.*s\n", col->col_name.len, col->col_name.s); |
| 187 | |
| 188 | if (!col->replicated) |
| 189 | continue; |
| 190 | |
| 191 | cache_htable = col->col_htable->htable; |
| 192 | |
| 193 | for (i =0; i < col->col_htable->size; i++) { |
| 194 | lock_get(&cache_htable[i].lock); |
| 195 | data = cache_htable[i].entries; |
| 196 | while(data) { |
| 197 | if (data->expires == 0 || data->expires > get_ticks()) { |
| 198 | sync_packet = clusterer_api.sync_chunk_start(&cache_repl_cap, |
| 199 | cluster_id, node_id, BIN_VERSION); |
| 200 | if (!sync_packet) { |
| 201 | LM_ERR("Can not create sync packet!\n"); |
| 202 | lock_release(&cache_htable[i].lock); |
| 203 | return -1; |
| 204 | } |
| 205 | bin_push_str(sync_packet, &col->col_name); |
| 206 | bin_push_str(sync_packet, &data->attr); |
| 207 | bin_push_str(sync_packet, &data->value); |
| 208 | bin_push_int(sync_packet, data->expires ? |
| 209 | data->expires - get_ticks() : 0); |
| 210 | } |
| 211 | data = data->next; |
| 212 | } |
| 213 | lock_release(&cache_htable[i].lock); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | void receive_cluster_event(enum clusterer_event ev, int node_id) |
| 221 | { |
no test coverage detected