Changeset e61b4e


Ignore:
Timestamp:
10/05/08 13:49:56 (4 years ago)
Author:
Tomash Brechko <tomash.brechko@…>
Branches:
master
Children:
b1ae26
Parents:
c346b2
git-author:
Tomash Brechko <tomash.brechko@…> (10/04/08 16:24:39)
git-committer:
Tomash Brechko <tomash.brechko@…> (10/05/08 13:49:56)
Message:

Simplify the code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/client.c

    rc346b2 re61b4e  
    14061406      struct server *s; 
    14071407      struct pollfd *pollfd_beg, *pollfd; 
    1408       int nfds, res; 
    1409  
    1410       nfds = 0; 
     1408      int res; 
     1409 
     1410      pollfd_beg = array_beg(c->pollfds, struct pollfd); 
     1411      pollfd = pollfd_beg; 
     1412 
    14111413      for (array_each(c->servers, struct server, s)) 
    14121414        { 
     
    14351437          if (may_read || may_write) 
    14361438            { 
    1437 #if 1 
    1438               /* 
    1439                 At least gcc 3.4.2--4.2.2 report that res may be used 
    1440                 uninitialized here.  Though this doesn't look so, we 
    1441                 initialize it to suppress the warning. 
    1442               */ 
    1443               int res = 0; 
    1444 #endif 
    1445  
    14461439              if (may_write) 
    14471440                { 
     1441                  int res; 
     1442 
    14481443                  res = send_request(state, s); 
    14491444                  if (res == MEMCACHED_CLOSED) 
     
    14521447 
    14531448              if (may_read) 
    1454                 res = process_reply(state, s); 
    1455  
    1456               if (is_active(state)) 
    1457                 ++nfds; 
     1449                process_reply(state, s); 
     1450 
     1451              if (! is_active(state)) 
     1452                continue; 
    14581453            } 
    1459           else 
     1454 
     1455          pollfd->events = 0; 
     1456 
     1457          if (state->iov_count > 0) 
     1458            pollfd->events |= POLLOUT; 
     1459          if (state->reply_count > 0 || state->nowait_count > 0) 
     1460            pollfd->events |= POLLIN; 
     1461 
     1462          if (pollfd->events != 0) 
    14601463            { 
    1461               ++nfds; 
     1464              pollfd->fd = state->fd; 
     1465              state->pollfd = pollfd; 
     1466              ++pollfd; 
    14621467            } 
    14631468        } 
    14641469 
    1465       if (nfds == 0) 
     1470      if (pollfd == pollfd_beg) 
    14661471        break; 
    1467  
    1468       pollfd_beg = array_beg(c->pollfds, struct pollfd); 
    1469       pollfd = pollfd_beg; 
    1470  
    1471       for (array_each(c->servers, struct server, s)) 
    1472         { 
    1473           struct command_state *state = &s->cmd_state; 
    1474  
    1475           if (is_active(state)) 
    1476             { 
    1477               pollfd->events = 0; 
    1478  
    1479               if (state->iov_count > 0) 
    1480                 pollfd->events |= POLLOUT; 
    1481               if (state->reply_count > 0 || state->nowait_count > 0) 
    1482                 pollfd->events |= POLLIN; 
    1483  
    1484               if (pollfd->events != 0) 
    1485                 { 
    1486                   pollfd->fd = state->fd; 
    1487                   state->pollfd = pollfd; 
    1488                   ++pollfd; 
    1489                 } 
    1490             } 
    1491         } 
    14921472 
    14931473      do 
Note: See TracChangeset for help on using the changeset viewer.