(rd *proto.Reader)
| 932 | } |
| 933 | |
| 934 | func (cmd *ZeroCopyStringCmd) readReply(rd *proto.Reader) error { |
| 935 | // Reset the byte count before reading so a previous successful run |
| 936 | // can't leak its data through Bytes() if this call errors out before |
| 937 | // updating cmd.n. |
| 938 | cmd.n = 0 |
| 939 | if cmd.cloned { |
| 940 | // A cloned ZeroCopyStringCmd has no usable destination buffer |
| 941 | // (see Clone for the rationale). Drain the network reply so the |
| 942 | // connection stays aligned for the next command, then surface a |
| 943 | // clear error rather than silently producing a wrong result. |
| 944 | if err := rd.DiscardNext(); err != nil { |
| 945 | return err |
| 946 | } |
| 947 | return fmt.Errorf("redis: ZeroCopyStringCmd cannot be cloned (cmd writes into caller-owned memory)") |
| 948 | } |
| 949 | n, err := rd.ReadStringInto(cmd.buf) |
| 950 | if err != nil { |
| 951 | return err |
| 952 | } |
| 953 | cmd.n = n |
| 954 | return nil |
| 955 | } |
| 956 | |
| 957 | // NoRetry returns true because the response is written directly into the |
| 958 | // caller's buffer. A retry could leave partial data from a failed attempt in |
nothing calls this directly
no test coverage detected