Append 'src' client output buffers into 'dst' client output buffers. * This function clears the output buffers of 'src' */
| 1096 | /* Append 'src' client output buffers into 'dst' client output buffers. |
| 1097 | * This function clears the output buffers of 'src' */ |
| 1098 | void AddReplyFromClient(client *dst, client *src) { |
| 1099 | /* If the source client contains a partial response due to client output |
| 1100 | * buffer limits, propagate that to the dest rather than copy a partial |
| 1101 | * reply. We don't wanna run the risk of copying partial response in case |
| 1102 | * for some reason the output limits don't reach the same decision (maybe |
| 1103 | * they changed) */ |
| 1104 | if (src->flags & CLIENT_CLOSE_ASAP) { |
| 1105 | sds client = catClientInfoString(sdsempty(),dst); |
| 1106 | freeClientAsync(dst); |
| 1107 | serverLog(LL_WARNING,"Client %s scheduled to be closed ASAP for overcoming of output buffer limits.", client); |
| 1108 | sdsfree(client); |
| 1109 | return; |
| 1110 | } |
| 1111 | |
| 1112 | /* First add the static buffer (either into the static buffer or reply list) */ |
| 1113 | addReplyProto(dst,src->buf, src->bufpos); |
| 1114 | |
| 1115 | /* We need to check with prepareClientToWrite again (after addReplyProto) |
| 1116 | * since addReplyProto may have changed something (like CLIENT_CLOSE_ASAP) */ |
| 1117 | if (prepareClientToWrite(dst) != C_OK) |
| 1118 | return; |
| 1119 | |
| 1120 | /* We're bypassing _addReplyProtoToList, so we need to add the pre/post |
| 1121 | * checks in it. */ |
| 1122 | if (dst->flags & CLIENT_CLOSE_AFTER_REPLY) return; |
| 1123 | |
| 1124 | /* Concatenate the reply list into the dest */ |
| 1125 | if (listLength(src->reply)) |
| 1126 | listJoin(dst->reply,src->reply); |
| 1127 | dst->reply_bytes += src->reply_bytes; |
| 1128 | src->reply_bytes = 0; |
| 1129 | src->bufpos = 0; |
| 1130 | |
| 1131 | /* Check output buffer limits */ |
| 1132 | closeClientOnOutputBufferLimitReached(dst, 1); |
| 1133 | } |
| 1134 | |
| 1135 | /* Copy 'src' client output buffers into 'dst' client output buffers. |
| 1136 | * The function takes care of freeing the old output buffers of the |
no test coverage detected