Overview
Features
Download
Documentation
Community
Add-Ons & Services

missing Marco condition, cause a wrong execption type

Please post support and help requests here.

missing Marco condition, cause a wrong execption type

Postby al0n9 » 01 Apr 2013, 17:21

Firstly, sorry for my bad Englisth.....:) Language is nation wide, but Code is world wide.
In DNS.cpp,
Code: Select all
HostEntry DNS::hostByName(const std::string& hostname)
{
 ......
#if defined(POCO_HAVE_IPv6) || defined(POCO_HAVE_ADDRINFO)
 ......
        int rc = getaddrinfo(hostname.c_str(), NULL, &hints, &pAI);
        if (rc == 0)
        {
                HostEntry result(pAI);
                freeaddrinfo(pAI);
                return result;
        }
        else
        {
                aierror(rc, hostname);
        }
#elif defined(POCO_VXWORKS)
......
#else
......
#endif
        error(lastError(), hostname);      // will throw an appropriate exception
        throw NetException(); // to silence compiler
}
......
void DNS::error(int code, const std::string& arg)
{
        switch (code)
        {
        case POCO_ESYSNOTREADY:
                throw NetException("Net subsystem not ready");
        case POCO_ENOTINIT:
                throw NetException("Net subsystem not initialized");
        case POCO_HOST_NOT_FOUND:
                throw HostNotFoundException(arg);
        case POCO_TRY_AGAIN:
                throw DNSException("Temporary DNS error while resolving", arg);
        case POCO_NO_RECOVERY:
                throw DNSException("Non recoverable DNS error while resolving", arg);
        case POCO_NO_DATA:
                throw NoAddressFoundException(arg);
        default:
                throw IOException(NumberFormatter::format(code));
        }
}
void DNS::aierror(int code, const std::string& arg)
{
#if defined(POCO_HAVE_IPv6)
......
#endif // POCO_HAVE_IPv6
}

In some host, that has POCO_HAVE_ADDRINFO defined, but not POCO_HAVE_IPv6, such Solaris 10, when I specify a unknow host, getaddrinfo return 8, which defined in netdb.h:
Code: Select all
#define EAI_NONAME      8       /* host/servname not known */

Finally, the program run into DNS::error, and throw IOException. It is inaccurate. So, I modify DNS:aierror
Code: Select all
void DNS::aierror(int code, const std::string& arg)
{
#if defined(POCO_HAVE_IPv6) || defined(POCO_HAVE_ADDRINFO)
        switch (code)
        {
        case EAI_AGAIN:
                throw DNSException("Temporary DNS error while resolving", arg);
        case EAI_FAIL:
                throw DNSException("Non recoverable DNS error while resolving", arg);
#if !defined(_WIN32) // EAI_NODATA and EAI_NONAME have the same value
        case EAI_NODATA:
                throw NoAddressFoundException(arg);
#endif
        case EAI_NONAME:
                throw HostNotFoundException(arg);
#if defined(EAI_SYSTEM)
        case EAI_SYSTEM:
                error(lastError(), arg);
                break;
#endif
#if defined(_WIN32)
        case WSANO_DATA: // may happen on XP
                throw HostNotFoundException(arg);
#endif
        default:
                throw DNSException("EAI", NumberFormatter::format(code));
        }
#endif // POCO_HAVE_IPv6||POCO_HAVE_ADDRINFO
}

Now, It's work fine.;)
al0n9
 
Posts: 4
Joined: 29 Mar 2013, 06:37

Re: missing Marco condition, cause a wrong execption type

Postby alex » 01 Apr 2013, 22:56

What version are you using? That's been fixed.
alex
 
Posts: 1105
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: missing Marco condition, cause a wrong execption type

Postby al0n9 » 02 Apr 2013, 07:34

alex wrote:What version are you using? That's been fixed.

Hi alex, thanks for your reply. I am using 1.4.6.
al0n9
 
Posts: 4
Joined: 29 Mar 2013, 06:37

Re: missing Marco condition, cause a wrong execption type

Postby al0n9 » 02 Apr 2013, 08:31

alex wrote:What version are you using? That's been fixed.

Hi alex.
I downloaded 1.4.6p1 and 1.5.1.
I find that this issure has been fixed in 1.4.6p1, but still exist in 1.5.1.
In change log of 1.4.6p1, there is no description for this fixed.
al0n9
 
Posts: 4
Joined: 29 Mar 2013, 06:37

Re: missing Marco condition, cause a wrong execption type

Postby alex » 03 Apr 2013, 02:06

Not sure what you downloaded, but that has been fixed in 1.5.1 release. Maybe you are referring to something that I am not interpreting correctly. It is best to send a github pull request with your change if you don't see the change you wish in the develop branch.
alex
 
Posts: 1105
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: missing Marco condition, cause a wrong execption type

Postby al0n9 » 08 Apr 2013, 04:01

alex wrote:Not sure what you downloaded, but that has been fixed in 1.5.1 release. Maybe you are referring to something that I am not interpreting correctly. It is best to send a github pull request with your change if you don't see the change you wish in the develop branch.

Hi, alex.
I downloaded poco from mainpage link: http://pocoproject.org/releases/poco-1. ... .1.tar.bz2 .
The change doesn't in this packege, but it's already in the develop branch.
al0n9
 
Posts: 4
Joined: 29 Mar 2013, 06:37


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests