Comment 4 for bug 541362

Revision history for this message
Jeff Hill (johill-lanl) wrote : Re: crash whil exiting ca client

Some source code for my test:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cadef.h>
#include <epicsVersion.h>
#include <epicsThread.h>

int main(int argc, char **argv)
{

    char name1[40], name2[40];
    chid chid1, chid2;
    long result;
    unsigned i;

    sprintf(name1, "joh:fred");
    sprintf(name2, "joh:jane");

    for ( i=0u; i < 1000; i++ ) {
        result = ca_context_create(ca_disable_preemptive_callback);
        if (result != ECA_NORMAL) {
            fprintf(stderr, "CA error %s occurred while trying to start channel access.n", ca_message(result));
            return(1);
        }

        result = ca_search(name1, &chid1);
        if (result != ECA_NORMAL) {
            fprintf(stderr, "error: problem doing search for %sn", name1);
            return(1);
        }

        result = ca_search(name2, &chid2);
        if (result != ECA_NORMAL) {
            fprintf(stderr, "error: problem doing search for %sn", name2);
            return(1);
        }

        result = ca_pend_io(10);
        if (result != ECA_NORMAL) {
            fprintf(stderr, "warning: problem doing search for PVsn");
        }

        result = ca_state(chid1);
        if (result != cs_conn) {
            result = ca_put(DBR_STRING, chid1, "0");
            if (result != ECA_NORMAL) {
                fprintf(stderr, "error: problem doing put for %sn", name1);
                return(1);
            }
        }

        result = ca_state(chid2);
        if (result != cs_conn) {
            result = ca_put(DBR_STRING, chid2, "0");
            if (result != ECA_NORMAL) {
                fprintf(stderr, "error: problem doing put for %sn", name2);
                return(1);
            }
        }

        result = ca_pend_io(10);

        result = ca_pend_io(10);
        if (result != ECA_NORMAL) {
            fprintf(stderr, "error: problem doing put for PVsn");
        }

        ca_context_destroy();

        epicsThreadSleep ( 1.0 );
    }
    return(0);
}