Changeset 6a2f037 for lib


Ignore:
Timestamp:
09/24/18 14:19:14 (2 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
develop, master, ringperformance
Children:
fe4940e
Parents:
73a5b72
Message:

ndag: join the stream socket multicast group at the last minute

Joining earlier means that we have packets queuing up while we're
still allocating buffers etc. This means we run the risk of
dropping packets during our init phase.

Instead, we now do as much initialisation as possible before
joining the group -- it means that our first packet might end up
being a later one than we would have read previously, but we are
less likely to have a gap in our incoming stream.

Using the old method, our first batch of packets might have been
as follows:

1, 2, 3, 4, 5, 8, 9, 10

Now we might miss 1 and 2, but avoid having the gap from 5 to 8,
i.e.:

3, 4, 5, 6, 7, 8, 9, 10

I think generally the latter is a better sequence of packets for
us to provide to the user. It also means that our reported missing
count is zero, which is less likely to make users think that there
is a performance issue in their own code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_ndag.c

    r30bf197 r6a2f037  
    550550#endif
    551551
    552                 close(src.sock);
     552                if (src.sock != -1) {
     553                        close(src.sock);
     554                }
    553555        }
    554556        if (receiver->knownmonitors) {
     
    724726        ssock = &(rt->sources[rt->sourcecount]);
    725727
    726         ssock->sock = join_multicast_group(src.groupaddr, src.localiface,
    727                         NULL, src.port, &(ssock->srcaddr));
    728 
    729         if (ssock->sock < 0) {
    730                 return -1;
    731         }
    732 
    733728        for (i = 0; i < rt->monitorcount; i++) {
    734729                if (rt->knownmonitors[i].monitorid == src.monitor) {
     
    777772        ssock->recordcount = 0;
    778773        rt->sourcecount += 1;
     774
     775        ssock->sock = join_multicast_group(src.groupaddr, src.localiface,
     776                        NULL, src.port, &(ssock->srcaddr));
     777
     778        if (ssock->sock < 0) {
     779                return -1;
     780        }
     781
    779782        if (ssock->sock > rt->maxfd) {
    780783                rt->maxfd = ssock->sock;
Note: See TracChangeset for help on using the changeset viewer.