Exemplo n.º 1
0
void *server_thr(void *arg) {
    int       ferr;
    int       lerr;
    int       max_msgs = gmaxc * gloop;
    bool      mon_msg;
    Test_SRE  sre;
    int       status;
    int       whoami = ginxs++;

    arg = arg; // touch
    for (;;) {
        if (gsre_count >= max_msgs)
            break;
        if (gshutdown)
            break;
        do {
            lerr = XWAIT(LREQ, 100);
            lerr = XMSG_LISTEN_((short *) &sre.sre,  // sre
                                0,                   // listenopts
                                0);                  // listenertag
        } while (lerr == XSRETYPE_NOWORK);
        mon_msg = (sre.sre.sre_flags & XSRE_MON);
        if (mon_msg) {
            int msg_size = sre.sre.sre_reqDataSize;
            char *msg = new char[msg_size];
            ferr = XMSG_READDATA_(sre.sre.sre_msgId,     // msgid
                                  msg,                   // reqdata
                                  (ushort) msg_size);    // bytecount
            assert(ferr == XZFIL_ERR_OK);
            pp_check_mon_msg(msg);
            pp_check_mon_msg_shutdown(msg);
            XMSG_REPLY_(sre.sre.sre_msgId,   // msgid
                        NULL,                // replyctrl
                        0,                   // replyctrlsize
                        NULL,                // replydata
                        0,                   // replydatasize
                        0,                   // errorclass
                        NULL);               // newphandle
            delete [] msg;
            if (gshutdown)
                break;
        } else {
            status = gmutex.lock();
            TEST_CHK_STATUSOK(status);
            gsre_count++;
            status = gmutex.unlock();
            TEST_CHK_STATUSOK(status);
            if (gverbose)
                printf("s-%d: have work, sre-count=%d\n",
                       whoami, gsre_count);
            server(whoami, &sre);
        }
    }
    return NULL;
}
Exemplo n.º 2
0
void *server_thr(void *arg) {
    int       lerr;
    int       max_msgs = maxcp * maxc * loop;
    Test_SRE  sre;
    Test_SRE *srep;
    int       status;
    int       whoami = inxs++;

    arg = arg; // touch
    for (;;) {
        if (thrlisten) {
            sre.fin = false;
            if (sre_count >= max_msgs)
                break;
            do {
                lerr = XWAIT(LREQ, -1);
                lerr = XMSG_LISTEN_((short *) &sre.sre,  // sre
                                    0,                   // listenopts
                                    0);                  // listenertag
            } while (lerr == XSRETYPE_NOWORK);
            status = mutex.lock();
            TEST_CHK_STATUSOK(status);
            sre_count++;
            status = mutex.unlock();
            TEST_CHK_STATUSOK(status);
            srep = &sre;
        } else
            srep = (Test_SRE *) work_q.remove();
        if (verbose)
            printf("s-%d: have work, fin=%d\n", whoami, srep->fin);
        if (srep->fin)
            break;
        server(whoami, srep);
        if (!thrlisten)
            free_q.add(&srep->link);
    }
    return NULL;
}