This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/9.0.x by this push:
     new da2e0dc  Fix bad limit in poll loop.  jtest -c1 now works again. Note: 
for poll() we must scan the entire array passed in because, unlink epoll() 
poll() does not populate the output with only the ready fds, instead it sets 
event bits over the entire array which was passed in.
da2e0dc is described below

commit da2e0dc7a76855fadba7caeef76c5645219a4614
Author: John Plevyak <jplev...@gmail.com>
AuthorDate: Fri Aug 23 11:44:42 2019 -0700

    Fix bad limit in poll loop.  jtest -c1 now works again.
    Note: for poll() we must scan the entire array passed in
    because, unlink epoll() poll() does not populate the output
    with only the ready fds, instead it sets event bits over the
    entire array which was passed in.
    
    Also fix port endian-ness in verbose message.
    
    Signed-off-by: John Plevyak <jplev...@gmail.com>
    (cherry picked from commit 209a0b243303a60487ede65ae66b0c0c1cc94c02)
---
 tools/jtest/jtest.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/jtest/jtest.cc b/tools/jtest/jtest.cc
index 4253d04..b856469 100644
--- a/tools/jtest/jtest.cc
+++ b/tools/jtest/jtest.cc
@@ -606,7 +606,7 @@ static void
 poll_set(int sock, poll_cb read_cb, poll_cb write_cb = nullptr)
 {
   if (verbose) {
-    printf("adding poll %d\n", sock);
+    printf("adding poll %d %s %s\n", sock, read_cb ? "READ" : "-", write_cb ? 
"WRITE" : "-");
   }
   fd[sock].fd       = sock;
   fd[sock].read_cb  = read_cb;
@@ -1770,7 +1770,7 @@ open_server(unsigned short int port, accept_fn_t 
accept_fn)
   }
 
   if (verbose) {
-    printf("opening server on %d port %d\n", sock, name.sin_port);
+    printf("opening server on %d port %d\n", sock, port);
   }
 
   poll_init_set(sock, accept_fn);
@@ -1806,7 +1806,7 @@ poll_loop()
     if (ip >= POLL_GROUP_SIZE || i == last_fd) {
       int n = poll(pfd, ip, POLL_TIMEOUT);
       if (n > 0) {
-        for (int j = 0; j < n; j++) {
+        for (int j = 0; j < ip; j++) {
           if (pfd[j].revents & (POLLIN | POLLERR | POLLHUP | POLLNVAL)) {
             if (verbose) {
               printf("poll read %d %X\n", pfd[j].fd, pfd[j].revents);

Reply via email to