trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [trafficserver] branch master updated: Prevent traffic_ctl from writing on a socket that is not connected.
Date Sat, 03 Jun 2017 16:20:13 GMT
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  a554692   Prevent traffic_ctl from writing on a socket that is not connected.
a554692 is described below

commit a554692e22c672b41d9879b76b2c7e583e85fda5
Author: Alan M. Carroll <solidwallofcode@yahoo-inc.com>
AuthorDate: Fri Jun 2 12:20:16 2017 -0500

    Prevent traffic_ctl from writing on a socket that is not connected.
---
 mgmt/api/NetworkMessage.cc    | 3 +++
 mgmt/api/NetworkMessage.h     | 3 +++
 mgmt/api/NetworkUtilsRemote.h | 7 ++++++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/mgmt/api/NetworkMessage.cc b/mgmt/api/NetworkMessage.cc
index 198bb4e..1a5b77e 100644
--- a/mgmt/api/NetworkMessage.cc
+++ b/mgmt/api/NetworkMessage.cc
@@ -125,6 +125,9 @@ send_mgmt_request(const mgmt_message_sender &snd, OpType optype, ...)
   const MgmtMarshallType lenfield[] = {MGMT_MARSHALL_INT};
   const NetCmdOperation *cmd;
 
+  if (!snd.is_connected())
+    return TS_ERR_NET_ESTABLISH; // no connection.
+
   GETCMD(requests, optype, cmd);
 
   va_start(ap, optype);
diff --git a/mgmt/api/NetworkMessage.h b/mgmt/api/NetworkMessage.h
index c8cb9fa..d9f55ba 100644
--- a/mgmt/api/NetworkMessage.h
+++ b/mgmt/api/NetworkMessage.h
@@ -69,6 +69,9 @@ enum {
 struct mgmt_message_sender {
   virtual TSMgmtError send(void *msg, size_t msglen) const = 0;
   virtual ~mgmt_message_sender(){};
+
+  // Check if the sender is connected.
+  virtual bool is_connected() const = 0;
 };
 
 // Marshall and send a request, prefixing the message length as a MGMT_MARSHALL_INT.
diff --git a/mgmt/api/NetworkUtilsRemote.h b/mgmt/api/NetworkUtilsRemote.h
index 5c63c8e..415719a 100644
--- a/mgmt/api/NetworkUtilsRemote.h
+++ b/mgmt/api/NetworkUtilsRemote.h
@@ -66,7 +66,12 @@ void *event_poll_thread_main(void *arg);
 
 struct mgmtapi_sender : public mgmt_message_sender {
   explicit mgmtapi_sender(int _fd) : fd(_fd) {}
-  virtual TSMgmtError send(void *msg, size_t msglen) const;
+  TSMgmtError send(void *msg, size_t msglen) const override;
+  bool
+  is_connected() const override
+  {
+    return fd != ts::NO_FD;
+  }
 
   int fd;
 };

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

Mime
View raw message