You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2016/03/08 15:36:28 UTC

trafficserver git commit: TS-4161 ProcessManager::pollLMConnection code refactoring

Repository: trafficserver
Updated Branches:
  refs/heads/master 6ea1d767f -> 5e53b85e6


TS-4161 ProcessManager::pollLMConnection code refactoring

Converted while(1) to for(;;) loop for better readability,
suggested by TS-4161 previous pull request comments.

This closes #519


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

Branch: refs/heads/master
Commit: 5e53b85e63a1c91f201d6e64b03e64e420550b6d
Parents: 6ea1d76
Author: Gancho Tenev <gt...@gmail.com>
Authored: Mon Mar 7 16:04:22 2016 -0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue Mar 8 07:35:41 2016 -0700

----------------------------------------------------------------------
 mgmt/ProcessManager.cc | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5e53b85e/mgmt/ProcessManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/ProcessManager.cc b/mgmt/ProcessManager.cc
index 91aecca..6ae18b1 100644
--- a/mgmt/ProcessManager.cc
+++ b/mgmt/ProcessManager.cc
@@ -233,8 +233,9 @@ ProcessManager::pollLMConnection()
   MgmtMessageHdr *mh_full;
   char *data_raw;
 
-  int count = MAX_MSGS_IN_A_ROW;
-  while (1) {
+  // Avoid getting stuck enqueuing too many requests in a row, limit to MAX_MSGS_IN_A_ROW.
+  int count;
+  for (count = 0; count < MAX_MSGS_IN_A_ROW; ++count) {
     int num;
 
     num = mgmt_read_timeout(local_manager_sockfd, 1 /* sec */, 0 /* usec */);
@@ -265,19 +266,12 @@ ProcessManager::pollLMConnection()
         close_socket(local_manager_sockfd);
         mgmt_fatal(stderr, 0, "[ProcessManager::pollLMConnection] Lost Manager EOF!");
       }
-
-      // Now don't get stuck in the while loop handling too many requests in a row.
-      count--;
-      if (0 == count) {
-        Debug("pmgmt", "[ProcessManager::pollLMConnection] enqueued '%d' messages in a row, pausing for processing",
-              MAX_MSGS_IN_A_ROW);
-        break;
-      }
     } else if (num < 0) { /* Error */
       mgmt_elog(stderr, 0, "[ProcessManager::pollLMConnection] select failed or was interrupted (%d)\n", errno);
     }
   }
 
+  Debug("pmgmt", "[ProcessManager::pollLMConnection] enqueued %d of max %d messages in a row", count, MAX_MSGS_IN_A_ROW);
 } /* End ProcessManager::pollLMConnection */
 
 void