In Redis commands are always executed in the context of a client, so in * order to load the append only file we need to create a fake client. */
| 685 | /* In Redis commands are always executed in the context of a client, so in |
| 686 | * order to load the append only file we need to create a fake client. */ |
| 687 | struct client *createAOFClient(void) { |
| 688 | struct client *c = zmalloc(sizeof(*c)); |
| 689 | |
| 690 | selectDb(c,0); |
| 691 | c->id = CLIENT_ID_AOF; /* So modules can identify it's the AOF client. */ |
| 692 | c->conn = NULL; |
| 693 | c->name = NULL; |
| 694 | c->querybuf = sdsempty(); |
| 695 | c->querybuf_peak = 0; |
| 696 | c->argc = 0; |
| 697 | c->argv = NULL; |
| 698 | c->original_argc = 0; |
| 699 | c->original_argv = NULL; |
| 700 | c->argv_len_sum = 0; |
| 701 | c->bufpos = 0; |
| 702 | |
| 703 | /* |
| 704 | * The AOF client should never be blocked (unlike master |
| 705 | * replication connection). |
| 706 | * This is because blocking the AOF client might cause |
| 707 | * deadlock (because potentially no one will unblock it). |
| 708 | * Also, if the AOF client will be blocked just for |
| 709 | * background processing there is a chance that the |
| 710 | * command execution order will be violated. |
| 711 | */ |
| 712 | c->flags = CLIENT_DENY_BLOCKING; |
| 713 | |
| 714 | c->btype = BLOCKED_NONE; |
| 715 | /* We set the fake client as a slave waiting for the synchronization |
| 716 | * so that Redis will not try to send replies to this client. */ |
| 717 | c->replstate = SLAVE_STATE_WAIT_BGSAVE_START; |
| 718 | c->reply = listCreate(); |
| 719 | c->reply_bytes = 0; |
| 720 | c->obuf_soft_limit_reached_time = 0; |
| 721 | c->watched_keys = listCreate(); |
| 722 | c->peerid = NULL; |
| 723 | c->sockname = NULL; |
| 724 | c->resp = 2; |
| 725 | c->user = NULL; |
| 726 | listSetFreeMethod(c->reply,freeClientReplyValue); |
| 727 | listSetDupMethod(c->reply,dupClientReplyValue); |
| 728 | initClientMultiState(c); |
| 729 | return c; |
| 730 | } |
| 731 | |
| 732 | void freeFakeClientArgv(struct client *c) { |
| 733 | int j; |
no test coverage detected