You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2016/01/12 23:42:52 UTC

[1/2] trafficserver git commit: TS-3072: Debug logging for single connection. Without config control. This closes #398.

Repository: trafficserver
Updated Branches:
  refs/heads/master 500b3c5e0 -> 63bf16f15


TS-3072: Debug logging for single connection. Without config control.  This closes #398.


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

Branch: refs/heads/master
Commit: 45266942b4510f5d06f2af95ea7b8972134ad8f8
Parents: 3a8ee6b
Author: shinrich <sh...@yahoo-inc.com>
Authored: Tue Nov 24 15:08:44 2015 -0600
Committer: shinrich <sh...@yahoo-inc.com>
Committed: Tue Jan 12 16:40:25 2016 -0600

----------------------------------------------------------------------
 iocore/eventsystem/I_Continuation.h |  9 ++++
 iocore/net/UnixNet.cc               |  5 ++
 lib/ts/ContFlags.cc                 | 71 ++++++++++++++++++++++++
 lib/ts/ContFlags.h                  | 93 ++++++++++++++++++++++++++++++++
 lib/ts/Diags.h                      |  9 ++++
 lib/ts/Makefile.am                  |  2 +
 proxy/http/HttpSM.cc                |  3 ++
 7 files changed, 192 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/45266942/iocore/eventsystem/I_Continuation.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/I_Continuation.h b/iocore/eventsystem/I_Continuation.h
index ec7c3f0..9ba78b4 100644
--- a/iocore/eventsystem/I_Continuation.h
+++ b/iocore/eventsystem/I_Continuation.h
@@ -39,6 +39,7 @@
 #include "ts/ink_platform.h"
 #include "ts/List.h"
 #include "I_Lock.h"
+#include "ts/ContFlags.h"
 
 class Continuation;
 class ContinuationQueue;
