| 277 | } |
| 278 | |
| 279 | redis_client* redis_client_cluster::peek_conn(int slot) |
| 280 | { |
| 281 | // ����Ѿ������˹�ϣ��ֵ�������ȴӱ��ػ����в��Ҷ�Ӧ�����ӳ� |
| 282 | // ���δ�ҵ���������м�Ⱥ����������һ�����õ����ӳض��� |
| 283 | |
| 284 | redis_client_pool* conns; |
| 285 | redis_client* conn; |
| 286 | int i = 0; |
| 287 | |
| 288 | while (i++ < 5) { |
| 289 | if (slot < 0) { |
| 290 | conns = (redis_client_pool*) this->peek(); |
| 291 | } else if ((conns = peek_slot(slot)) == NULL) { |
| 292 | conns = (redis_client_pool*) this->peek(); |
| 293 | } |
| 294 | |
| 295 | if (conns == NULL) { |
| 296 | slot = -1; |
| 297 | continue; |
| 298 | } |
| 299 | |
| 300 | conn = (redis_client*) conns->peek(); |
| 301 | if (conn != NULL) { |
| 302 | return conn; |
| 303 | } |
| 304 | |
| 305 | // ȡ����ϣ�۵ĵ�ַӳ���ϵ |
| 306 | clear_slot(slot); |
| 307 | |
| 308 | #ifdef AUTO_SET_ALIVE |
| 309 | // �����ӳض�����Ϊ������״̬ |
| 310 | conns->set_alive(false); |
| 311 | #endif |
| 312 | } |
| 313 | |
| 314 | logger_warn("too many retry: %d, slot: %d", i, slot); |
| 315 | return NULL; |
| 316 | } |
| 317 | |
| 318 | redis_client* redis_client_cluster::reopen(redis_command& cmd, |
| 319 | redis_client* conn) |