示例#1
0
int main(int argc, char *argv[]) {
    _xcc_status         cc;
    bool                client = false;
    int                 closes;
    int                 count_read;
    int                 count_written;
    int                 ferr;
    short               filenumr;
    short               filenums[MAX_SRV];
    int                 inxl;
    int                 inxs;
    int                 loop = 10;
    int                 maxcp = 1;
    int                 maxsp = 1;
    bool                mq = false;
    char                serv[20];
    xzsys_ddl_smsg_def *sys_msg = (xzsys_ddl_smsg_def *) recv_buffer;
    bool                verbose = false;
    TAD                 zargs[] = {
      { "-client",    TA_Bool, TA_NOMAX,    &client    },
      { "-loop",      TA_Int,  TA_NOMAX,    &loop      },
      { "-maxcp",     TA_Int,  MAX_CLI,     &maxcp     },
      { "-maxsp",     TA_Int,  MAX_SRV,     &maxsp     },
      { "-mq",        TA_Bool, TA_NOMAX,    &mq        },
      { "-server",    TA_Ign,  TA_NOMAX,    NULL       },
      { "-v",         TA_Bool, TA_NOMAX,    &verbose   },
      { "",           TA_End,  TA_NOMAX,    NULL       }
    };

    ferr = file_init(&argc, &argv);
    TEST_CHK_FEOK(ferr);
    msfs_util_init_fs(&argc, &argv, file_debug_hook);
    arg_proc_args(zargs, false, argc, argv);
    util_test_start(client);
    ferr = file_mon_process_startup(!client);  // system messages?
    TEST_CHK_FEOK(ferr);
    ferr = msg_mon_get_my_process_name(my_name, BUFSIZ);
    util_check("msg_mon_get_my_process_name", ferr);

    if (client) {
        for (inxl = 0; inxl < loop; inxl++) {
            for (inxs = 0; inxs < maxsp; inxs++) {
                sprintf(serv, "$srv%d", inxs);
                ferr = BFILE_OPEN_(serv, (short) strlen(serv), &filenums[inxs],
                                   0, 0, 0, 0, 0, 0, 0, NULL);
                TEST_CHK_FEOK(ferr);
            }
            for (inxs = 0; inxs < maxsp; inxs++) {
                sprintf(send_buffer, "hello, greetings %d from %s, inx=%d",
                        inxs, my_name, inxl);
                cc = BWRITEREADX(filenums[inxs],
                                 send_buffer,
                                 (int) (strlen(send_buffer) + 1), // cast
                                 BUFSIZ,
                                 &count_read,
                                 0);
                TEST_CHK_CCEQ(cc);
                if (mq) {
                    if ((inxl % 100) == 0)
                        printf("count=%d\n", inxl);
                } else
                    printf("%s\n", send_buffer);
            }
            for (inxs = 0; inxs < maxsp; inxs++) {
                ferr = BFILE_CLOSE_(filenums[inxs], 0);
                TEST_CHK_FEOK(ferr);
            }
        }
    } else {
        closes = 0;
        ferr = BFILE_OPEN_((char *) "$RECEIVE", 8, &filenumr,
                           0, 0, 0,
                           1, 0, // sys msg
                           0, 0, NULL);
        TEST_CHK_FEOK(ferr);

        // process requests
        for (inxl = 0;; inxl++) {
            cc = BREADUPDATEX(filenumr,
                              recv_buffer,
                              BUFSIZ,
                              &count_read,
                              0);
            if (_xstatus_ne(cc)) {
                int mt = sys_msg->u_z_msg.z_msgnumber[0];
                if (verbose) {
                    if (mt == XZSYS_VAL_SMSG_CLOSE)
                        printf("inx=%d, type=%d, cc=%d\n", inxl, mt, closes);
                    else
                        printf("inx=%d, type=%d\n", inxl, mt);
                }
                if (mt == XZSYS_VAL_SMSG_CLOSE)
                    closes++;
                count_read = 0;
            } else {
                strcat(recv_buffer, "- reply from ");
                strcat(recv_buffer, my_name);
                count_read = (int) (strlen(recv_buffer) + 1); // cast
            }
            cc = BREPLYX(recv_buffer,
                         count_read,
                         &count_written,
                         0,
                         XZFIL_ERR_OK);
            TEST_CHK_CCEQ(cc);
            if (closes >= maxcp * loop)
                break;
        }
        ferr = BFILE_CLOSE_(filenumr, 0);
        TEST_CHK_FEOK(ferr);
    }
    ferr = file_mon_process_shutdown();
    TEST_CHK_FEOK(ferr);
    util_test_finish(client);
    return 0;
}
示例#2
0
int main(int argc, char *argv[]) {
    bool            bidir = false;
    bool            bm = false;
    void           *buf;
    double          busy;
    _xcc_status     cc;
    int             count_read;
    int             count_written;
    int             count_xferred;
    int             dsize = 1024;
    int             ferr;
    short           filenum[MAX_SERVERS];
    short           filenumr;
    int             inx;
    int             loop = 10;
    int             max;
    int             maxsp = 1;
    bool            mq = false;
    bool            nocopy = false;
    bool            nowaitc = false;
    bool            nowaits = false;
    int             pinx;
    struct rusage   r_start;
    struct rusage   r_stop;
    char           *recv_buffer_ptr;
    RI_Type         ri;
    short           sender_len;
    int             sys_msg;
    struct timeval  t_elapsed_data;
    struct timeval  t_elapsed_open;
    struct timeval  t_elapsed_total;
    struct timeval  t_start_data;
    struct timeval  t_start_total;
    struct timeval  t_stop;
    SB_Tag_Type     tag;
    short           tfilenum;
    int             timeout = -1;
    bool            verbose = false;
    TAD             zargs[] = {
      { "-bidir",     TA_Bool, TA_NOMAX,    &bidir        },
      { "-bm",        TA_Bool, TA_NOMAX,    &bm           },
      { "-client",    TA_Bool, TA_NOMAX,    &client       },
      { "-dsize",     TA_Int,  MAX_DBUF,    &dsize        },
      { "-loop",      TA_Int,  TA_NOMAX,    &loop         },
      { "-maxcp",     TA_Int,  MAX_CLIENTS, &maxcp        },
      { "-maxsp",     TA_Int,  MAX_SERVERS, &maxsp        },
      { "-mq",        TA_Bool, TA_NOMAX,    &mq           },
      { "-nocopy",    TA_Bool, TA_NOMAX,    &nocopy       },
      { "-nowaitc",   TA_Bool, TA_NOMAX,    &nowaitc      },
      { "-nowaits",   TA_Bool, TA_NOMAX,    &nowaits      },
      { "-server",    TA_Ign,  TA_NOMAX,    NULL          },
      { "",           TA_End,  TA_NOMAX,    NULL          }
    };

    for (inx = 0; inx < MAX_CLIENTS; inx++)
        account[inx] = 0;
    signal(SIGUSR2, printaccount);
    ferr = file_init(&argc, &argv);
    TEST_CHK_FEOK(ferr);
    msfs_util_init_fs(&argc, &argv, file_debug_hook);
    arg_proc_args(zargs, false, argc, argv);
    if (maxcp < 0)
        maxcp = 1;
    if (maxsp < 0)
        maxsp = 1;
    util_test_start(client);
    ferr = file_mon_process_startup(!client);  // system messages?
    TEST_CHK_FEOK(ferr);
    if (nocopy) {
        ferr = file_buf_register(buf_alloc, buf_free);
        TEST_CHK_FEOK(ferr);
    }
    ferr = msg_mon_get_my_process_name(my_name, BUFSIZ);
    TEST_CHK_FEOK(ferr);

    // process-wait for clients/servers/shell
    ferr = msfs_util_wait_process_count(MS_ProcessType_Generic,
                                        maxcp + maxsp + 1,
                                        NULL,
                                        verbose);
    if (client)
        sleep(1);
    util_time_timer_start(&t_start_total);
    if (client) {
        inx = atoi(&my_name[4]);
        printf("dsize=%d, loop=%d\n", dsize, loop);
        for (pinx = 0; pinx < maxsp; pinx++) {
            sprintf(serv, "$srv%d", pinx);
            ferr = BFILE_OPEN_(serv, (short) strlen(serv), &filenum[pinx],
                               0, 0, nowaitc ? (short) 1 : (short) 0,
                               0, 0, 0, 0, NULL);
            TEST_CHK_FEOK(ferr);
        }
        util_time_timer_start(&t_start_data);
        util_cpu_timer_start(&r_start);
        util_time_elapsed(&t_start_total, &t_start_data, &t_elapsed_open);
        max = loop;
        for (inx = 0; inx < max; inx++) {
            for (pinx = 0; pinx < maxsp; pinx++) {
                if (pinx == 0) {
                    if (verbose)
                        printf("%s-count=%d\n", my_name, inx);
                    else if (mq && ((inx % 1000) == 0))
                        printf("%s-count=%d\n", my_name, inx);
                }
                cc = BWRITEREADX(filenum[pinx],
                                 send_buffer,
                                 (int) dsize, // cast
                                 bidir ? dsize : 0,
                                 &count_read,
                                 0);
            }
            for (pinx = 0; pinx < maxsp; pinx++) {
                if (nowaitc) {
                    TEST_CHK_CCEQ(cc);
                    tfilenum = filenum[pinx];
                    cc = BAWAITIOX(&tfilenum,
                                   &buf,
                                   &count_xferred,
                                   &tag,
                                   timeout,
                                   NULL);
                    TEST_CHK_CCEQ(cc);
                }
            }
        }
    } else {
        ferr = BFILE_OPEN_((char *) "$RECEIVE", 8, &filenumr,
                           0, 0, nowaits ? (short) 1 : (short) 0, // nowait
                           1, 0, // sys msg
                           0, 0, NULL);
        TEST_CHK_FEOK(ferr);
        util_time_timer_start(&t_start_data);
        util_cpu_timer_start(&r_start);
        max = maxcp * loop;
        for (inx = 0; inx < max; inx++) {
            if (nocopy) {
                cc = file_buf_readupdatex(filenumr,
                                          &recv_buffer_ptr,
                                          &count_read,
                                          0);
                buf_free(recv_buffer_ptr);
            } else
                cc = BREADUPDATEX(filenumr,
                                  recv_buffer,
                                  (int) dsize, // cast
                                  &count_read,
                                  0);
            if (nowaits) {
                tfilenum = -1;
                cc = BAWAITIOX(&tfilenum,
                               &buf,
                               &count_xferred,
                               &tag,
                               timeout,
                               NULL);
                // don't check cc - could be sys msg
                sys_msg = _xstatus_ne(cc);
            } else
                sys_msg = _xstatus_ne(cc);
            if (sys_msg)
                inx--;
            if (!sys_msg) {
                getri(&ri);
                ferr = XPROCESSHANDLE_DECOMPOSE_(TPT_REF(ri.sender),
                                                 NULL, // cpu
                                                 NULL, // pin
                                                 NULL, // nodenumber
                                                 NULL, // nodename
                                                 0,    // nodename
                                                 NULL, // nodename_length
                                                 sender,
                                                 sizeof(sender),
                                                 &sender_len,
                                                 NULL); // sequence_number
                TEST_CHK_FEOK(ferr);
                sender[sender_len] = 0;
                if (verbose)
                    printf("sender=%s\n", sender);
                char *p = &sender[4]; // past $cli
                int sender_inx = atoi(p);
                account[sender_inx]++;
            }
            cc = BREPLYX(recv_buffer,
                         bidir ? dsize : 0,
                         &count_written,
                         0,
                         XZFIL_ERR_OK);
            TEST_CHK_CCEQ(cc);
        }
    }

    util_cpu_timer_stop(&r_stop);
    util_time_timer_stop(&t_stop);
    util_time_elapsed(&t_start_total, &t_stop, &t_elapsed_total);
    util_time_elapsed(&t_start_data, &t_stop, &t_elapsed_data);
    util_cpu_timer_busy(&r_start, &r_stop, &t_elapsed_data, &busy);

    if (client) {
        if (!bm) {
            print_elapsed("", &t_elapsed_total);
            print_elapsed(" (data)", &t_elapsed_data);
            print_elapsed(" (open)", &t_elapsed_open);
        }
        print_rate(bm, "", bidir ? 2 * loop : loop, dsize, &t_elapsed_data, busy);
    } else
        print_server_busy(bm, "", busy);

    if (client) {
        for (pinx = 0; pinx < maxsp; pinx++) {
            ferr = BFILE_CLOSE_(filenum[pinx], 0);
            TEST_CHK_FEOK(ferr);
        }
    } else {
        ferr = BFILE_CLOSE_(filenumr, 0);
        TEST_CHK_FEOK(ferr);
        ferr = file_mon_process_close();
        TEST_CHK_FEOK(ferr);
    }

    ferr = file_mon_process_shutdown();
    TEST_CHK_FEOK(ferr);
    util_test_finish(client);
    printaccount(0);
    return 0;
}
示例#3
0
int main(int argc, char *argv[]) {
    bool           abort1 = false;
    bool           abort2 = false;
    void          *buf;
    _xcc_status    cc;
    bool           client = false;
    int            count_read;
    int            count_written;
    int            count_xferred;
    int            dsize = 1024;
    int            ferr;
    short          filenum;
    int            inx;
    int            loop = 10;
    short          mt;
    char           my_name[BUFSIZ];
    bool           verbose = false;
    SB_Tag_Type    tag;
    short          tfilenum;
    int            timeout = -1;
    TAD            zargs[] = {
        { "-abort1",    TA_Bool, TA_NOMAX,    &abort1    },
        { "-abort2",    TA_Bool, TA_NOMAX,    &abort2    },
        { "-client",    TA_Bool, TA_NOMAX,    &client    },
        { "-loop",      TA_Int,  TA_NOMAX,    &loop      },
        { "-server",    TA_Ign,  TA_NOMAX,    NULL       },
        { "-v",         TA_Bool, TA_NOMAX,    &verbose   },
        { "",           TA_End,  TA_NOMAX,    NULL       }
    };

    ferr = file_init(&argc, &argv);
    TEST_CHK_FEOK(ferr);
    msfs_util_init_fs(&argc, &argv, file_debug_hook);
    arg_proc_args(zargs, false, argc, argv);
    util_test_start(client);
    ferr = file_mon_process_startup(!client);  // system messages?
    TEST_CHK_FEOK(ferr);
    ferr = msg_mon_get_my_process_name(my_name, BUFSIZ);
    util_check("msg_mon_get_my_process_name", ferr);

    if (client) {
        ferr = BFILE_OPEN_((char *) "$srv", 4, &filenum,
                           0, 0, (short) 1, // nowait
                           0, 0, 0, 0, NULL);
        if (verbose)
            printf("client open ferr=%d\n", ferr);
        TEST_CHK_FEOK(ferr);
        for (inx = 0; inx < loop; inx++) {
            sprintf(send_buffer, "hello, greetings from %s, inx=%d",
                    my_name, inx);
            cc = BWRITEREADX(filenum,
                             send_buffer,
                             (unsigned short) (strlen(send_buffer) + 1), // cast
                             0,
                             &count_read,
                             0);
            if (verbose)
                printf("client wr cc=%d\n", cc);
            TEST_CHK_CCEQ(cc);
            tfilenum = -2;
            cc = BAWAITIOX(&tfilenum,
                           &buf,
                           &count_xferred,
                           &tag,
                           timeout,
                           NULL);
            if (verbose)
                printf("client awaitiox cc=%d, fn=%d\n", cc, tfilenum);
            if (abort1) {
                if (_xstatus_ne(cc)) {
                    sleep(1);
                    inx--;
                    continue;
                }
            } else {
                TEST_CHK_CCEQ(cc);
            }
            printf("%s\n", send_buffer);
        }
    } else {
        ferr = BFILE_OPEN_((char *) "$RECEIVE", 8, &filenum,
                           0, 0, (short) 0,
                           1, 0, // sys msg
                           0, 0, NULL);
        TEST_CHK_FEOK(ferr);
        if (abort1) {
        } else if (abort2) {
            loop -= 2;
        } else {
            loop += 2;
        }
        for (inx = 0; inx < loop; inx++) {
            if (abort1 && (inx == 3))
                util_abort_core_free();
            cc = BREADUPDATEX(filenum,
                              recv_buffer,
                              (int) dsize, // cast
                              &count_read,
                              0);
            if (verbose) {
                memcpy(&mt, recv_buffer, sizeof(mt));
                printf("server cc=%d, mt=%d\n", cc, mt);
            }
            cc = BREPLYX(recv_buffer,
                         0,
                         &count_written,
                         0,
                         XZFIL_ERR_OK);
            TEST_CHK_CCEQ(cc);
        }
    }

    if (client) {
        ferr = BFILE_CLOSE_(filenum, 0);
        TEST_CHK_FEOK(ferr);
    } else {
        ferr = BFILE_CLOSE_(filenum, 0);
        TEST_CHK_FEOK(ferr);
    }

    ferr = file_mon_process_shutdown();
    TEST_CHK_FEOK(ferr);
    util_test_finish(client);
    return 0;
}
示例#4
0
int main(int argc, char *argv[]) {
    void           *buf;
    _xcc_status     cc;
    bool            client = false;
    unsigned short  count_read;
    unsigned short  count_written;
    unsigned short  count_xferred;
    int             ferr;
    short           filenum;
    int             inx;
    short           lasterr;
    int             loop = 10;
    char            my_name[BUFSIZ];
    bool            nowait = true;
    char            recv_buffer[BUFSIZ];
    char            send_buffer[BUFSIZ];
    SB_Tag_Type     tag;
    short           tfilenum;
    int             timeout;
    int             timeout_count;
    TAD             zargs[] = {
      { "-client",    TA_Bool, TA_NOMAX,    &client    },
      { "-loop",      TA_Int,  TA_NOMAX,    &loop      },
      { "-server",    TA_Ign,  TA_NOMAX,    NULL       },
      { "",           TA_End,  TA_NOMAX,    NULL       }
    };

    ferr = file_init(&argc, &argv);
    TEST_CHK_FEOK(ferr);
    msfs_util_init_fs(&argc, &argv, file_debug_hook);
    arg_proc_args(zargs, false, argc, argv);
    util_test_start(client);
    ferr = file_mon_process_startup(!client); // system messages
    TEST_CHK_FEOK(ferr);
    util_gethostname(my_name, sizeof(my_name));

    if (client) {
        timeout_count = 0;
        ferr = XFILE_OPEN_((char *) "$srv", 4, &filenum,
                           0, 0, nowait ? (short) 1 : (short) 0,
                           0, 0, 0, 0, NULL);
        TEST_CHK_FEOK(ferr);
        for (inx = 0; inx < loop; inx++) {
            sprintf(send_buffer, "hello, greetings from %s, inx=%d",
                    my_name, inx);
            cc = XWRITEREADX(filenum,
                             send_buffer,
                             (short) (strlen(send_buffer) + 1),
                             BUFSIZ,
                             &count_read,
                             0);
            if (nowait) {
                TEST_CHK_CCEQ(cc);
                tfilenum = filenum;
                timeout = 1;
                cc = XAWAITIOX(&tfilenum,
                               &buf,
                               &count_xferred,
                               &tag,
                               timeout,
                               NULL);
                if (_xstatus_ne(cc)) {
                    timeout_count++;
                    TEST_CHK_CCNE(cc);
                    ferr = XFILE_GETINFO_(filenum,
                                          &lasterr,
                                          NULL,
                                          0,
                                          NULL,
                                          NULL,
                                          NULL);
                    assert(lasterr == XZFIL_ERR_TIMEDOUT);
                    tfilenum = filenum;
                    timeout = 200;
                    cc = XAWAITIOX(&tfilenum,
                                   &buf,
                                   &count_xferred,
                                   &tag,
                                   timeout,
                                   NULL);
                    TEST_CHK_CCEQ(cc);
                }
            } else {
                TEST_CHK_CCNE(cc);
                ferr = XFILE_GETINFO_(-1, &lasterr, NULL, 0, NULL, NULL, NULL);
                TEST_CHK_FEOK(ferr);
                assert(lasterr == XZFIL_ERR_TIMEDOUT);
            }
            printf("%s\n", send_buffer);
        }
        assert(timeout_count);
        ferr = XFILE_CLOSE_(filenum, 0);
        TEST_CHK_FEOK(ferr);
    } else {
        ferr = XFILE_OPEN_((char *) "$RECEIVE", 8, &filenum,
                           0, 0, 0,
                           1, 1, // no sys msg
                           0, 0, NULL);
        TEST_CHK_FEOK(ferr);
        for (inx = 0; inx < loop; inx++) {
            cc = XREADUPDATEX(filenum,
                              recv_buffer,
                              BUFSIZ,
                              &count_read,
                              0);
            SB_Thread::Sthr::sleep(30); // cause timeout
            TEST_CHK_CCEQ(cc);
            strcat(recv_buffer, "- reply from ");
            strcat(recv_buffer, my_name);
            count_read = (short) (strlen(recv_buffer) + 1);
            cc = XREPLYX(recv_buffer,
                         count_read,
                         &count_written,
                         0,
                         XZFIL_ERR_OK);
            TEST_CHK_CCEQ(cc);
        }
        ferr = XFILE_CLOSE_(filenum, 0);
        TEST_CHK_FEOK(ferr);
    }
    ferr = file_mon_process_shutdown();
    TEST_CHK_FEOK(ferr);
    util_test_finish(client);
    return 0;
}
示例#5
0
int main(int argc, char *argv[]) {
    enum                    { MAX_RETRIES = 100 };
    enum                    { SLEEP_US    = 1000 };
    bool                      attach = false;
    _xcc_status               cc;
    bool                      client = false;
    int                       count;
    int                       count_read;
    int                       count_written;
    bool                      dif = false;
    double                    dloop;
    double                    dms;
    double                    dsec;
    int                       err;
    bool                      exec = false;
    int                       ferr;
    bool                      fin = false;
    MS_Mon_Process_Info_Type  info;
    MS_Mon_Process_Info_Type *infop;
    int                       inx;
    int                       inx2;
    int                       inx3;
    short                     len;
    short                     lerr;
    short                     lerr2;
    int                       loop = 10;
    int                       max;
    int                       nid;
    pid_t                     pid;
    int                       sargc;
    ssize_t                   size;
    int                       snid;
    int                       spid;
    bool                      startup = false;
    xzsys_ddl_smsg_def       *sys_msgp = (xzsys_ddl_smsg_def *) recv_buffer;
    int                       sys_msg;
    int                       sys_msg_count;
    bool                      verbose = false;
    TAD                       zargs[] = {
      { "-attach",    TA_Bool, TA_NOMAX,    &attach    },
      { "-client",    TA_Bool, TA_NOMAX,    &client    },
      { "-dif",       TA_Bool, TA_NOMAX,    &dif       },
      { "-exec",      TA_Bool, TA_NOMAX,    &exec      },
      { "-loop",      TA_Int,  TA_NOMAX,    &loop      },
      { "-maxsp",     TA_Int,  TA_NOMAX,    &maxsp     },
      { "-server",    TA_Ign,  TA_NOMAX,    NULL       },
      { "-startup",   TA_Bool, TA_NOMAX,    &startup   },
      { "-trace",     TA_Bool, TA_NOMAX,    &trace     },
      { "-v",         TA_Bool, TA_NOMAX,    &verbose   },
      { "-verbose",   TA_Ign,  TA_NOMAX,    NULL       },
      { "",           TA_End,  TA_NOMAX,    NULL       }
    };

    arg_proc_args(zargs, false, argc, argv);
    sprintf(fifo1, "%s-%s", FIFO1, getenv("USER"));
    sprintf(fifo2, "%s-%s", FIFO2, getenv("USER"));
    if (trace)
        msg_init_trace();
    if (exec)
        return 0;
    if (startup) {
        err = fifo_open(fifo1, O_WRONLY);
        assert(err != -1);
        ffds[1] = err;
        err = fifo_open(fifo2, O_RDONLY);
        assert(err != -1);
        ffds[0] = err;
        if (trace)
            trace_printf("cli: writing fifo\n");
        size = write(ffds[1], recv_buffer, 1);
        if (trace)
            trace_printf("cli: fifo write, size=%d\n", (int) size);
        assert(size == 1);
        if (trace)
            trace_printf("cli: fifo written\n");
        close(ffds[1]);
        return 0;
    }
    if (attach)
        ferr = file_init_attach(&argc, &argv, false, NULL);
    else
        ferr = file_init(&argc, &argv);
    TEST_CHK_FEOK(ferr);
    util_test_start(client);
    ferr = msg_mon_process_startup(true); // system messages
    util_check("msg_mon_process_startup", ferr);
    ferr = msg_mon_get_my_process_name(procname, BUFSIZ);
    util_check("msg_mon_get_my_process_name", ferr);
    ferr = msg_mon_get_process_info(procname, &nid, &pid);
    TEST_CHK_FEOK(ferr);

    if (trace)
        trace_printf("proc=%s, nid=%d, pid=%d\n", procname, nid, pid);
    dloop = (double) loop;
    for (inx = 0; inx < T_MAX; inx++)
        t_elapsed[inx] = 0.0;
    if (client) {
        printf("loop=%d, maxsp=%d\n", loop, maxsp);
        sargc = argc;
        assert(sargc < MAX_ARGS);
        for (inx2 = 0; inx2 < argc; inx2++) {
            if (strcmp(argv[inx2], "-client") == 0)
                sargv[inx2] = (char *) "-server";
            else
                sargv[inx2] = argv[inx2];
            if (strcmp(argv[inx2], "-attach") == 0)
                sargv[inx2] = (char *) "-server";
        }
        sargv[argc] = NULL;
        sprintf(sprog, "%s/%s", getenv("PWD"), argv[0]);
        time_start(T_TOTAL);
        for (inx = 0; inx < loop; inx += maxsp) {
            if (dif)
                snid = -1;
            else
                snid = nid;
            max = loop - inx;
            if (max > maxsp)
                max = maxsp;
            for (inx2 = 0; inx2 < max; inx2++)
                sname[inx2][0] = 0; // mon picks name
            if (trace)
                trace_printf("cli: newproc, inx=%d\n", inx);
            time_start(T_NEWPROC);
            for (inx2 = 0; inx2 < max; inx2++) {
                ferr = msg_mon_start_process(sprog,                  // prog
                                             sname[inx2],            // name
                                             sname[inx2],            // ret_name
                                             sargc,                  // argc
                                             sargv,                  // argv
                                             TPT_REF2(sphandle,inx2),// phandle
                                             false,                  // open
                                             &soid[inx2],            // oid
                                             MS_ProcessType_Generic, // type
                                             0,                      // priority
                                             false,                  // debug
                                             false,                  // backup
                                             &snid,                  // nid
                                             &spid,                  // pid
                                             NULL,                   // infile
                                             NULL);                  // outfile
                TEST_CHK_FEOK(ferr);
            }
            time_stop(T_NEWPROC);
            time_elapsed(T_NEWPROC);

            // wait here until processes are 'up'
            // so that open timing is correct
            inx3 = 0;
            for (inx2 = 0; inx2 < max; inx2++) {
                ferr = msg_mon_get_process_info_detail(sname[inx2], &info);
                TEST_CHK_FEOK(ferr);
                if (info.state != MS_Mon_State_Up) {
                    inx3++;
                    if (inx3 > MAX_RETRIES) {
                        printf("process %s did not enter 'UP' state\n", sname[inx2]);
                        assert(inx3 < MAX_RETRIES);
                    }
                    usleep(SLEEP_US);
                    inx2--;
                    continue;
                } else
                    inx3 = 0;
            }

            if (trace)
                trace_printf("cli: open, inx=%d\n", inx);
            time_start(T_OPEN);
            for (inx2 = 0; inx2 < max; inx2++) {
                if (trace)
                    trace_printf("cli: opening inx=%d, name=%s\n", inx, sname[inx2]);
                len = (short) strlen(sname[inx2]);
                ferr = BFILE_OPEN_(sname[inx2], len, &sfilenum[inx2],
                                   0, 0, 0,
                                   0, 0, 0, 0);
                if (trace)
                    trace_printf("cli: open, inx=%d, name=%s, ferr=%d\n",
                           inx, sname[inx2], ferr);
                TEST_CHK_FEOK(ferr);
            }
            time_stop(T_OPEN);
            time_elapsed(T_OPEN);

            if (trace)
                trace_printf("cli: procinfo, inx=%d\n", inx);
            time_start(T_PROCINFO);
            for (inx2 = 0; inx2 < max; inx2++) {
                ferr = msg_mon_get_process_info_detail(sname[inx2], &info);
                TEST_CHK_FEOK(ferr);
            }
            time_stop(T_PROCINFO);
            time_elapsed(T_PROCINFO);

            if (trace)
                trace_printf("cli: procinfo-type, inx=%d\n", inx);
            time_start(T_PROCINFO_TYPE);
            ferr = msg_mon_get_process_info_type(MS_ProcessType_Generic,
                                                 &count,
                                                 MAX_SRV,
                                                 infotype);
            TEST_CHK_FEOK(ferr);
            time_stop(T_PROCINFO_TYPE);
            time_elapsed(T_PROCINFO_TYPE);
            if (verbose) {
                for (inx2 = 0; inx2 < count; inx2++) {
                    infop = &infotype[inx2];
                    char s_em = infop->event_messages ? 'E' : '-';
                    char s_sm = infop->system_messages ? 'S' : '-';
                    char s_pr = infop->pending_replication ? 'R' : '-';
                    char s_pd = infop->pending_delete ? 'D' : '-';
                    char s_s  = infop->state == MS_Mon_State_Up ? 'A' : 'U';
                    char s_o  = infop->opened ? 'O' : '-';
                    char s_p  = infop->paired ? 'P' : infop->backup ? 'B' : '-';
                    printf("%3.3d,%8.8d %3.3d %d %c%c%c%c%c%c%c %-11s %-11s %-15s\n",
                           infop->nid,
                           infop->pid,
                           infop->priority,
                           infop->state,
                           s_em, s_sm, s_pr, s_pd, s_s, s_o, s_p,
                           infop->process_name,
                           infop->parent_name,
                           infop->program);
                }
            }

            if (trace)
                trace_printf("cli: close, inx=%d\n", inx);
            time_start(T_CLOSE);
            for (inx2 = 0; inx2 < max; inx2++) {
                ferr = BFILE_CLOSE_(sfilenum[inx2]);
                TEST_CHK_FEOK(ferr);
            }
            time_stop(T_CLOSE);
            time_elapsed(T_CLOSE);

            // re-open/close
            for (inx2 = 0; inx2 < max; inx2++) {
                if (trace)
                    trace_printf("cli: re-opening inx=%d, name=%s\n",
                           inx, sname[inx2]);
                len = (short) strlen(sname[inx2]);
                ferr = BFILE_OPEN_(sname[inx2], len, &sfilenum[inx2],
                                   0, 0, 0,
                                   0, 0, 0, 0);
                TEST_CHK_FEOK(ferr);
            }
            if (trace)
                trace_printf("cli: re-close, inx=%d\n", inx);
            for (inx2 = 0; inx2 < max; inx2++) {
                ferr = BFILE_CLOSE_(sfilenum[inx2]);
                TEST_CHK_FEOK(ferr);
            }

            if (trace)
                trace_printf("cli: newproc-forkexec, inx=%d\n", inx);
            sargc = 2;
            sargv[0] = argv[0];
            sargv[1] = (char *) "-exec";
            if (trace)
                sargv[sargc++] = (char *) "-trace";
            sargv[sargc] = NULL;
            time_start(T_FORKEXEC);
            for (inx2 = 0; inx2 < max; inx2++) {
                pid = fork();
                assert(pid >= 0);
                if (pid == 0) {
                    // child
                    err = execv(sprog, sargv);
                    assert(err == 0);
                }
            }
            time_stop(T_FORKEXEC);
            time_elapsed(T_FORKEXEC);

            if (trace)
                trace_printf("cli: newproc-forkexec-su, inx=%d\n", inx);
            sargc = 2;
            sargv[0] = argv[0];
            sargv[1] = (char *) "-startup";
            if (trace)
                sargv[sargc++] = (char *) "-trace";
            sargv[sargc] = NULL;
            time_start(T_FORKEXEC_SU);
            for (inx2 = 0; inx2 < max; inx2++) {
                fifo_create(fifo1, fifo2);
                pid = fork();
                assert(pid >= 0);
                if (pid > 0) {
                    // parent
                    err = fifo_open(fifo1, O_RDONLY);
                    assert(err != -1);
                    ffds[0] = err;
                    err = fifo_open(fifo2, O_WRONLY);
                    assert(err != -1);
                    ffds[1] = err;
                    if (trace)
                        trace_printf("cli: reading fifo, inx=%d\n", inx2);
                    size = ::read(ffds[0], recv_buffer, 1);
                    if (trace)
                        trace_printf("cli: fifo read, size=%d\n", (int) size);
                    assert(size == 1);
                    if (trace)
                        trace_printf("cli: fifo read, inx=%d\n", inx2);
                    ::read(ffds[0], recv_buffer, 1);
                    err = fifo_close(ffds[0]);
                    assert(err == 0);
                    err = fifo_close(ffds[1]);
                    assert(err == 0);
                    fifo_destroy(fifo1, fifo1);
                } else {
                    // child
                    err = execv(sprog, sargv);
                    assert(err == 0);
                }
            }
            fifo_destroy(fifo2, fifo2);
            time_stop(T_FORKEXEC_SU);
            time_elapsed(T_FORKEXEC_SU);
        }
    } else {
        sys_msg_count = 0;
        time_start(T_TOTAL);
        ferr = BFILE_OPEN_((char *) "$RECEIVE", 8, &filenumr,
                           0, 0, 0,
                           1, 0); // sys msgs
        TEST_CHK_FEOK(ferr);
        for (inx = 0; !fin; inx++) {
            if (trace)
                trace_printf("srv: readupdate, inx=%d\n", inx);
            cc = BREADUPDATEX(filenumr,
                              recv_buffer,
                              4,
                              &count_read,
                              0);
            sys_msg = _xstatus_ne(cc);
            if (trace && sys_msg)
                trace_printf("srv: rcvd sys msg=%d\n",
                             sys_msgp->u_z_msg.z_msgnumber[0]);
            if (sys_msg) {
                sys_msg_count++;
                inx--;
            }
            lerr2 = BFILE_GETINFO_(filenumr, &lerr);
            TEST_CHK_FEIGNORE(lerr2);
            if (trace)
                trace_printf("srv: reply, inx=%d\n", inx);
            cc = BREPLYX(recv_buffer,
                         (unsigned short) 0,
                         &count_written,
                         0,
                         XZFIL_ERR_OK);
            TEST_CHK_CCEQ(cc);
            if (sys_msg_count >= 4)
                fin = true;
        }
    }
    time_stop(T_TOTAL);
    time_elapsed(T_TOTAL);

    if (client) {
        dsec = time_sec(T_TOTAL);
        dms = dsec * 1000.0;
        printf("elapsed=%f\n", dms);
        printf("open/close/newprocess/processinfo/forkexec=%d\n", loop);
        dsec = time_sec(T_OPEN);
        dms = dsec * 1000.0;
        printf("open            : total-time=%f ms, time/loop=%f ms, ops/sec=%f\n",
               dms, dms / dloop, dloop / dsec);
        dsec = time_sec(T_CLOSE);
        dms = dsec * 1000.0;
        printf("close           : total-time=%f ms, time/loop=%f ms, ops/sec=%f\n",
               dms, dms / dloop, dloop / dsec);
        dsec = time_sec(T_PROCINFO);
        dms = dsec * 1000.0;
        printf("procinfo        : total-time=%f ms, time/loop=%f ms, ops/sec=%f\n",
               dms, dms / dloop, dloop / dsec);
        dsec = time_sec(T_PROCINFO_TYPE);
        dms = dsec * 1000.0;
        printf("procinfo-type   : total-time=%f ms, time/loop=%f ms, ops/sec=%f\n",
               dms, dms / dloop, dloop / dsec);
        dsec = time_sec(T_NEWPROC);
        dms = dsec * 1000.0;
        printf("newproc         : total-time=%f ms, time/loop=%f ms, ops/sec=%f\n",
               dms, dms / dloop, dloop / dsec);
        dsec = time_sec(T_FORKEXEC);
        dms = dsec * 1000.0;
        printf("forkexec        : total-time=%f ms, time/loop=%f ms, ops/sec=%f\n",
               dms, dms / dloop, dloop / dsec);
        dsec = time_sec(T_FORKEXEC_SU);
        dms = dsec * 1000.0;
        printf("forkexec-startup: total-time=%f ms, time/loop=%f ms, ops/sec=%f\n",
               dms, dms / dloop, dloop / dsec);
    }
    ferr = msg_mon_process_shutdown();
    TEST_CHK_FEOK(ferr);
    util_test_finish(client);
    return 0;
}
示例#6
0
int main(int argc, char *argv[]) {
    _bcc_status         bcc;
    void               *buf;
    int                 cancel = 0;
    bool                client = false;
    int                 closes;
    int                 count;
    int                 count_cancel;
    int                 count_read;
    int                 count_written;
    int                 count_xferred;
    int                 ferr;
    int                 inxl;
    int                 inxo;
    int                 inxs;
    int                 inxx;
    int                 loop = 10;
    int                 maxcp = 1;
    int                 maxout = 1;
    int                 maxsp = 1;
    int                 msg_count;
    bool                mq = false;
    short               filenumr;
    short               filenums[MAX_SRV];
    int                 send_len;
    char                serv[20];
    xzsys_ddl_smsg_def *sys_msg = (xzsys_ddl_smsg_def *) recv_buffer;
    SB_Tag_Type         tago;
    short               tfilenum;
    int                 timeout = -1;
    bool                verbose = false;
    TAD                 zargs[] = {
      { "-cancel",    TA_Int,  TA_NOMAX,    &cancel    },
      { "-client",    TA_Bool, TA_NOMAX,    &client    },
      { "-loop",      TA_Int,  TA_NOMAX,    &loop      },
      { "-maxcp",     TA_Int,  MAX_CLI,     &maxcp     },
      { "-maxout",    TA_Int,  MAX_OUT,     &maxout    },
      { "-maxsp",     TA_Int,  MAX_SRV,     &maxsp     },
      { "-mq",        TA_Bool, TA_NOMAX,    &mq        },
      { "-server",    TA_Ign,  TA_NOMAX,    NULL       },
      { "-v",         TA_Bool, TA_NOMAX,    &verbose   },
      { "",           TA_End,  TA_NOMAX,    NULL       }
    };

    ferr = file_init(&argc, &argv);
    TEST_CHK_FEOK(ferr);
    msfs_util_init_fs(&argc, &argv, file_debug_hook);
    arg_proc_args(zargs, false, argc, argv);
    util_test_start(client);
    ferr = file_mon_process_startup(!client);  // system messages?
    TEST_CHK_FEOK(ferr);
    ferr = msg_mon_get_my_process_name(my_name, BUFSIZ);
    util_check("file_mon_get_my_process_name", ferr);

    if (client) {
        ferr = XCONTROLMESSAGESYSTEM(XCTLMSGSYS_SETSENDLIMIT,
                                     XMAX_SETTABLE_SENDLIMIT);
        assert(ferr == XZFIL_ERR_OK);
        for (inxs = 0; inxs < maxsp; inxs++) {
            sprintf(serv, "$srv%d", inxs);
            ferr = BFILE_OPEN_(serv, (short) strlen(serv), &filenums[inxs],
                               0, 0, (short) maxout,
                               0, 0, 0, 0, NULL);
            TEST_CHK_FEOK(ferr);
        }
        msg_count = 0;
        count_cancel = 0;
        for (inxl = 0; inxl < loop; inxl++) {
            count = 0;
            if (cancel)
                count_cancel = rnd(cancel);
            for (inxs = 0; inxs < maxsp; inxs++) {
                for (inxo = 0; inxo < maxout; inxo++) {
                    send_len = rnd(BUFSIZ);
                    bcc = BWRITEREADX(filenums[inxs],
                                      send_buffer[inxo],
                                      send_len,
                                      BUFSIZ,
                                      &count_read,
                                      inxo + 1);
                    out_list[inxs][inxo] = inxo + 1;
                    util_check("BWRITEREADX", ferr);
                }
            }
            for (inxs = 0; inxs < maxsp; inxs++) {
                for (inxo = 0; inxo < maxout; inxo++) {
                    msg_count++;
                    if (verbose)
                        printf("client(%s): msg-count=%d\n",
                               my_name, msg_count);
                    count++;
                    if (cancel && (count >= count_cancel)) {
                        if (verbose)
                            printf("client(%s): cancel, count=%d\n",
                                   my_name, count);
                        count_cancel = rnd(cancel);
                        count = 0;
                        tago = out_list[inxs][inxo];
                        if (tago == 0) {
                            for (inxx = maxout - 1; inxx > 0; inxx--) {
                                tago = out_list[inxs][inxx];
                                if (tago > 0)
                                    break;
                            }
                        }
                        if (verbose)
                            printf("client(%s): cancel, tag=" PFTAG "\n",
                                   my_name, tago);
                        ferr = BCANCELREQ(filenums[inxs], tago);
                        util_check("BCANCELREQ", ferr);
                    } else {
                        tfilenum = filenums[inxs];
                        bcc = BAWAITIOX(&tfilenum,
                                        &buf,
                                        &count_xferred,
                                        &tago,
                                        timeout,
                                        NULL);
                        TEST_CHK_BCCEQ(bcc);
                        assert(tago <= maxout);
                        out_list[inxs][tago-1] = 0;
                    }
                }
            }
            if (mq) {
                if ((inxl % 100) == 0)
                    printf("client(%s): count=%d\n", my_name, inxl);
            }
        }
        for (inxs = 0; inxs < maxsp; inxs++) {
            ferr = BFILE_CLOSE_(filenums[inxs]);
            TEST_CHK_FEOK(ferr);
        }
    } else {
        ferr = XCONTROLMESSAGESYSTEM(XCTLMSGSYS_SETRECVLIMIT,
                                     XMAX_SETTABLE_RECVLIMIT);
        assert(ferr == XZFIL_ERR_OK);
        ferr = XFILE_OPEN_((char *) "$RECEIVE", 8, &filenumr,
                           0, 0, 0,
                           1, 0, // sys msg
                           0, 0, NULL);
        TEST_CHK_FEOK(ferr);
        closes = 0;
        msg_count = 0;
        // process requests
        for (;;) {
            bcc = BREADUPDATEX(filenumr,
                               recv_buffer,
                               BUFSIZ,
                               &count_read,
                               0);
            if (_xstatus_ne(bcc)) {
                int mt = sys_msg->u_z_msg.z_msgnumber[0];
                if (mt == XZSYS_VAL_SMSG_CLOSE) {
                    closes++;
                    if (verbose)
                        printf("server(%s): closes=%d\n",
                               my_name, closes);
                } else {
                    const char *mtstr = msfs_util_get_sysmsg_str(mt);
                    if (verbose)
                        printf("server(%s): type=%s(%d)\n", my_name, mtstr, mt);
                }
            } else {
                msg_count++;
                if (verbose)
                    printf("server(%s): msg-count=%d\n",
                           my_name, msg_count);
            }
            bcc = BREPLYX(recv_buffer,
                          count_read,
                          &count_written,
                          0,
                          XZFIL_ERR_OK);
            TEST_CHK_BCCEQ(bcc);
            if (closes >= maxcp)
                break;
        }
    }
    ferr = file_mon_process_shutdown();
    TEST_CHK_FEOK(ferr);
    util_test_finish(client);
    return 0;
}
示例#7
0
int main(int argc, char *argv[]) {
    _xcc_status         cc;
    bool                client = false;
    int                 count_read;
    int                 count_written;
    int                 ferr;
    short               filenum;
    int                 inx;
    void               *result;
    int                 status;
    SB_Thread::Thread  *thr_cli;
    TAD                 zargs[] = {
      { "-client",    TA_Bool, TA_NOMAX,    &client    },
      { "-loop",      TA_Int,  TA_NOMAX,    &loop      },
      { "-server",    TA_Ign,  TA_NOMAX,    NULL       },
      { "-sname",     TA_Str,  TA_NOMAX,    &sname     },
      { "",           TA_End,  TA_NOMAX,    NULL       }
    };

    ferr = file_init(&argc, &argv);
    TEST_CHK_FEOK(ferr);
    msfs_util_init_fs(&argc, &argv, file_debug_hook);
    arg_proc_args(zargs, false, argc, argv);
    util_test_start(client);
    ferr = file_mon_process_startup(!client);  // system messages?
    TEST_CHK_FEOK(ferr);
    ferr = msg_mon_get_my_process_name(my_name, BUFSIZ);
    util_check("msg_mon_get_my_process_name", ferr);

    if (client) {
        thr_cli = new SB_Thread::Thread(thread_cli_fun, "cli");
        thr_cli->start();
        status = thr_cli->join(&result);
        TEST_CHK_STATUSOK(status);
        delete thr_cli;
    } else {
        ferr = BFILE_OPEN_((char *) "$RECEIVE", 8, &filenum,
                           0, 0, 0,
                           1, 0, // sys msg
                           0, 0, NULL);
        TEST_CHK_FEOK(ferr);
        for (inx = 0; inx < (loop + 4); inx++) {
            cc = BREADUPDATEX(filenum,
                              recv_buffer,
                              BUFSIZ,
                              &count_read,
                              0);
            if (_xstatus_ne(cc)) {
                count_read = 0;
            } else {
                strcat(recv_buffer, "- reply from ");
                strcat(recv_buffer, my_name);
                count_read = (int) (strlen(recv_buffer) + 1); // cast
            }
            cc = BREPLYX(recv_buffer,
                         count_read,
                         &count_written,
                         0,
                         XZFIL_ERR_OK);
            TEST_CHK_CCEQ(cc);
        }
        ferr = BFILE_CLOSE_(filenum, 0);
        TEST_CHK_FEOK(ferr);
    }
    ferr = file_mon_process_shutdown();
    TEST_CHK_FEOK(ferr);
    util_test_finish(client);
    return 0;
}
示例#8
0
int main(int argc, char *argv[]) {
    void           *buf;
    _xcc_status     cc;
    bool            client = false;
    unsigned short  count_read;
    unsigned short  count_written;
    unsigned short  count_xferred;
    int             ferr;
    short           filenum_rcv;
    short           filenum_wr;
    int             inx;
    short           lasterr;
    int             loop = 10;
    char            my_name[BUFSIZ];
    char            recv_buffer[BUFSIZ];
    char            send_buffer[BUFSIZ];
    SB_Tag_Type     tag;
    short           tfilenum;
    int             timeout = -1;
    bool            verbose = false;
    TAD             zargs[] = {
      { "-client",    TA_Bool, TA_NOMAX,    &client    },
      { "-loop",      TA_Int,  TA_NOMAX,    &loop      },
      { "-server",    TA_Ign,  TA_NOMAX,    NULL       },
      { "-v",         TA_Bool, TA_NOMAX,    &verbose   },
      { "",           TA_End,  TA_NOMAX,    NULL       }
    };

    ferr = file_init(&argc, &argv);
    TEST_CHK_FEOK(ferr);
    msfs_util_init_fs(&argc, &argv, file_debug_hook);
    arg_proc_args(zargs, false, argc, argv);
    util_test_start(client);
    ferr = file_mon_process_startup(true); // system messages
    TEST_CHK_FEOK(ferr);
    util_gethostname(my_name, sizeof(my_name));

    // process-wait for client/server/shell
    ferr = msfs_util_wait_process_count(MS_ProcessType_Generic, 3, NULL, verbose);
    TEST_CHK_FEOK(ferr);
    if (client) {
        ferr = XFILE_OPEN_((char *) "$srv", 4, &filenum_wr,
                           0, 0, 1,
                           0, 0, 0, 0, NULL);
        TEST_CHK_FEOK(ferr);
        ferr = XFILE_OPEN_((char *) "$RECEIVE", 8, &filenum_rcv,
                           0, 0, 0,
                           1, 0, // sys msg
                           0, 0, NULL);
        TEST_CHK_FEOK(ferr);
        // read open message
        cc = XREADUPDATEX(filenum_rcv,
                          recv_buffer,
                          BUFSIZ,
                          &count_read,
                          0);
        TEST_CHK_CCNE(cc);
        if (_xstatus_ne(cc)) {
            ferr = XFILE_GETINFO_(-1, &lasterr, NULL, 0, NULL, NULL, NULL);
            TEST_CHK_FEOK(ferr);
            assert(lasterr == XZFIL_ERR_SYSMESS);
        }
        cc = XREPLYX(recv_buffer,
                     0,
                     &count_written,
                     0,
                     XZFIL_ERR_OK);
        TEST_CHK_CCEQ(cc);
        for (inx = 0; inx < loop; inx++) {
            sprintf(send_buffer, "hello, greetings from %s, inx=%d",
                    my_name, inx);
            if (verbose)
                printf("client doing writeread inx=%d\n", inx);
            cc = XWRITEREADX(filenum_wr,
                             send_buffer,
                             (short) (strlen(send_buffer) + 1),
                             BUFSIZ,
                             &count_read,
                             0);
            TEST_CHK_CCEQ(cc);
            if (verbose)
                printf("client doing awaitiox inx=%d\n", inx);
            tfilenum = filenum_wr;
            cc = XAWAITIOX(&tfilenum,
                           &buf,
                           &count_xferred,
                           &tag,
                           timeout,
                           NULL);
            TEST_CHK_CCEQ(cc);
            if (verbose)
                printf("client writeread done inx=%d\n", inx);
            printf("%s\n", send_buffer);
        }
        ferr = XFILE_CLOSE_(filenum_wr, 0);
        TEST_CHK_FEOK(ferr);
        ferr = file_mon_process_close();
        TEST_CHK_FEOK(ferr);
    } else {
        ferr = XFILE_OPEN_((char *) "$RECEIVE", 8, &filenum_rcv,
                           0, 0, 1,
                           1, 0, // sys msg
                           0, 0, NULL);
        TEST_CHK_FEOK(ferr);
        // read open message
        cc = XREADUPDATEX(filenum_rcv,
                          recv_buffer,
                          BUFSIZ,
                          &count_read,
                          0);
        TEST_CHK_CCEQ(cc);
        tfilenum = filenum_rcv;
        cc = XAWAITIOX(&tfilenum,
                       &buf,
                       &count_xferred,
                       &tag,
                       timeout,
                       NULL);
        if (_xstatus_ne(cc)) {
            ferr = XFILE_GETINFO_(-1, &lasterr, NULL, 0, NULL, NULL, NULL);
            TEST_CHK_FEOK(ferr);
            assert(lasterr == XZFIL_ERR_SYSMESS);
        }
        cc = XREPLYX(recv_buffer,
                     0,
                     &count_written,
                     0,
                     XZFIL_ERR_OK);
        TEST_CHK_CCEQ(cc);
        ferr = XFILE_OPEN_((char *) "$cli", 4, &filenum_wr,
                           0, 0, 1,
                           0, 0, 0, 0, NULL);
        for (inx = 0; inx < loop; inx++) {
            sprintf(send_buffer, "i'm the server inx=%d", inx);
            if (verbose)
                printf("server doing readupdate inx=%d\n", inx);
            cc = XREADUPDATEX(filenum_rcv,
                              recv_buffer,
                              BUFSIZ,
                              &count_read,
                              0);
            TEST_CHK_CCEQ(cc);
            if (verbose)
                printf("server doing awaitiox inx=%d\n", inx);
            tfilenum = filenum_rcv;
            cc = XAWAITIOX(&tfilenum,
                           &buf,
                           &count_xferred,
                           &tag,
                           timeout,
                           NULL);
            TEST_CHK_CCEQ(cc);
            if (verbose)
                printf("server awaitiox done inx=%d\n", inx);
            strcat(recv_buffer, "- reply from ");
            strcat(recv_buffer, my_name);
            count_read = (short) (strlen(recv_buffer) + 1);
            if (verbose)
                printf("server doing reply inx=%d\n", inx);
            cc = XREPLYX(recv_buffer,
                         count_read,
                         &count_written,
                         0,
                         XZFIL_ERR_OK);
            TEST_CHK_CCEQ(cc);
            if (verbose)
                printf("server reply done inx=%d\n", inx);
        }
        ferr = XFILE_CLOSE_(filenum_rcv, 0);
        TEST_CHK_FEOK(ferr);
        ferr = file_mon_process_close();
        TEST_CHK_FEOK(ferr);
    }
    ferr = file_mon_process_shutdown();
    TEST_CHK_FEOK(ferr);
    util_test_finish(client);
    return 0;
}