Пример #1
0
static flux_rpc_t *rpc_create (flux_t *h, int rx_expected)
{
    flux_rpc_t *rpc;
    int flags = 0;

    if (!(rpc = calloc (1, sizeof (*rpc)))) {
        errno = ENOMEM;
        return NULL;
    }
    rpc->magic = RPC_MAGIC;
    if (rx_expected == 0) {
        rpc->m.matchtag = FLUX_MATCHTAG_NONE;
    } else {
        if (rx_expected != 1)
            flags |= FLUX_MATCHTAG_GROUP;
        rpc->m.matchtag = flux_matchtag_alloc (h, flags);
        if (rpc->m.matchtag == FLUX_MATCHTAG_NONE) {
            flux_rpc_destroy (rpc);
            return NULL;
        }
    }
    rpc->rx_expected = rx_expected;
    rpc->m.typemask = FLUX_MSGTYPE_RESPONSE;
    rpc->h = h;
    rpc->usecount = 1;
    rpc->nodeid = FLUX_NODEID_ANY;
    return rpc;
}
Пример #2
0
static flux_rpc_t *rpc_create (flux_t h, int flags, int count)
{
    flux_rpc_t *rpc = xzmalloc (sizeof (*rpc));
    if ((flags & FLUX_RPC_NORESPONSE)) {
        rpc->oneway = true;
        rpc->m.matchtag = FLUX_MATCHTAG_NONE;
    } else {
        rpc->nodemap = xzmalloc (sizeof (rpc->nodemap[0]) * count);
        rpc->m.matchtag = flux_matchtag_alloc (h, count);
        if (rpc->m.matchtag == FLUX_MATCHTAG_NONE) {
            flux_rpc_destroy (rpc);
            return NULL;
        }
    }
    rpc->m.bsize = count;
    rpc->m.typemask = FLUX_MSGTYPE_RESPONSE;
    rpc->h = h;
    rpc->usecount = 1;
    return rpc;
}