@@ -128,6 +129,12 @@ public:
   LINK(Continuation, link);
 
   /**
+    Contains values for debug_override and future flags that
+    needs to be thread local while this continuation is running
+  */
+  ContFlags control_flags;
+
+  /**
     Receives the event code and data for an Event.
 
     This function receives the event code and data for an event and
@@ -191,6 +198,8 @@ inline Continuation::Continuation(ProxyMutex *amutex)
 #endif
     mutex(amutex)
 {
+  // Pick up the control flags from the creating thread
+  this->control_flags.set_flags(get_cont_flags().get_flags());
 }
 
 #endif /*_Continuation_h_*/

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/45266942/iocore/net/UnixNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixNet.cc b/iocore/net/UnixNet.cc
index b3a7587..c4405ae 100644
--- a/iocore/net/UnixNet.cc
+++ b/iocore/net/UnixNet.cc
@@ -510,6 +510,8 @@ NetHandler::mainNetEvent(int event, Event *e)
 #if defined(USE_EDGE_TRIGGER)
   // UnixNetVConnection *
   while ((vc = read_ready_list.dequeue())) {
+    // Initialize the thread-local continuation flags
+    set_cont_flags(vc->control_flags);
     if (vc->closed)
       close_UnixNetVConnection(vc, trigger_event->ethread);
     else if (vc->read.enabled && vc->read.triggered)
@@ -526,6 +528,7 @@ NetHandler::mainNetEvent(int event, Event *e)
     }
   }
   while ((vc = write_ready_list.dequeue())) {
+    set_cont_flags(vc->control_flags);
     if (vc->closed)
       close_UnixNetVConnection(vc, trigger_event->ethread);
     else if (vc->write.enabled && vc->write.triggered)
@@ -543,6 +546,7 @@ NetHandler::mainNetEvent(int event, Event *e)
   }
 #else  /* !USE_EDGE_TRIGGER */
   while ((vc = read_ready_list.dequeue())) {
+    diags->set_override(vc->control.debug_override);
     if (vc->closed)
       close_UnixNetVConnection(vc, trigger_event->ethread);
     else if (vc->read.enabled && vc->read.triggered)
@@ -551,6 +555,7 @@ NetHandler::mainNetEvent(int event, Event *e)
       vc->ep.modify(-EVENTIO_READ);
   }
   while ((vc = write_ready_list.dequeue())) {
+    diags->set_override(vc->control.debug_override);
     if (vc->closed)
       close_UnixNetVConnection(vc, trigger_event->ethread);
     else if (vc->write.enabled && vc->write.triggered)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/45266942/lib/ts/ContFlags.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ContFlags.cc b/lib/ts/ContFlags.cc
new file mode 100644
index 0000000..6f564b6
--- /dev/null
+++ b/lib/ts/ContFlags.cc
@@ -0,0 +1,71 @@
+/** @file
+
+  A brief file description
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#include "ContFlags.h"
+
+static ink_thread_key init_thread_key();
+static inkcoreapi ink_thread_key flags_data_key = init_thread_key();
+
+static ink_thread_key
+init_thread_key()
+{
+  ink_thread_key_create(&flags_data_key, NULL);
+  return flags_data_key;
+}
+
+
+/* Set up a cont_flags entry for this threa */
+void
+init_cont_flags()
+{
+  ContFlags new_flags;
+  ink_thread_setspecific(flags_data_key, (void *)new_flags.get_flags());
+}
+
+void
+set_cont_flags(const ContFlags &flags)
+{
+  ink_thread_setspecific(flags_data_key, (void *)flags.get_flags());
+}
+
+void
+set_cont_flag(ContFlags::flags flag_bit, bool value)
+{
+  u_int64_t flags = (u_int64_t)ink_thread_getspecific(flags_data_key);
+  ContFlags new_flags(flags);
+  new_flags.set_flag(flag_bit, value);
+  ink_thread_setspecific(flags_data_key, (void *)new_flags.get_flags());
+}
+
+ContFlags
+get_cont_flags()
+{
+  return ContFlags((u_int64_t)ink_thread_getspecific(flags_data_key));
+}
+
+bool
+get_cont_flag(ContFlags::flags flag_bit)
+{
+  ContFlags flags((u_int64_t)ink_thread_getspecific(flags_data_key));
+  return flags.get_flag(flag_bit);
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/45266942/lib/ts/ContFlags.h
----------------------------------------------------------------------
diff --git a/lib/ts/ContFlags.h b/lib/ts/ContFlags.h
new file mode 100644
index 0000000..f581c81
--- /dev/null
+++ b/lib/ts/ContFlags.h
@@ -0,0 +1,93 @@
+/** @file
+
+  A brief file description
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/****************************************************************************
+
+ ContFlags.h
+
+ Thread local storage for a set of flags that are updated based the continuation
+ currently running in the thread.  These flags are handy if the data is needed
+ as a "global" in parts of the code where the original net VC is not available.
+ Storing the flags in the void * of the thread key directly. I assume we are on
+ at least a 32 bit architecture, so the rawflags size is 32 bits.
+ ****************************************************************************/
+
+#ifndef _CONT_FLAGS_H
+#define _CONT_FLAGS_H
+
+#include "ink_thread.h"
+
+class ContFlags
+{
+public:
+  enum flags { DEBUG_OVERRIDE = 0, DISABLE_PLUGINS = 1, LAST_FLAG };
+
+  ContFlags() : raw_flags(0) {}
+  ContFlags(u_int32_t in_flags) : raw_flags(in_flags) {}
+  void
+  set_flags(u_int32_t new_flags)
+  {
+    raw_flags = new_flags;
+  }
+  ContFlags &operator=(ContFlags const &other)
+  {
+    this->set_flags(other.get_flags());
+    return *this;
+  }
+
+  u_int32_t
+  get_flags() const
+  {
+    return raw_flags;
+  }
+  void
+  set_flag(enum flags flag_bit, bool value)
+  {
+    if (flag_bit >= 0 && flag_bit < LAST_FLAG) {
+      if (value)
+        raw_flags |= (1 << flag_bit);
+      else
+        raw_flags &= ~(1 << flag_bit);
+    }
+  }
+  bool
+  get_flag(enum flags flag_bit) const
+  {
+    if (flag_bit >= 0 && flag_bit < LAST_FLAG) {
+      return (raw_flags & (1 << flag_bit)) != 0;
+    } else {
+      return false;
+    }
+  }
+
+private:
+  u_int32_t raw_flags;
+};
+
+void init_cont_flags();
+void set_cont_flags(const ContFlags &flags);
+void set_cont_flag(ContFlags::flags flag_bit, bool value);
+ContFlags get_cont_flags();
+bool get_cont_flag(ContFlags::flags flag_bit);
+
+#endif // _CONT_FLAGS_H

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/45266942/lib/ts/Diags.h
----------------------------------------------------------------------
diff --git a/lib/ts/Diags.h b/lib/ts/Diags.h
index 9f32465..3338444 100644
--- a/lib/ts/Diags.h
+++ b/lib/ts/Diags.h
@@ -39,6 +39,8 @@
 #include "ink_mutex.h"
 #include "Regex.h"
 #include "ink_apidefs.h"
+#include "ContFlags.h"
+#include "ink_inet.h"
 #include "BaseLogFile.h"
 
 #define DIAGS_MAGIC 0x12345678
@@ -163,6 +165,13 @@ public:
   // conditional debugging //
   ///////////////////////////
 
+
+  bool
+  get_override() const
+  {
+    return get_cont_flag(ContFlags::DEBUG_OVERRIDE);
+  }
+
   bool
   on(DiagsTagType mode = DiagsTagType_Debug) const
   {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/45266942/lib/ts/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/ts/Makefile.am b/lib/ts/Makefile.am
index d151a97..be9ee78 100644
--- a/lib/ts/Makefile.am
+++ b/lib/ts/Makefile.am
@@ -49,6 +49,8 @@ libtsutil_la_SOURCES = \
   Bitops.h \
   ConsistentHash.cc \
   ConsistentHash.h \
+  ContFlags.cc \
+  ContFlags.h \
   Cryptohash.h \
   Diags.cc \
   Diags.h \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/45266942/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 40bb8fe..cc72f6d 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -5619,6 +5619,9 @@ HttpSM::attach_server_session(HttpServerSession *s)
   hsm_release_assert(s->state == HSS_ACTIVE);
   server_session = s;
   server_transact_count = server_session->transact_count++;
+  // Propagate the per client IP debugging
+  if (ua_session)
+    s->get_netvc()->control_flags = get_cont_flags();
 
   // Set the mutex so that we have something to update
   //   stats with


[2/2] trafficserver git commit: Merge branch 'pr/398'

Posted by sh...@apache.org.
Merge branch 'pr/398'


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

Branch: refs/heads/master
Commit: 63bf16f153594ea6f5b4a903e6ede6bd6360360a
Parents: 500b3c5 4526694
Author: shinrich <sh...@yahoo-inc.com>
Authored: Tue Jan 12 16:42:08 2016 -0600
Committer: shinrich <sh...@yahoo-inc.com>
Committed: Tue Jan 12 16:42:08 2016 -0600

----------------------------------------------------------------------
 iocore/eventsystem/I_Continuation.h |  9 ++++
 iocore/net/UnixNet.cc               |  5 ++
 lib/ts/ContFlags.cc                 | 71 ++++++++++++++++++++++++
 lib/ts/ContFlags.h                  | 93 ++++++++++++++++++++++++++++++++
 lib/ts/Diags.h                      |  9 ++++
 lib/ts/Makefile.am                  |  2 +
 proxy/http/HttpSM.cc                |  3 ++
 7 files changed, 192 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63bf16f1/iocore/net/UnixNet.cc
----------------------------------------------------------------------