| 688 | } |
| 689 | |
| 690 | void redisAsyncHandleTimeout(redisAsyncContext *ac) { |
| 691 | redisContext *c = &(ac->c); |
| 692 | redisCallback cb; |
| 693 | |
| 694 | if ((c->flags & REDIS_CONNECTED) && ac->replies.head == NULL) { |
| 695 | /* Nothing to do - just an idle timeout */ |
| 696 | return; |
| 697 | } |
| 698 | |
| 699 | if (!c->err) { |
| 700 | __redisSetError(c, REDIS_ERR_TIMEOUT, "Timeout"); |
| 701 | } |
| 702 | |
| 703 | if (!(c->flags & REDIS_CONNECTED) && ac->onConnect) { |
| 704 | ac->onConnect(ac, REDIS_ERR); |
| 705 | } |
| 706 | |
| 707 | while (__redisShiftCallback(&ac->replies, &cb) == REDIS_OK) { |
| 708 | __redisRunCallback(ac, &cb, NULL); |
| 709 | } |
| 710 | |
| 711 | /** |
| 712 | * TODO: Don't automatically sever the connection, |
| 713 | * rather, allow to ignore <x> responses before the queue is clear |
| 714 | */ |
| 715 | __redisAsyncDisconnect(ac); |
| 716 | } |
| 717 | |
| 718 | /* Sets a pointer to the first argument and its length starting at p. Returns |
| 719 | * the number of bytes to skip to get to the following argument. */ |
no test coverage detected