Navigation


Changeset 1376:b8afaf63f65a in freeDiameter for libfdproto


Ignore:
Timestamp:
Jun 20, 2019, 6:33:29 PM (5 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Phase:
public
Message:

Handle case where pthread_cond_timedwait returns EINVAL if abstime
has passed before it was called.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/sessions.c

    r1373 r1376  
    207207                /* If first session is not expired, we just wait until it happens */
    208208                if ( TS_IS_INFERIOR( &now, &first->timeout ) ) {
    209                         CHECK_POSIX_DO2(  pthread_cond_timedwait( &exp_cond, &exp_lock, &first->timeout ),
    210                                         ETIMEDOUT, /* ETIMEDOUT is a normal error, continue */,
    211                                         /* on other error, */ break );
    212 
    213                         /* on wakeup, loop */
    214                         goto again;
     209                        int ret;
     210
     211                        ret = pthread_cond_timedwait(&exp_cond, &exp_lock, &first->timeout);
     212                        switch (ret) {
     213                        case 0:
     214                        case ETIMEDOUT:
     215                                /* on wakeup or time-out, loop */
     216                                goto again;
     217                        case EINVAL:
     218                                if (clock_gettime(CLOCK_REALTIME, &now) < 0) {
     219                                        break;
     220                                }
     221                                if (TS_IS_INFERIOR(&now, &first->timeout)) {
     222                                        TRACE_DEBUG(FULL, "'pthread_cond_timedwait(&exp_cond, &exp_lock, &first->timeout)' : timer expired before loop could start");
     223                                        goto again;
     224                                }
     225                                /* FALLTHROUGH */
     226                        default:
     227                                TRACE_ERROR("ERROR: in 'pthread_cond_timedwait(&exp_cond, &exp_lock, &first->timeout)' :\t%s", strerror(ret));
     228                                break;
     229                        }
    215230                }
    216231
Note: See TracChangeset for help on using the changeset viewer.