Commit d8f93a46 authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

Merge branch 'margo_fix_handle_cache' into 'master'

Margo fix handle cache

Closes #85

See merge request zdvresearch_bsc/adafs!116
parents d2cfbefc 31e78184
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -289,6 +289,8 @@ echo "############################################################ Installing:
CURR=${SOURCE}/margo
prepare_build_dir ${CURR}
cd ${CURR}
echo "########## Applying margo handle cache fix"
git apply ${PATCH_DIR}/handle_cache.patch
./prepare.sh
cd ${CURR}/build
../configure --prefix=${INSTALL} PKG_CONFIG_PATH=${INSTALL}/lib/pkgconfig CFLAGS="-Wall -O3"
+37 −0
Original line number Diff line number Diff line
diff --git a/include/margo.h b/include/margo.h
index 56aa9dd..9dd49a8 100644
--- a/include/margo.h
+++ b/include/margo.h
@@ -435,6 +435,12 @@ hg_return_t margo_create(
     hg_id_t id,
     hg_handle_t *handle);
 
+hg_return_t margo_create_cache(
+    margo_instance_id mid,
+    hg_addr_t addr,
+    hg_id_t id,
+    hg_handle_t *handle);
+
 /**
  * Destroy Mercury handle.
  *
diff --git a/src/margo.c b/src/margo.c
index df035c1..87c2524 100644
--- a/src/margo.c
+++ b/src/margo.c
@@ -716,6 +716,15 @@ hg_return_t margo_create(margo_instance_id mid, hg_addr_t addr,
     hg_id_t id, hg_handle_t *handle)
 {
     hg_return_t hret = HG_OTHER_ERROR;
+    hret = HG_Create(mid->hg_context, addr, id, handle);
+
+    return hret;
+}
+
+hg_return_t margo_create_cache(margo_instance_id mid, hg_addr_t addr,
+    hg_id_t id, hg_handle_t *handle)
+{
+    hg_return_t hret = HG_OTHER_ERROR;
 
     /* look for a handle to reuse */
     hret = margo_handle_cache_get(mid, addr, id, handle);
+13 −7
Original line number Diff line number Diff line
#include <preload/preload_util.hpp>
#include <global/rpc/rpc_utils.hpp>
#include <global/rpc/distributor.hpp>
#include <global/global_func.hpp>

#include <fstream>
#include <iterator>
#include <memory>
#include <unordered_map>
#include <sstream>
#include <csignal>
#include <random>
@@ -210,8 +206,14 @@ bool lookup_all_hosts() {
    ::shuffle(hosts.begin(), hosts.end(), g); // Shuffle hosts vector
    // lookup addresses and put abstract server addresses into rpc_addresses
    for (auto& host : hosts) {
        string uri{};
        // If local use address provided by daemon in order to use automatic shared memory routing
        if (host == CTX->fs_conf()->host_id) {
            uri = CTX->daemon_addr_str();
        } else {
            auto hostname = CTX->fs_conf()->hosts.at(host);
        auto uri = get_uri_from_hostname(hostname);
            uri = get_uri_from_hostname(hostname);
        }
        auto remote_addr = margo_addr_lookup_retry(uri);
        if (remote_addr == HG_ADDR_NULL) {
            CTX->log()->error("{}() Failed to lookup address {}", __func__, uri);
@@ -263,7 +265,11 @@ margo_create_wrap_helper(const hg_id_t rpc_id, uint64_t recipient, hg_handle_t&
        CTX->log()->error("{}() server address not resolvable for host id {}", __func__, recipient);
        return HG_OTHER_ERROR;
    }
    // TODO The following is a work around until https://xgitlab.cels.anl.gov/sds/margo/issues/47 is fixed
    if (recipient == CTX->fs_conf()->host_id)
        ret = margo_create(ld_margo_rpc_id, svr_addr, rpc_id, &handle);
    else
        ret = margo_create_cache(ld_margo_rpc_id, svr_addr, rpc_id, &handle);
    if (ret != HG_SUCCESS) {
        CTX->log()->error("{}() creating handle FAILED", __func__);
        return HG_OTHER_ERROR;