/* * remove_remote -- (internal) remove remote pool */ static int remove_remote(const char *target, const char *pool_set) { #ifdef USE_RPMEM struct rpmem_target_info *info = rpmem_target_parse(target); if (!info) goto err_parse; struct rpmem_ssh *ssh = rpmem_ssh_exec(info, "--remove", pool_set, "--force", NULL); if (!ssh) { goto err_ssh_exec; } if (rpmem_ssh_monitor(ssh, 0)) goto err_ssh_monitor; int ret = rpmem_ssh_close(ssh); rpmem_target_free(info); return ret; err_ssh_monitor: rpmem_ssh_close(ssh); err_ssh_exec: rpmem_target_free(info); err_parse: return -1; #else FATAL("remote replication not supported"); return -1; #endif }
/* * clnt_wait_disconnect -- wait for disconnection */ void clnt_wait_disconnect(struct rpmem_ssh *ssh) { int ret; ret = rpmem_ssh_monitor(ssh, 0); UT_ASSERTne(ret, 1); }
/* * rpmem_obc_monitor -- monitor connection with target node * * The nonblock variable indicates whether this function should return * immediately (= 1) or may block (= 0). * * If the function detects that socket was closed by remote peer it is * closed on local side and set to -1, so there is no need to call * rpmem_obc_disconnect function. Please take a look at functions' * descriptions to see which functions cannot be used if the connection * has been already closed. * * This function expects there is no data pending on socket, if any data * is pending this function returns an error and sets errno to EPROTO. * * Return values: * 0 - not connected * 1 - connected * < 0 - error */ int rpmem_obc_monitor(struct rpmem_obc *rpc, int nonblock) { if (!rpmem_obc_is_connected(rpc)) return 0; return rpmem_ssh_monitor(rpc->ssh, nonblock); }
/* * remove_remote -- (internal) remove remote pool */ static int remove_remote(const char *target, const char *pool_set) { #ifdef USE_RPMEM char cask = 'y'; switch (ask_mode) { case ASK_ALWAYS: cask = '?'; break; case ASK_NEVER: case ASK_SOMETIMES: cask = 'y'; break; } if (ask_Yn(cask, "remove remote pool '%s' on '%s'?", pool_set, target) != 'y') return 0; struct rpmem_target_info *info = rpmem_target_parse(target); if (!info) goto err_parse; struct rpmem_ssh *ssh; if (force) { ssh = rpmem_ssh_exec(info, "--remove", pool_set, "--force", NULL); } else { ssh = rpmem_ssh_exec(info, "--remove", pool_set, NULL); } if (!ssh) goto err_ssh_exec; int ret = 0; if (rpmem_ssh_monitor(ssh, 0)) ret = 1; if (rpmem_ssh_close(ssh)) ret = 1; if (ret) goto err_ssh_exec; rpmem_target_free(info); outv(1, "removed '%s' on '%s'\n", pool_set, target); return ret; err_ssh_exec: rpmem_target_free(info); err_parse: if (!force) outv_err("cannot remove '%s' on '%s'", pool_set, target); return 1; #else outv_err("remote replication not supported"); return 1; #endif }