Thanks to visit codestin.com
Credit goes to github.com

Skip to content

windows connection database crash #195

@romanholidaypancakes

Description

@romanholidaypancakes

I bet no one in the real world has used clickhouse-cpp on windows, not even for testing.

Using the following code on windows results in an error code: WSAHOST_NOT_FOUND

hints.ai_flags |= AI_ADDRCONFIG;

So it will crash here

throw std::system_error(getSocketErrorCode(), getErrorCategory());

we need

#if defined(_unix_)
    if (!Singleton<LocalNames>()->IsLocalName(host)) {
        // https://linux.die.net/man/3/getaddrinfo
        // If hints.ai_flags includes the AI_ADDRCONFIG flag,
        // then IPv4 addresses are returned in the list pointed to by res only
        // if the local system has at least one IPv4 address configured,
        // and IPv6 addresses are only returned if the local system
        // has at least one IPv6 address configured.
        // The loopback address is not considered for this case
        // as valid as a configured address.
        hints.ai_flags |= AI_ADDRCONFIG;
    }
#endif

At the same time, I don't know why windows can never receive database messages here,

const ssize_t ret = ::recv(s_, (char*)buf, (int)len, 0);

so inevitably it crashes in the code behind

throw std::system_error(getSocketErrorCode(), getErrorCategory(), "closed");

By the way I am connecting to the remote ip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions