Append 'src' client output buffers into 'dst' client output buffers. * This function clears the output buffers of 'src' */
| 933 | /* Append 'src' client output buffers into 'dst' client output buffers. |
| 934 | * This function clears the output buffers of 'src' */ |
| 935 | void AddReplyFromClient(client *dst, client *src) { |
| 936 | /* If the source client contains a partial response due to client output |
| 937 | * buffer limits, propagate that to the dest rather than copy a partial |
| 938 | * reply. We don't wanna run the risk of copying partial response in case |
| 939 | * for some reason the output limits don't reach the same decision (maybe |
| 940 | * they changed) */ |
| 941 | if (src->flags & CLIENT_CLOSE_ASAP) { |
| 942 | sds client = catClientInfoString(sdsempty(),dst); |
| 943 | freeClientAsync(dst); |
| 944 | serverLog(LL_WARNING,"Client %s scheduled to be closed ASAP for overcoming of output buffer limits.", client); |
| 945 | sdsfree(client); |
| 946 | return; |
| 947 | } |
| 948 | |
| 949 | /* First add the static buffer (either into the static buffer or reply list) */ |
| 950 | addReplyProto(dst,src->buf, src->bufpos); |
| 951 | |
| 952 | /* We need to check with prepareClientToWrite again (after addReplyProto) |
| 953 | * since addReplyProto may have changed something (like CLIENT_CLOSE_ASAP) */ |
| 954 | if (prepareClientToWrite(dst) != C_OK) |
| 955 | return; |
| 956 | |
| 957 | /* We're bypassing _addReplyProtoToList, so we need to add the pre/post |
| 958 | * checks in it. */ |
| 959 | if (dst->flags & CLIENT_CLOSE_AFTER_REPLY) return; |
| 960 | |
| 961 | /* Concatenate the reply list into the dest */ |
| 962 | if (listLength(src->reply)) |
| 963 | listJoin(dst->reply,src->reply); |
| 964 | dst->reply_bytes += src->reply_bytes; |
| 965 | src->reply_bytes = 0; |
| 966 | src->bufpos = 0; |
| 967 | |
| 968 | /* Check output buffer limits */ |
| 969 | closeClientOnOutputBufferLimitReached(dst, 1); |
| 970 | } |
| 971 | |
| 972 | /* Copy 'src' client output buffers into 'dst' client output buffers. |
| 973 | * The function takes care of freeing the old output buffers of the |
no test coverage detected