[trafficserver] branch quic-latest updated: Clear tracked event in the begnning of the event procedure

2017-09-14 Thread masaori
This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/quic-latest by this push:
 new 1eb074f  Clear tracked event in the begnning of the event procedure
1eb074f is described below

commit 1eb074fa2a96ded10371cee3e7ad991b17659887
Author: Masaori Koshiba 
AuthorDate: Fri Sep 15 12:28:53 2017 +0900

Clear tracked event in the begnning of the event procedure

- Clear tracked event in the begnning of the event procedure
- Add interal version of transmit_frame() and transmit_packet()

The methods from QUICPacketTransmitter and QUICFrameTransmitter could be 
called
from QUICApplication. In that cases, PACKET_WRITE_READY event should be 
scheduled
(if there're no tracked event). OTOH, internally called enqueue and dequeue 
frames
or packets should not schedule event. So this change separate the methods 
for
internal and external, and clear tracked event in the beggining.
---
 iocore/net/P_QUICNetVConnection.h |  3 +++
 iocore/net/QUICNetVConnection.cc  | 47 +++
 iocore/net/quic/QUICPacket.h  |  1 +
 3 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/iocore/net/P_QUICNetVConnection.h 
b/iocore/net/P_QUICNetVConnection.h
index b29d2d6..9bb2b1a 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -223,6 +223,9 @@ private:
 
   Event *_packet_write_ready = nullptr;
 
+  void _transmit_packet(QUICPacketPtr);
+  void _transmit_frame(QUICFramePtr);
+
   void _packetize_frames();
   std::unique_ptr 
_build_packet(ats_unique_buf buf, size_t len, bool retransmittable,

QUICPacketType type = QUICPacketType::UNINITIALIZED);
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index aefd28c..56246df 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -197,10 +197,19 @@ QUICNetVConnection::maximum_stream_frame_data_size()
 }
 
 void
-QUICNetVConnection::transmit_packet(std::unique_ptr packet)
+QUICNetVConnection::_transmit_packet(QUICPacketPtr packet)
 {
+  DebugQUICCon("Packet Type=%s Size=%hu", 
QUICDebugNames::packet_type(packet->type()), packet->size());
+
+  SCOPED_MUTEX_LOCK(packet_transmitter_lock, this->_packet_transmitter_mutex, 
this_ethread());
   // TODO Remove const_cast
   this->_packet_send_queue.enqueue(const_cast(packet.release()));
+}
+
+void
+QUICNetVConnection::transmit_packet(std::unique_ptr packet)
+{
+  this->_transmit_packet(std::move(packet));
   if (!this->_packet_write_ready) {
 this->_packet_write_ready = eventProcessor.schedule_imm(this, ET_CALL, 
QUIC_EVENT_PACKET_WRITE_READY, nullptr);
   }
@@ -246,13 +255,20 @@ 
QUICNetVConnection::push_packet(std::unique_ptr frame)
+QUICNetVConnection::_transmit_frame(QUICFramePtr frame)
 {
-  DebugQUICCon("Type=%s Size=%zu", QUICDebugNames::frame_type(frame->type()), 
frame->size());
+  DebugQUICCon("Frame Type=%s Size=%zu", 
QUICDebugNames::frame_type(frame->type()), frame->size());
 
   SCOPED_MUTEX_LOCK(frame_transmitter_lock, this->_frame_transmitter_mutex, 
this_ethread());
   this->_frame_send_queue.push(std::move(frame));
+}
+
+void
+QUICNetVConnection::transmit_frame(std::unique_ptr frame)
+{
+  this->_transmit_frame(std::move(frame));
   if (!this->_packet_write_ready) {
+DebugQUICCon("Schedule %s event", 
QUICDebugNames::quic_event(QUIC_EVENT_PACKET_WRITE_READY));
 this->_packet_write_ready = eventProcessor.schedule_imm(this, ET_CALL, 
QUIC_EVENT_PACKET_WRITE_READY, nullptr);
   }
 }
@@ -362,8 +378,10 @@ QUICNetVConnection::state_handshake(int event, Event *data)
 break;
   }
   case QUIC_EVENT_PACKET_WRITE_READY: {
-error = this->_state_common_send_packet();
-this->_packet_write_ready = nullptr;
+if (this->_packet_write_ready == data) {
+  this->_packet_write_ready = nullptr;
+}
+error = this->_state_common_send_packet();
 break;
   }
   case EVENT_IMMEDIATE: {
@@ -407,11 +425,12 @@ QUICNetVConnection::state_connection_established(int 
event, Event *data)
 break;
   }
   case QUIC_EVENT_PACKET_WRITE_READY: {
-error = this->_state_common_send_packet();
-this->_packet_write_ready = nullptr;
+if (this->_packet_write_ready == data) {
+  this->_packet_write_ready = nullptr;
+}
+error = this->_state_common_send_packet();
 break;
   }
