Navigation


Changeset 1200:ce2b00dc86c1 in freeDiameter for libfdcore/sctp.c


Ignore:
Timestamp:
Jun 14, 2013, 11:14:11 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

React quickly to head-of-the-line blocking in case of network failure. Can be adapted with MAX_HOTL_BLOCKING_TIME constant in cnxctx.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/sctp.c

    r1198 r1200  
    10841084#endif /* OLD_SCTP_SOCKET_API */
    10851085        ssize_t ret;
    1086         int timedout = 0;
     1086        struct timespec ts, now;
    10871087       
    10881088        TRACE_ENTRY("%p %hu %p %d", conn, strid, iov, iovcnt);
    10891089        CHECK_PARAMS_DO(conn && iov && iovcnt, { errno = EINVAL; return -1; } );
     1090        CHECK_SYS_DO(  clock_gettime(CLOCK_REALTIME, &ts), return -1 );
    10901091       
    10911092        memset(&mhdr, 0, sizeof(mhdr));
     
    11211122        if ((ret < 0) && ((errno == EAGAIN) || (errno == EINTR))) {
    11221123                pthread_testcancel();
    1123                 if (! fd_cnx_teststate(conn, CC_STATUS_CLOSING ))
     1124                /* Check how much time we were blocked for this sending. */
     1125                CHECK_SYS_DO(  clock_gettime(CLOCK_REALTIME, &now), return -1 );
     1126                if ( ((now.tv_sec - ts.tv_sec) * 1000 + ((now.tv_nsec - ts.tv_nsec) / 1000000L)) > MAX_HOTL_BLOCKING_TIME) {
     1127                        LOG_D("Unable to send any data for %dms, closing the connection", MAX_HOTL_BLOCKING_TIME);
     1128                } else if (! fd_cnx_teststate(conn, CC_STATUS_CLOSING )) {
    11241129                        goto again; /* don't care, just ignore */
    1125                 if (!timedout) {
    1126                         timedout ++; /* allow for one timeout while closing */
    1127                         goto again;
    1128                 }
     1130                }
     1131               
     1132                /* propagate the error */
     1133                errno = -ret;
     1134                ret = -1;
    11291135        }
    11301136       
Note: See TracChangeset for help on using the changeset viewer.