Changeset 417a136 for lib/ior-thread.c


Ignore:
Timestamp:
12/18/08 14:07:58 (13 years ago)
Author:
Perry Lorier <perry@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, 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:
398fa86
Parents:
cf30639
Message:

Use pthread_join() to tell when we've finished cleaning up

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/ior-thread.c

    rcf30639 r417a136  
    2929        pthread_mutex_t mutex;
    3030        bool closing;
    31         bool closed;
    3231        io_t *io;
    3332};
     
    7978        wandio_destroy(DATA(state)->io);
    8079
    81         DATA(state)->closed = true;
    8280        pthread_cond_signal(&DATA(state)->data_ready);
    8381        pthread_mutex_unlock(&DATA(state)->mutex);
     
    107105        DATA(state)->io = parent;
    108106        DATA(state)->closing = false;
    109         DATA(state)->closed = false;
    110107
    111108        pthread_create(&DATA(state)->producer,NULL,thread_producer,state);
     
    173170        DATA(io)->closing = true;
    174171        pthread_cond_signal(&DATA(io)->space_avail);
     172        pthread_mutex_unlock(&DATA(io)->mutex);
    175173
    176         /* Wait until the producer thread dies */
    177         while (!DATA(io)->closed) {
    178                 pthread_cond_wait(&DATA(io)->data_ready, &DATA(io)->mutex);
    179         }
    180         pthread_mutex_unlock(&DATA(io)->mutex);
     174        /* Wait for the thread to exit */
     175        pthread_join(&DATA(io)->producer, NULL);
    181176        free(DATA(io));
    182177        free(io);
Note: See TracChangeset for help on using the changeset viewer.