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. */
| 765 | /* In Redis commands are always executed in the context of a client, so in |
| 766 | * order to load the append only file we need to create a fake client. */ |
| 767 | struct client *createAOFClient(void) { |
| 768 | struct client *c = new client(); |
| 769 | |
| 770 | selectDb(c,0); |
| 771 | c->id = CLIENT_ID_AOF; /* So modules can identify it's the AOF client. */ |
| 772 | c->conn = NULL; |
| 773 | c->iel = IDX_EVENT_LOOP_MAIN; |
| 774 | c->name = NULL; |
| 775 | c->querybuf = sdsempty(); |
| 776 | c->querybuf_peak = 0; |
| 777 | c->argc = 0; |
| 778 | c->argv = NULL; |
| 779 | c->original_argc = 0; |
| 780 | c->original_argv = NULL; |
| 781 | c->bufpos = 0; |
| 782 | c->fPendingAsyncWrite = FALSE; |
| 783 | c->fPendingAsyncWriteHandler = FALSE; |
| 784 | |
| 785 | /* |
| 786 | * The AOF client should never be blocked (unlike master |
| 787 | * replication connection). |
| 788 | * This is because blocking the AOF client might cause |
| 789 | * deadlock (because potentially no one will unblock it). |
| 790 | * Also, if the AOF client will be blocked just for |
| 791 | * background processing there is a chance that the |
| 792 | * command execution order will be violated. |
| 793 | */ |
| 794 | c->flags = CLIENT_DENY_BLOCKING; |
| 795 | |
| 796 | c->btype = BLOCKED_NONE; |
| 797 | /* We set the fake client as a replica waiting for the synchronization |
| 798 | * so that Redis will not try to send replies to this client. */ |
| 799 | c->replstate = SLAVE_STATE_WAIT_BGSAVE_START; |
| 800 | c->reply = listCreate(); |
| 801 | c->reply_bytes = 0; |
| 802 | c->obuf_soft_limit_reached_time = 0; |
| 803 | c->watched_keys = listCreate(); |
| 804 | c->peerid = NULL; |
| 805 | c->sockname = NULL; |
| 806 | c->resp = 2; |
| 807 | c->user = NULL; |
| 808 | c->mvccCheckpoint = 0; |
| 809 | listSetFreeMethod(c->reply,freeClientReplyValue); |
| 810 | listSetDupMethod(c->reply,dupClientReplyValue); |
| 811 | fastlock_init(&c->lock, "fake client"); |
| 812 | fastlock_lock(&c->lock); |
| 813 | initClientMultiState(c); |
| 814 | return c; |
| 815 | } |
| 816 | |
| 817 | void freeFakeClientArgv(struct client *c) { |
| 818 | int j; |
no test coverage detected