• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #882

31 Aug 2023 07:44PM UTC coverage: 41.798% (-44.7%) from 86.546%
#882

push

19442 of 46514 relevant lines covered (41.8%)

126375.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.54
/libs/core/asio/src/map_hostnames.cpp
1
//  Copyright (c) 2007-2023 Hartmut Kaiser
2
//
3
//  SPDX-License-Identifier: BSL-1.0
4
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
5
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6

7
#include <hpx/config.hpp>
8
#include <hpx/asio/asio_util.hpp>
9
#include <hpx/asio/map_hostnames.hpp>
10

11
#include <cstdint>
12
#include <iostream>
13
#include <string>
14

15
#include <asio/io_context.hpp>
16
#include <asio/ip/tcp.hpp>
17

18
namespace hpx::util {
19

20
    std::string map_hostnames::map(
128✔
21
        std::string host_name, std::uint16_t port) const
22
    {
23
        if (host_name == "localhost")
128✔
24
        {
25
            // map local host to loopback ip address (that's a quick hack that
26
            // will be removed as soon as we figure out why name resolution does
27
            // not handle this anymore)
28
            if (debug_)
×
29
            {
30
                std::cerr << "resolved: 'localhost' to: 127.0.0.1" << std::endl;
31
            }
32
            return "127.0.0.1";
×
33
        }
34

35
        if (!!transform_)
128✔
36
        {
37
            // if the transform is not empty
38
            host_name = transform_(host_name);
×
39
            if (debug_)
×
40
            {
41
                std::cerr << "host_name(transformed): " << host_name
42
                          << std::endl;
43
            }
44
        }
45

46
        // do full host name resolution
47
        ::asio::io_context io_service;
128✔
48
        ::asio::ip::tcp::endpoint const ep = util::resolve_hostname(
49
            prefix_ + host_name + suffix_, port, io_service, ipv4_);
256✔
50

51
        std::string resolved_addr(util::get_endpoint_name(ep));
128✔
52
        if (debug_)
128✔
53
        {
54
            std::cerr << "resolved: '" << prefix_ + host_name + suffix_
×
55
                      << "' to: " << resolved_addr << std::endl;
56
        }
57

58
        return resolved_addr;
128✔
59
    }
60
}    // namespace hpx::util
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc