]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Polished.
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 16 May 2008 00:31:16 +0000 (18:31 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 16 May 2008 00:31:16 +0000 (18:31 -0600)
src/adaptation/Message.cc
src/adaptation/Message.h

index 5d7ed767b220cc9e9812bcec7146e613b53dfdda..ee4bac6500bcd053ccdccb4836f08e2175ee7355 100644 (file)
@@ -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());
 }
index 531fec6bd6ac12c33b4215872ee0d12d4318b001..2273c0036deb8bbab8564a4a7fb297d7ae95cecf 100644 (file)
@@ -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