You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by su...@apache.org on 2016/02/01 19:03:30 UTC

[3/4] trafficserver git commit: [TS-4135] reset handles to null if getter fails

[TS-4135] reset handles to null if getter fails


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/919de4cc
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/919de4cc
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/919de4cc

Branch: refs/heads/master
Commit: 919de4cc8daa5ee739aa7993b9de59dd72530ee0
Parents: ef31c38
Author: Sandeep Davu <sd...@sniffcliff.corp.ne1.yahoo.com>
Authored: Fri Jan 29 20:48:02 2016 +0000
Committer: Sudheer Vinukonda <su...@yahoo-inc.com>
Committed: Mon Feb 1 18:03:17 2016 +0000

----------------------------------------------------------------------
 lib/atscppapi/src/Request.cc                   | 10 ++++++++++
 lib/atscppapi/src/Response.cc                  |  9 +++++++++
 lib/atscppapi/src/Transaction.cc               | 15 +++++++++++++++
 lib/atscppapi/src/include/atscppapi/Request.h  |  1 +
 lib/atscppapi/src/include/atscppapi/Response.h |  1 +
 5 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/919de4cc/lib/atscppapi/src/Request.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/Request.cc b/lib/atscppapi/src/Request.cc
index 250f4f5..714ac93 100644
--- a/lib/atscppapi/src/Request.cc
+++ b/lib/atscppapi/src/Request.cc
@@ -97,6 +97,16 @@ Request::init(void *hdr_buf, void *hdr_loc)
   }
 }
 
+void
+Request::reset()
+{
+  state_->hdr_buf_ = NULL;
+  state_->hdr_loc_ = NULL;
+  state_->headers_.reset(NULL, NULL);
+  state_->url_loc_ = NULL;
+  LOG_DEBUG("Reset request %p", this);
+}
+
 HttpMethod
 Request::getMethod() const
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/919de4cc/lib/atscppapi/src/Response.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/Response.cc b/lib/atscppapi/src/Response.cc
index b60d4f1..823986f 100644
--- a/lib/atscppapi/src/Response.cc
+++ b/lib/atscppapi/src/Response.cc
@@ -54,6 +54,15 @@ Response::init(void *hdr_buf, void *hdr_loc)
   LOG_DEBUG("Initializing response %p with hdr_buf=%p and hdr_loc=%p", this, state_->hdr_buf_, state_->hdr_loc_);
 }
 
+void
+Response::reset()
+{
+  state_->hdr_buf_ = NULL;
+  state_->hdr_loc_ = NULL;
+  state_->headers_.reset(NULL, NULL);
+  LOG_DEBUG("Reset response %p", this);
+}
+
 HttpVersion
 Response::getVersion() const
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/919de4cc/lib/atscppapi/src/Transaction.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/Transaction.cc b/lib/atscppapi/src/Transaction.cc
index 8790c00..3f1b0a8 100644
--- a/lib/atscppapi/src/Transaction.cc
+++ b/lib/atscppapi/src/Transaction.cc
@@ -435,6 +435,9 @@ Transaction::initServerRequest()
                                      "server request")) {
     LOG_DEBUG("Initializing server request");
     state_->server_request_.init(state_->server_request_hdr_buf_, state_->server_request_hdr_loc_);
+  } else {
+    LOG_DEBUG("Reset server request");
+    state_->server_request_.reset();
   }
 }
 
@@ -446,6 +449,9 @@ Transaction::initServerResponse()
                                       "server response")) {
     LOG_DEBUG("Initializing server response");
     state_->server_response_.init(state_->server_response_hdr_buf_, state_->server_response_hdr_loc_);
+  } else {
+    LOG_DEBUG("Reset server response");
+    state_->server_response_.reset();
   }
 }
 
@@ -457,6 +463,9 @@ Transaction::initClientResponse()
                                       "client response")) {
     LOG_DEBUG("Initializing client response");
     state_->client_response_.init(state_->client_response_hdr_buf_, state_->client_response_hdr_loc_);
+  } else {
+    LOG_DEBUG("Reset client response");
+    state_->client_response_.reset();
   }
 }
 
@@ -468,6 +477,9 @@ Transaction::initCachedRequest()
                                      "cached request")) {
     LOG_DEBUG("Initializing cached request");
     state_->cached_request_.init(state_->cached_request_hdr_buf_, state_->cached_request_hdr_loc_);
+  } else {
+    LOG_DEBUG("Reset cached request");
+    state_->cached_request_.reset();
   }
 }
 
@@ -479,5 +491,8 @@ Transaction::initCachedResponse()
                                       "cached response")) {
     LOG_DEBUG("Initializing cached response");
     state_->cached_response_.init(state_->cached_response_hdr_buf_, state_->cached_response_hdr_loc_);
+  } else {
+    LOG_DEBUG("Reset cached response");
+    state_->cached_response_.reset();
   }
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/919de4cc/lib/atscppapi/src/include/atscppapi/Request.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Request.h b/lib/atscppapi/src/include/atscppapi/Request.h
index bfe1b0a..25ab332 100644
--- a/lib/atscppapi/src/include/atscppapi/Request.h
+++ b/lib/atscppapi/src/include/atscppapi/Request.h
@@ -65,6 +65,7 @@ private:
   Request(void *hdr_buf, void *hdr_loc);
   RequestState *state_;
   void init(void *hdr_buf, void *hdr_loc);
+  void reset();
   friend class Transaction;
   friend class ClientRequest;
 };

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/919de4cc/lib/atscppapi/src/include/atscppapi/Response.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Response.h b/lib/atscppapi/src/include/atscppapi/Response.h
index 5b8582d..741d709 100644
--- a/lib/atscppapi/src/include/atscppapi/Response.h
+++ b/lib/atscppapi/src/include/atscppapi/Response.h
@@ -67,6 +67,7 @@ public:
 private:
   ResponseState *state_;
   void init(void *hdr_buf, void *hdr_loc);
+  void reset();
   friend class Transaction;
   friend class utils::internal;
 };