Example #1
0
void mod_rmmod (flux_t h, opt_t opt)
{
    char *modname = NULL;

    if (opt.argc != 1)
        usage ();
    modname = opt.argv[0];
    if (opt.direct) {
        char *service = getservice (modname);
        char *topic = xasprintf ("%s.rmmod", service);
        char *json_str = flux_rmmod_json_encode (modname);
        assert (json_str != NULL);
        flux_rpc_t *r = flux_rpc_multi (h, topic, json_str, opt.nodeset, 0);
        if (!r)
            err_exit ("%s", topic);
        while (!flux_rpc_completed (r)) {
            uint32_t nodeid = FLUX_NODEID_ANY;
            if (flux_rpc_get (r, &nodeid, NULL) < 0)
                err ("%s[%d]", topic, nodeid == FLUX_NODEID_ANY ? -1 : nodeid);
        }
        flux_rpc_destroy (r);
        free (topic);
        free (service);
        free (json_str);
    } else {
        if (flux_modctl_unload (h, opt.nodeset, modname) < 0)
            err_exit ("%s", modname);
    }
}
Example #2
0
void test_rmmod_codec (void)
{
    char *json_str;
    char *s = NULL;

    json_str = flux_rmmod_json_encode ("xyz");
    ok (json_str != NULL,
        "flux_rmmod_json_encode works");
    ok (flux_rmmod_json_decode (json_str, &s) == 0
        && s != NULL && !strcmp (s, "xyz"),
        "flux_rmmod_json_decode works");
    free (s);
    free (json_str);
}