-
   case EVENT_IMMEDIATE: {
 // Start Implicit Shutdown. Because of no network 

[trafficserver] branch quic-latest updated: Acquire a lock before _frame_send_queue operation

2017-09-14 Thread masaori
This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/quic-latest by this push:
 new 47078f9  Acquire a lock before _frame_send_queue operation
47078f9 is described below

commit 47078f9aa1c62e9b7e80fb2fe2d95aeb5b1fa139
Author: Masaori Koshiba 
AuthorDate: Fri Sep 15 11:25:11 2017 +0900

Acquire a lock before _frame_send_queue operation
---
 iocore/net/P_QUICNetVConnection.h   |  5 +++--
 iocore/net/QUICNetVConnection.cc| 20 +---
 iocore/net/quic/QUICLossDetector.cc |  2 +-
 iocore/net/quic/QUICPacketTransmitter.h |  2 +-
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/iocore/net/P_QUICNetVConnection.h 
b/iocore/net/P_QUICNetVConnection.h
index 01b689c..b29d2d6 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -181,7 +181,7 @@ public:
   // QUICConnection (QUICPacketTransmitter)
   virtual void transmit_packet(std::unique_ptr packet) override;
   virtual void retransmit_packet(const QUICPacket ) override;
-  virtual Ptr get_transmitter_mutex() override;
+  virtual Ptr get_packet_transmitter_mutex() override;
 
   // QUICConnection (QUICFrameTransmitter)
   virtual void transmit_frame(std::unique_ptr 
frame) override;
@@ -236,7 +236,8 @@ private:
   QUICError _state_common_receive_packet();
   QUICError _state_common_send_packet();
 
-  Ptr _transmitter_mutex;
+  Ptr _packet_transmitter_mutex;
+  Ptr _frame_transmitter_mutex;
 
   QUICApplication *_create_application();
   void _init_flow_control_params(const std::shared_ptr _tp,
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 8f25ca9..aefd28c 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -61,9 +61,10 @@ QUICNetVConnection::QUICNetVConnection() : 
UnixNetVConnection()
 void
 QUICNetVConnection::init(UDPConnection *udp_con, QUICPacketHandler 
*packet_handler)
 {
-  this->_transmitter_mutex = new_ProxyMutex();
-  this->_udp_con   = udp_con;
-  this->_packet_handler= packet_handler;
+  this->_packet_transmitter_mutex = new_ProxyMutex();
+  this->_frame_transmitter_mutex  = new_ProxyMutex();
+  this->_udp_con  = udp_con;
+  this->_packet_handler   = packet_handler;
   this->_quic_connection_id.randomize();
 
   // FIXME These should be done by HttpProxyServerMain
@@ -231,9 +232,9 @@ QUICNetVConnection::retransmit_packet(const QUICPacket 
)
 }
 
 Ptr
-QUICNetVConnection::get_transmitter_mutex()
+QUICNetVConnection::get_packet_transmitter_mutex()
 {
-  return this->_transmitter_mutex;
+  return this->_packet_transmitter_mutex;
 }
 
 void
@@ -248,6 +249,8 @@ void
 QUICNetVConnection::transmit_frame(std::unique_ptr frame)
 {
   DebugQUICCon("Type=%s Size=%zu", QUICDebugNames::frame_type(frame->type()), 
frame->size());
+
+  SCOPED_MUTEX_LOCK(frame_transmitter_lock, this->_frame_transmitter_mutex, 
this_ethread());
   this->_frame_send_queue.push(std::move(frame));
   if (!this->_packet_write_ready) {
 this->_packet_write_ready = eventProcessor.schedule_imm(this, ET_CALL, 
QUIC_EVENT_PACKET_WRITE_READY, nullptr);
@@ -641,6 +644,8 @@ QUICNetVConnection::_state_common_send_packet()
   if (error.cls != QUICErrorClass::NONE) {
 return error;
   }
+
+  SCOPED_MUTEX_LOCK(packet_transmitter_lock, 
this->get_packet_transmitter_mutex().get(), this_ethread());
   while ((packet = this->_packet_send_queue.dequeue()) != nullptr) {
 this->_packet_handler->send_packet(*packet, this);
 this->_loss_detector->on_packet_sent(
@@ -666,6 +671,7 @@ QUICNetVConnection::_packetize_frames()
   QUICPacketType previous_packet_type = QUICPacketType::UNINITIALIZED;
   QUICPacketType current_packet_type  = QUICPacketType::UNINITIALIZED;
 
+  SCOPED_MUTEX_LOCK(frame_transmitter_lock, this->_frame_transmitter_mutex, 
this_ethread());
   while (this->_frame_send_queue.size() > 0) {
 frame = std::move(this->_frame_send_queue.front());
 this->_frame_send_queue.pop();
@@ -678,7 +684,7 @@ QUICNetVConnection::_packetize_frames()
 }
 if (len + frame->size() + MAX_PACKET_OVERHEAD > max_size || 
(previous_packet_type != current_packet_type && len > 0)) {
   ink_assert(len > 0);
-  SCOPED_MUTEX_LOCK(transmitter_lock, this->get_transmitter_mutex().get(), 
this_ethread());
+  SCOPED_MUTEX_LOCK(packet_transmitter_lock, 
this->get_packet_transmitter_mutex().get(), this_ethread());
   this->transmit_packet(this->_build_packet(std::move(buf), len, 
retransmittable, previous_packet_type));
   len = 0;
 }
@@ -700,7 +706,7 @@ QUICNetVConnection::_packetize_frames()
   memset(buf.get() + len, 0, min_size - len);
   len += min_size - len;
 }

[trafficserver] branch master updated: Optimize: Add startCop & stopCop for InactivityCop

2017-09-14 Thread oknet
This is an automated email from the ASF dual-hosted git repository.

oknet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 5b7aabc  Optimize: Add startCop & stopCop for InactivityCop
5b7aabc is described below

commit 5b7aabccaec0de5d603b9b12e68a9d37ae208baf
Author: Oknet Xu 
AuthorDate: Tue Sep 12 15:37:33 2017 +0800

Optimize: Add startCop & stopCop for InactivityCop

startCop: put a netvc into open_list. All NetVCs in the open_list is
checked for timeout by InactivityCop.

stopCop: remove the netvc from open_list and cop_list. Also remove the
netvc from keep_alive_queue and active_queue if its context is IN.
---
 iocore/net/P_UnixNet.h   | 46 ++--
 iocore/net/UnixNetVConnection.cc | 16 ++
 2 files changed, 50 insertions(+), 12 deletions(-)

diff --git a/iocore/net/P_UnixNet.h b/iocore/net/P_UnixNet.h
index a2200ea..ce76c45 100644
--- a/iocore/net/P_UnixNet.h
+++ b/iocore/net/P_UnixNet.h
@@ -212,18 +212,38 @@ public:
 Only be called when holding the mutex of this NetHandler.
 
 @param netvc UnixNetVConnection to be managed by this NetHandler.
-@return 0 on success, -ERRNO on failure.
+@return 0 on success, netvc->nh set to this NetHandler.
+-ERRNO on failure.
*/
   int startIO(UnixNetVConnection *netvc);
   /**
 Stop to handle read & write event on a UnixNetVConnection.
 Remove the socket fd of netvc from polling system.
-Only be called when holding the mutex of this NetHandler.
+Only be called when holding the mutex of this NetHandler and must call 
stopCop(netvc) first.
 
 @param netvc UnixNetVConnection to be released.
+@return netvc->nh set to nullptr.
*/
   void stopIO(UnixNetVConnection *netvc);
 
+  /**
+Start to handle active timeout and inactivity timeout on a 
UnixNetVConnection.
+Put the netvc into open_list. All NetVCs in the open_list is checked for 
timeout by InactivityCop.
+Only be called when holding the mutex of this NetHandler and must call 
startIO(netvc) first.
+
+@param netvc UnixNetVConnection to be managed by InactivityCop
+   */
+  void startCop(UnixNetVConnection *netvc);
+  /* *
+Stop to handle active timeout and inactivity on a UnixNetVConnection.
+Remove the netvc from open_list and cop_list.
+Also remove the netvc from keep_alive_queue and active_queue if its 
context is IN.
+Only be called when holding the mutex of this NetHandler.
+
+@param netvc UnixNetVConnection to be released.
+   */
+  void stopCop(UnixNetVConnection *netvc);
+
   NetHandler();
 
 private:
@@ -701,4 +721,26 @@ NetHandler::stopIO(UnixNetVConnection *netvc)
 
   netvc->nh = nullptr;
 }
+
+TS_INLINE void
+NetHandler::startCop(UnixNetVConnection *netvc)
+{
+  ink_assert(this->mutex->thread_holding == this_ethread());
+  ink_release_assert(netvc->nh == this);
+  ink_assert(!open_list.in(netvc));
+
+  open_list.enqueue(netvc);
+}
+
+TS_INLINE void
+NetHandler::stopCop(UnixNetVConnection *netvc)
+{
+  ink_release_assert(netvc->nh == this);
+
+  open_list.remove(netvc);
+  cop_list.remove(netvc);
+  remove_from_keep_alive_queue(netvc);
+  remove_from_active_queue(netvc);
+}
+
 #endif
diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc
index a47ee31..63d5ba0 100644
--- a/iocore/net/UnixNetVConnection.cc
+++ b/iocore/net/UnixNetVConnection.cc
@@ -95,10 +95,7 @@ close_UnixNetVConnection(UnixNetVConnection *vc, EThread *t)
 
   if (nh) {
 // 2. Release vc from InactivityCop.
-nh->open_list.remove(vc);
-nh->cop_list.remove(vc);
-vc->remove_from_keep_alive_queue();
-vc->remove_from_active_queue();
+nh->stopCop(vc);
 // 3. Release vc from NetHandler.
 nh->stopIO(vc);
   }
@@ -1142,8 +1139,8 @@ UnixNetVConnection::acceptEvent(int event, Event *e)
   // Setup a timeout callback handler.
   SET_HANDLER((NetVConnHandler)::mainEvent);
 
-  // All NetVCs in the open_list is checked for timeout by InactivityCop.
-  nh->open_list.enqueue(this);
+  // Send this netvc to InactivityCop.
+  nh->startCop(this);
 
   if (inactivity_timeout_in) {
 UnixNetVConnection::set_inactivity_timeout(inactivity_timeout_in);
@@ -1253,8 +1250,7 @@ UnixNetVConnection::populate(Connection _in, 
Continuation *c, void *arg)
 
   ink_assert(this->nh != nullptr);
   SET_HANDLER(::mainEvent);
-  ink_assert(!nh->open_list.in(this));
-  this->nh->open_list.enqueue(this);
+  this->nh->startCop(this);
   ink_assert(this->con.fd != NO_FD);
   return EVENT_DONE;
 }
@@ -1335,8 +1331,8 @@ UnixNetVConnection::connectUp(EThread *t, int fd)
 
   // Setup a timeout callback handler.
   SET_HANDLER(::mainEvent);
-  // All NetVCs in the open_list is checked for timeout by InactivityCop.
-  nh->open_list.enqueue(this);
+  // Send this netvc to InactivityCop.
+  

[trafficserver] branch quic-latest updated: Rename _frame_buffer of QUICNetVConnection to _frame_send_queue

2017-09-14 Thread masaori
This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/quic-latest by this push:
 new f973bcc  Rename _frame_buffer of QUICNetVConnection to 
_frame_send_queue
f973bcc is described below

commit f973bccd4b5b55f61104ada6e231495672756acb
Author: Masaori Koshiba 
AuthorDate: Fri Sep 15 10:56:46 2017 +0900

Rename _frame_buffer of QUICNetVConnection to _frame_send_queue
---
 iocore/net/P_QUICNetVConnection.h | 2 +-
 iocore/net/QUICNetVConnection.cc  | 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/iocore/net/P_QUICNetVConnection.h 
b/iocore/net/P_QUICNetVConnection.h
index 61d16e2..01b689c 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -219,7 +219,7 @@ private:
 
   Queue _packet_recv_queue;
   Queue _packet_send_queue;
-  std::queue> _frame_buffer;
+  std::queue _frame_send_queue;
 
   Event *_packet_write_ready = nullptr;
 
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index b0df002..8f25ca9 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -248,7 +248,7 @@ void
 QUICNetVConnection::transmit_frame(std::unique_ptr frame)
 {
   DebugQUICCon("Type=%s Size=%zu", QUICDebugNames::frame_type(frame->type()), 
frame->size());
-  this->_frame_buffer.push(std::move(frame));
+  this->_frame_send_queue.push(std::move(frame));
   if (!this->_packet_write_ready) {
 this->_packet_write_ready = eventProcessor.schedule_imm(this, ET_CALL, 
QUIC_EVENT_PACKET_WRITE_READY, nullptr);
   }
@@ -666,9 +666,9 @@ QUICNetVConnection::_packetize_frames()
   QUICPacketType previous_packet_type = QUICPacketType::UNINITIALIZED;
   QUICPacketType current_packet_type  = QUICPacketType::UNINITIALIZED;
 
-  while (this->_frame_buffer.size() > 0) {
-frame = std::move(this->_frame_buffer.front());
-this->_frame_buffer.pop();
+  while (this->_frame_send_queue.size() > 0) {
+frame = std::move(this->_frame_send_queue.front());
+this->_frame_send_queue.pop();
 QUICRetransmissionFrame *rf = dynamic_cast(frame.get());
 previous_packet_type= current_packet_type;
 if (rf) {

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" '].


[trafficserver] branch quic-latest updated: correct the calc of the forward_limit

2017-09-14 Thread scw00
This is an automated email from the ASF dual-hosted git repository.

scw00 pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/quic-latest by this push:
 new 0ee430e  correct the calc of the forward_limit
0ee430e is described below

commit 0ee430e9666ac63b6595d5952a129e3046ee892c
Author: scw00 
AuthorDate: Tue Sep 12 20:32:22 2017 +0800

correct the calc of the forward_limit
---
 iocore/net/quic/QUICStream.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/iocore/net/quic/QUICStream.cc b/iocore/net/quic/QUICStream.cc
index e656874..ebc0178 100644
--- a/iocore/net/quic/QUICStream.cc
+++ b/iocore/net/quic/QUICStream.cc
@@ -256,7 +256,7 @@ QUICStream::_write_to_read_vio(const std::shared_ptr 
   int bytes_added = this->_read_vio.buffer.writer()->write(frame->data(), 
frame->data_length());
   this->_read_vio.nbytes += bytes_added;
   this->_recv_offset += frame->data_length();
-  this->_local_flow_controller->forward_limit(frame->offset() + 
this->_flow_control_buffer_size);
+  this->_local_flow_controller->forward_limit(this->_recv_offset + 
this->_flow_control_buffer_size);
   Debug("quic_flow_ctrl", "Stream [%" PRIx32 "] [%s] [LOCAL] %" PRIu64 "/%" 
PRIu64, this->_id,
 QUICDebugNames::stream_state(this->_state), 
this->_local_flow_controller->current_offset(),
 this->_local_flow_controller->current_limit());

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" '].


[trafficserver] branch quic-latest updated: remove the useless frame since we already written it in vio

2017-09-14 Thread scw00
This is an automated email from the ASF dual-hosted git repository.

scw00 pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/quic-latest by this push:
 new 0a56b5a  remove the useless frame since we already written it in vio
0a56b5a is described below

commit 0a56b5af456a7f0c8ed15b38fa21c87345291699
Author: scw00 
AuthorDate: Fri Sep 15 08:57:46 2017 +0800

remove the useless frame since we already written it in vio
---
 iocore/net/quic/QUICStream.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/iocore/net/quic/QUICStream.cc b/iocore/net/quic/QUICStream.cc
index 91033fe..e656874 100644
--- a/iocore/net/quic/QUICStream.cc
+++ b/iocore/net/quic/QUICStream.cc
@@ -268,6 +268,7 @@ QUICStream::_reorder_data()
   auto frame = _received_stream_frame_buffer.find(this->_recv_offset);
   while (frame != this->_received_stream_frame_buffer.end()) {
 this->_write_to_read_vio(frame->second);
+this->_received_stream_frame_buffer.erase(frame);
 frame = _received_stream_frame_buffer.find(this->_recv_offset);
   }
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" '].


[trafficserver] branch master updated: Tests: Add logging field test base. Initially test essh for multi-values.

2017-09-14 Thread amc
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new c70e58e  Tests: Add logging field test base. Initially test essh for 
multi-values.
c70e58e is described below

commit c70e58ecc735556a0a1dc1217e95cf0af02fd14a
Author: Alan M. Carroll 
AuthorDate: Fri Sep 8 17:22:15 2017 -0500

Tests: Add logging field test base. Initially test essh for multi-values.
---
 tests/gold_tests/logging/gold/field-test.gold |   3 +
 tests/gold_tests/logging/log-field.test.py| 102 ++
 2 files changed, 105 insertions(+)

diff --git a/tests/gold_tests/logging/gold/field-test.gold 
b/tests/gold_tests/logging/gold/field-test.gold
new file mode 100644
index 000..f75ee82
--- /dev/null
+++ b/tests/gold_tests/logging/gold/field-test.gold
@@ -0,0 +1,3 @@
+application/json,%20application/json
+application/jason,%20application/json
+application/json
diff --git a/tests/gold_tests/logging/log-field.test.py 
b/tests/gold_tests/logging/log-field.test.py
new file mode 100644
index 000..66cd7c7
--- /dev/null
+++ b/tests/gold_tests/logging/log-field.test.py
@@ -0,0 +1,102 @@
+'''
+'''
+#  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.
+
+import os
+
+Test.Summary = '''
+Test log fields.
+'''
+# need Curl
+Test.SkipUnless(
+Condition.HasProgram(
+"curl", "Curl need to be installed on system for this test to work"),
+Condition.IsPlatform("linux")
+)
+
+# Define default ATS
+ts = Test.MakeATSProcess("ts")
+# Microserver
+server = Test.MakeOriginServer("server")
+
+request_header = {'timestamp': 100, "headers": "GET /test-1 HTTP/1.1\r\nHost: 
test-1\r\n\r\n", "body": ""}
+response_header = {'timestamp': 100,
+   "headers": "HTTP/1.1 200 OK\r\nTest: 1\r\nContent-Type: 
application/json\r\nConnection: close\r\nContent-Type: 
application/json\r\n\r\n", "body": "Test 1"}
+server.addResponse("sessionlog.json", request_header, response_header)
+server.addResponse("sessionlog.json",
+   {'timestamp': 101, "headers": "GET /test-2 
HTTP/1.1\r\nHost: test-2\r\n\r\n", "body": ""},
+   {'timestamp': 101, "headers": "HTTP/1.1 200 OK\r\nTest: 
2\r\nContent-Type: application/jason\r\nConnection: close\r\nContent-Type: 
application/json\r\n\r\n", "body": "Test 2"}
+   )
+server.addResponse("sessionlog.json",
+   {'timestamp': 102, "headers": "GET /test-3 
HTTP/1.1\r\nHost: test-3\r\n\r\n", "body": ""},
+   {'timestamp': 102, "headers": "HTTP/1.1 200 OK\r\nTest: 
3\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", "body": 
"Test 3"}
+   )
+
+ts.Disk.records_config.update({
+'proxy.config.net.connections_throttle': 100,
+'proxy.config.http.cache.http': 0
+})
+# setup some config file for this server
+ts.Disk.remap_config.AddLine(
+'map / http://localhost:{}/'.format(server.Variables.Port)
+)
+
+ts.Disk.logging_config.AddLines(
+'''
+custom = format {
+  Format = '%<{Content-Type}essh>'
+}
+
+log.ascii {
+  Format = custom,
+  Filename = 'field-test'
+}
+'''.split("\n")
+)
+
+# #
+# at the end of the different test run a custom log file should exist
+# Because of this we expect the testruns to pass the real test is if the
+# customlog file exists and passes the format check
+Test.Disk.File(os.path.join(ts.Variables.LOGDIR, 'field-test.log'),
+   exists=True, content='gold/field-test.gold')
+
+# first test is a miss for default
+tr = Test.AddTestRun()
+# Wait for the micro server
+tr.Processes.Default.StartBefore(server)
+# Delay on readiness of our ssl ports
+tr.Processes.Default.StartBefore(Test.Processes.ts)
+
+tr.Processes.Default.Command = 'curl --verbose --header "Host: test-1" 
http://localhost:{0}/test-1' .format(
+ts.Variables.port)
+tr.Processes.Default.ReturnCode = 0
+
+tr = Test.AddTestRun()
+tr.Processes.Default.Command = 'curl --verbose --header "Host: test-2" 
http://localhost:{0}/test-2' .format(
+

[trafficserver] branch master updated: Add a metric for tracking RSS of traffic_server

2017-09-14 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new c1a656e  Add a metric for tracking RSS of traffic_server
c1a656e is described below

commit c1a656e372d2577fdf63d34769a898acd1ab804f
Author: Leif Hedstrom 
AuthorDate: Wed Sep 13 13:01:34 2017 -0600

Add a metric for tracking RSS of traffic_server
---
 .../monitoring/statistics/core/general.en.rst  |  5 
 proxy/Main.cc  | 34 --
 2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/doc/admin-guide/monitoring/statistics/core/general.en.rst 
b/doc/admin-guide/monitoring/statistics/core/general.en.rst
index eb08eda..50468ae 100644
--- a/doc/admin-guide/monitoring/statistics/core/general.en.rst
+++ b/doc/admin-guide/monitoring/statistics/core/general.en.rst
@@ -117,3 +117,8 @@ General
A shortened string containing the release number of the running instance of
|TS|.
 
+.. ts:stat:: global proxy.process.traffic_server.memory.rss integer
+   :units: bytes
+
+   The resident set size (RSS) of the ``traffic_server`` process. This is
+   basically the amount of memory this process is consuming.
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 789d0f0..3a9ea06 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -381,8 +381,11 @@ public:
   {
 memset(&_usage, 0, sizeof(_usage));
 SET_HANDLER(::periodic);
+RecRegisterStatInt(RECT_PROCESS, 
"proxy.process.traffic_server.memory.rss", static_cast(0), 
RECP_NON_PERSISTENT);
   }
+
   ~MemoryLimit() override { mutex = nullptr; }
+
   int
   periodic(int event, Event *e)
   {
@@ -392,14 +395,15 @@ public:
   delete this;
   return EVENT_DONE;
 }
-if (_memory_limit == 0) {
-  // first time it has been run
-  _memory_limit = REC_ConfigReadInteger("proxy.config.memory.max_usage");
-  _memory_limit = _memory_limit >> 10; // divide by 1024
-}
-if (_memory_limit > 0) {
-  if (getrusage(RUSAGE_SELF, &_usage) == 0) {
-Debug("server", "memory usage - ru_maxrss: %ld memory limit: %" 
PRId64, _usage.ru_maxrss, _memory_limit);
+
+// "reload" the setting, we don't do this often so not expensive
+_memory_limit = REC_ConfigReadInteger("proxy.config.memory.max_usage");
+_memory_limit = _memory_limit >> 10; // divide by 1024
+
+if (getrusage(RUSAGE_SELF, &_usage) == 0) {
+  RecSetRecordInt("proxy.process.traffic_server.memory.rss", 
_usage.ru_maxrss << 10, REC_SOURCE_DEFAULT); // * 1024
+  Debug("server", "memory usage - ru_maxrss: %ld memory limit: %" PRId64, 
_usage.ru_maxrss, _memory_limit);
+  if (_memory_limit > 0) {
 if (_usage.ru_maxrss > _memory_limit) {
   if (net_memory_throttle == false) {
 net_memory_throttle = true;
@@ -411,13 +415,13 @@ public:
 Debug("server", "memory usage under limit - ru_maxrss: %ld memory 
limit: %" PRId64, _usage.ru_maxrss, _memory_limit);
   }
 }
+  } else {
+// this feature has not been enabled
+Debug("server", "limiting connections based on memory usage has been 
disabled");
+e->cancel();
+delete this;
+return EVENT_DONE;
   }
-} else {
-  // this feature has not be enabled
-  Debug("server", "limiting connections based on memory usage has been 
disabled");
-  e->cancel();
-  delete this;
-  return EVENT_DONE;
 }
 return EVENT_CONT;
   }
@@ -1783,7 +1787,7 @@ main(int /* argc ATS_UNUSED */, const char **argv)
 
   eventProcessor.schedule_every(new SignalContinuation, HRTIME_MSECOND * 500, 
ET_CALL);
   eventProcessor.schedule_every(new DiagsLogContinuation, HRTIME_SECOND, 
ET_TASK);
-  eventProcessor.schedule_every(new MemoryLimit, HRTIME_SECOND, ET_TASK);
+  eventProcessor.schedule_every(new MemoryLimit, HRTIME_SECOND * 10, ET_TASK);
   REC_RegisterConfigUpdateFunc("proxy.config.dump_mem_info_frequency", 
init_memory_tracker, nullptr);
   init_memory_tracker(nullptr, RECD_NULL, RecData(), nullptr);
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" '].


[trafficserver] branch master updated: TS-4976: Regularize plugins - txn_data_sink.

2017-09-14 Thread amc
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 712823e  TS-4976: Regularize plugins - txn_data_sink.
712823e is described below

commit 712823e0d025ddde3f0e0c5084af53a78e4f7ec9
Author: Alan M. Carroll 
AuthorDate: Wed Sep 13 10:07:09 2017 -0500

TS-4976: Regularize plugins - txn_data_sink.
---
 doc/developer-guide/plugins/http-transformations/index.en.rst | 2 +-
 example/Makefile.am   | 4 ++--
 .../{txn-data-sink/txn-data-sink.c => txn_data_sink/txn_data_sink.c}  | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/developer-guide/plugins/http-transformations/index.en.rst 
b/doc/developer-guide/plugins/http-transformations/index.en.rst
index cc35380..7e747d2 100644
--- a/doc/developer-guide/plugins/http-transformations/index.en.rst
+++ b/doc/developer-guide/plugins/http-transformations/index.en.rst
@@ -181,5 +181,5 @@ and will keep the transaction and the origin server 
connection up. This is usefu
 run to completion even if the user agent disconnects. Examples would be a 
standard transform that is expensive to initiate, or expensive
 origin server connections that should be :ts:cv:`shared 
`.
 
-There is an `example plugin 
`_
 that demonstrates
+There is an `example plugin 
`_
 that demonstrates
 this used as a pure data sink to keep the transaction up regardless of whether 
the user agent disconnects.
diff --git a/example/Makefile.am b/example/Makefile.am
index d4e4213..27621e3 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -58,7 +58,7 @@ example_Plugins = \
ssl_sni.la \
statistic.la \
thread_1.la \
-   txn-data-sink.la \
+   txn_data_sink.la \
version.la \
disable_http2.la
 
@@ -125,7 +125,7 @@ ssl_sni_whitelist_la_LIBADD = $(libtsconfig)
 disable_http2_la_SOURCES = disable_http2/disable_http2.cc
 statistic_la_SOURCES = statistic/statistic.cc
 thread_1_la_SOURCES = thread_1/thread_1.c
-txn_data_sink_la_SOURCES = txn-data-sink/txn-data-sink.c
+txn_data_sink_la_SOURCES = txn_data_sink/txn_data_sink.c
 version_la_SOURCES = version/version.c
 redirect_1_la_SOURCES = redirect_1/redirect_1.c
 session_hooks_la_SOURCES = session_hooks/session_hooks.c
diff --git a/example/txn-data-sink/txn-data-sink.c 
b/example/txn_data_sink/txn_data_sink.c
similarity index 98%
rename from example/txn-data-sink/txn-data-sink.c
rename to example/txn_data_sink/txn_data_sink.c
index 3f22fa1..60d10de 100644
--- a/example/txn-data-sink/txn-data-sink.c
+++ b/example/txn_data_sink/txn_data_sink.c
@@ -36,8 +36,8 @@
 #define __STDC_FORMAT_MACROS 1
 #include 
 
-#define PLUGIN_NAME "txn-data-sink"
-#define PCP "[" PLUGIN_NAME "]"
+#define PLUGIN_NAME "txn_data_sink"
+#define PCP "[" PLUGIN_NAME "] "
 
 // Activate the data sink if this field is present in the request.
 static const char FLAG_MIME_FIELD[] = "TS-Agent";

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" '].


[trafficserver] branch master updated: ink_memory.cc: musl support tiny fix

2017-09-14 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new bf64ec2  ink_memory.cc: musl support tiny fix
bf64ec2 is described below

commit bf64ec2dfc251d140d78b3a033863579ef6cffcc
Author: IvanStarodubtsev 
AuthorDate: Tue Sep 12 15:42:48 2017 +0300

ink_memory.cc: musl support tiny fix

mallopt is GLIBC only (alpine3.6/musl)
---
 lib/ts/ink_memory.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ts/ink_memory.cc b/lib/ts/ink_memory.cc
index 6811c4e..9cbcbd7 100644
--- a/lib/ts/ink_memory.cc
+++ b/lib/ts/ink_memory.cc
@@ -159,9 +159,9 @@ ats_mallopt(int param ATS_UNUSED, int value ATS_UNUSED)
 #if TS_HAS_TCMALLOC
 // TODO: tcmalloc code ?
 #else
-#if defined(linux)
+#if defined(__GLIBC__)
   return mallopt(param, value);
-#endif // ! defined(linux)
+#endif // ! defined(__GLIBC__)
 #endif // ! TS_HAS_TCMALLOC
 #endif // ! TS_HAS_JEMALLOC
   return 0;

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" '].