From: Alex Rousskov Date: Fri, 16 May 2008 00:31:16 +0000 (-0600) Subject: Polished. X-Git-Tag: SQUID_3_1_0_1~45^2~11^2~24^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1649fbab176e2af377bc9b45023ad81d58d090e;p=thirdparty%2Fsquid.git Polished. --- diff --git a/src/adaptation/Message.cc b/src/adaptation/Message.cc index 5d7ed767b2..ee4bac6500 100644 --- a/src/adaptation/Message.cc +++ b/src/adaptation/Message.cc @@ -39,20 +39,19 @@ Adaptation::Message::set(Header *aHeader) } void -Adaptation::Message::copyTo(Message &dest) +Adaptation::Message::ShortCircuit(Message &src, Message &dest) { - Must(!dest.body_pipe); // can relax if needed, but need !body_pipe->used() - dest.clear(); - if (header) { - if (header->body_pipe != NULL) { - // check that it would not be too late to clone the pipe - Must(!header->body_pipe->consumedSize()); - header->body_pipe->clearConsumer(); // if any - // note: current header->body_pipe producer may later become - // dest.body_pipe consumer and consume its own data - // TODO: consumer should detect and short-circuit no-op adaptation - } - Header *copy = header->clone(); - dest.set(copy); + Must(!dest.header); // the message is not "used" + Must(!dest.body_pipe); // can relax if needed, but need !body_pipe->used() + Must(src.header); // or there is nothing to shortcircuit + + if (src.header->body_pipe != NULL) { + // check that it would not be too late to shortcircuit the pipe + Must(!src.header->body_pipe->consumedSize()); + src.header->body_pipe->clearConsumer(); // if any + // note: current header->body_pipe producer may later become + // dest.body_pipe consumer and consume its own data + // TODO: consumer should detect and bypass short-circuit adaptation } + dest.set(src.header->clone()); } diff --git a/src/adaptation/Message.h b/src/adaptation/Message.h index 531fec6bd6..2273c0036d 100644 --- a/src/adaptation/Message.h +++ b/src/adaptation/Message.h @@ -16,6 +16,8 @@ namespace Adaptation { // Manages the header and the body of an HTTP message being worked on. // Adaptation transactions use this class for virgin and adapted HTTP messages. +// TODO: remove this class after adding refcounted message pointers and +// after making sure nobody abruptly clears the HttpMsg::body_pipe pointer. class Message { @@ -29,7 +31,7 @@ public: void clear(); void set(Header *aHeader); - void copyTo(Message &dest); + static void ShortCircuit(Message &src, Message &dest); public: // virgin or adapted message being worked on