Changeset 9993cde


Ignore:
Timestamp:
11/15/17 14:26:01 (3 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
cachetimestamps, develop, dpdk-ndag, etsilive, master, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance
Children:
21c7681
Parents:
6654714
Message:

Added code path in format_ndag for machines without recvmmsg.

The performance will likely be terrible and the code is completely
untested, but at least libtrace will compile on those systems.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • configure.in

    re3fa533 r9993cde  
    126126
    127127# Fail if any of these functions are missing
    128 AC_CHECK_FUNCS(socket strdup strlcpy strcasecmp strncasecmp snprintf vsnprintf)
     128AC_CHECK_FUNCS(socket strdup strlcpy strcasecmp strncasecmp snprintf vsnprintf recvmmsg)
    129129
    130130AC_CHECK_SIZEOF([long int])
  • lib/format_ndag.c

    re844ff2 r9993cde  
    6666        int bufavail;
    6767
     68#if HAVE_RECVMMSG
    6869        struct mmsghdr mmsgbufs[RECV_BATCH_SIZE];
     70#else
     71        struct msghdr singlemsg;
     72#endif
     73
    6974} streamsock_t;
    7075
     
    495500                        free(src.saved);
    496501                }
     502
     503#if HAVE_RECVMMSG
    497504                for (j = 0; j < RECV_BATCH_SIZE; j++) {
    498505                        if (src.mmsgbufs[j].msg_hdr.msg_iov) {
     
    500507                        }
    501508                }
     509#else
     510                free(src.singlemsg.msg_iov);
     511#endif
     512
    502513                close(src.sock);
    503514        }
     
    701712        }
    702713
     714#if HAVE_RECVMMSG
    703715        for (i = 0; i < RECV_BATCH_SIZE; i++) {
    704716                ssock->mmsgbufs[i].msg_hdr.msg_iov = (struct iovec *)
     
    711723                ssock->mmsgbufs[i].msg_len = 0;
    712724        }
     725#else
     726        ssock->singlemsg.msg_iov = (struct iovec *) malloc(sizeof(struct iovec));
     727#endif
    713728
    714729        ssock->nextread = NULL;;
     
    776791
    777792        int wind = ssock->nextwriteind;
    778         int i;
    779 
     793        int i = 1;
     794
     795#if HAVE_RECVMMSG
    780796        for (i = 0; i < required; i++) {
    781797                if (i >= RECV_BATCH_SIZE) {
     
    794810                wind ++;
    795811        }
    796 
     812#else
     813        assert(required > 0);
     814        ssock->singlemsg.msg_iov->iov_base = ssock->saved[wind];
     815        ssock->singlemsg.msg_iov->iov_len = ENCAP_BUFSIZE;
     816        ssock->singlemsg.msg_iovlen = 1;
     817#endif
    797818        return i;
    798819}
     
    872893                int *gottime, recvstream_t *rt) {
    873894
    874         int ret, ndagstat, i, avail;
     895        int ret, ndagstat, avail;
    875896        int toret = 0;
     897
     898#if HAVE_RECVMMSG
     899        int i;
     900#endif
    876901
    877902        if (ssock->sock == -1) {
     
    879904        }
    880905
     906#if HAVE_RECVMMSG
    881907        /* Plenty of full buffers, just use the packets in those */
    882908        if (ssock->bufavail < RECV_BATCH_SIZE / 2) {
    883909                return 1;
    884910        }
     911#else
     912        if (ssock->bufavail == 0) {
     913                return 1;
     914        }
     915#endif
    885916
    886917        avail = init_receivers(ssock, ssock->bufavail);
    887918
     919#if HAVE_RECVMMSG
    888920        ret = recvmmsg(ssock->sock, ssock->mmsgbufs, avail,
    889921                        MSG_DONTWAIT, NULL);
    890 
     922#else
     923        ret = recvmsg(ssock->sock, &(ssock->singlemsg), MSG_DONTWAIT);
     924#endif
    891925        if (ret < 0) {
    892926                /* Nothing to receive right now, but we should still
     
    922956                return toret;
    923957        }
     958
    924959        ssock->startidle = 0;
     960
     961#if HAVE_RECVMMSG
    925962        for (i = 0; i < ret; i++) {
    926963                ndagstat = check_ndag_received(ssock, ssock->nextwriteind,
     
    934971                }
    935972        }
     973#else
     974        ndagstat = check_ndag_received(ssock, ssock->nextwriteind, ret, rt);
     975        if (ndagstat <= 0) {
     976                toret = 0;
     977        } else {
     978                toret = 1;
     979        }
     980#endif
    936981
    937982        return toret;
Note: See TracChangeset for help on using the changeset viewer.