lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CABa6K_Evv5+rXFvAOa0RGZ7Mbi11idS=0Xmyq=AURCcV7r6NJw@mail.gmail.com>
Date:	Mon, 30 Mar 2015 21:51:56 +0800
From:	Changli Gao <xiaosuo@...il.com>
To:	Linux Netdev List <netdev@...r.kernel.org>
Subject: The errno when failing to connect to a unix stream socket due to timeout

Dear all,

When working with the unix stream socket, I find that when failing to
connect to a unix stream socket due to timeout, the errno is EAGAIN
instead of ETIMEDOUT. IMHO, EAGAIN should be for non blocking IO only,
but if we change the errno, there maybe a risk: breaking some
applications. So, I want to know your ideas. Correct me if I made any
mistake.

Here is the code snippet:

#include <unistd.h>

#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/un.h>

int main()
{
        int serv = socket(PF_UNIX, SOCK_STREAM, 0);
        struct sockaddr_un addr;

        remove("/tmp/test.unix");
        memset(&addr, 0, sizeof(addr));
        addr.sun_family = AF_UNIX;
        strcpy(addr.sun_path, "/tmp/test.unix");
        bind(serv, (struct sockaddr *)&addr, sizeof(addr));
        listen(serv, 1);

        int i;
        for (i = 0; i < 3; ++i) {
                int clnt = socket(PF_UNIX, SOCK_STREAM, 0);
                struct timeval tv;
                tv.tv_sec = 3;
                tv.tv_usec = 0;
                setsockopt(clnt, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
                if (connect(clnt, (struct sockaddr *)&addr, sizeof(addr)))
                        perror("connect");
        }

        return 0;
}

-- 
Regards,
Changli Gao(xiaosuo@...il.com)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