Changeset 1ebc4bd


Ignore:
Timestamp:
02/13/15 14:57:13 (6 years ago)
Author:
Richard Sanger <rsangerarj@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
ed6304c5
Parents:
de74f88
Message:

Fix bug in ring: format if the interface is down

If the ring interface goes down (or starts down), Linux considers this
to be an error for the socket and we were not checking for the error
returns of the individual poll() items, where this error was returned.

Due to ordering of the code this broke libtrace_halt (if no packets are being received),
even if the interface came back (once shutdown the error seems to persist
upon restart).

The behaviour now is that an error, such as the interface being down
(probably the only error one could encounter?) will return as an error
to the libtrace application.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_linux_ring.c

    r6cf3ca0 r1ebc4bd  
    484484                        pollset[1].revents = 0;
    485485                }
    486                 /* Wait for more data or a message*/
    487                 ret = poll(pollset, (queue ? 2 : 1), -1);
     486                /* Wait for more data or a message */
     487                ret = poll(pollset, (queue ? 2 : 1), 500);
    488488                if (ret > 0) {
    489                         if (pollset[0].revents)
     489                        if (pollset[0].revents == POLLIN)
    490490                                continue;
    491                         else
     491                        else if (queue && pollset[1].revents == POLLIN)
    492492                                return READ_MESSAGE;
     493                        else if (queue && pollset[1].revents) {
     494                                /* Internal error */
     495                                trace_set_err(libtrace,TRACE_ERR_BAD_STATE,
     496                                              "Message queue error %d poll()",
     497                                              pollset[1].revents);
     498                                return READ_ERROR;
     499                        } else {
     500                                /* I've only seen this when the network was down */
     501                                trace_set_err(libtrace,ENETDOWN,
     502                                              "Socket error revents=%d poll()",
     503                                              pollset[0].revents);
     504                                return READ_ERROR;
     505                        }
    493506                } else if (ret < 0) {
    494                         if (errno != EINTR)
    495                         trace_set_err(libtrace,errno,"poll()");
    496                         return -1;
     507                        if (errno != EINTR) {
     508                                trace_set_err(libtrace,errno,"poll()");
     509                                return -1;
     510                        }
    497511                } else {
    498512                        /* Poll timed out - check if we should exit */
Note: See TracChangeset for help on using the changeset viewer.