delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/04/13/13:43:47

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE
X-Spam-Check-By: sourceware.org
Message-ID: <4BC4AD2D.1040209@acm.org>
Date: Tue, 13 Apr 2010 10:43:09 -0700
From: David Rothenberger <daveroth AT acm DOT org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4
MIME-Version: 1.0
To: cygwin <cygwin AT cygwin DOT com>
Subject: configure test for accept4 hangs
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------060207020908070703050902
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

While configuring apr-1.4.2 with Cygwin 1.7.5, the test for accept4
hung. I don't know much about this API, so I've just disabled it in
libapr1 for now, but I wanted to report the hang in case it was a
Cygwin bug.

The associated conftest is attached.

-- 
David Rothenberger  ----  daveroth AT acm DOT org

QOTD:
        "I'd never marry a woman who didn't like pizza... I might play
        golf with her, but I wouldn't marry her!"

--------------060207020908070703050902
Content-Type: text/plain;
 name="accept4.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="accept4.c"

#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <signal.h>
#include <errno.h>

#define A4_SOCK "./apr_accept4_test_socket"

int main()
{
    pid_t pid;
    int fd;
    struct sockaddr_un loc, rem;
    socklen_t rem_sz;

    if ((pid = fork())) {
        int status;

        unlink(A4_SOCK);

        if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
            goto cleanup_failure2;

        loc.sun_family = AF_UNIX;
        strncpy(loc.sun_path, A4_SOCK, sizeof(loc.sun_path) - 1);

        if (bind(fd, (struct sockaddr *) &loc,
                 sizeof(struct sockaddr_un)) == -1)
            goto cleanup_failure;

        if (listen(fd, 5) == -1)
            goto cleanup_failure;

        rem_sz = sizeof(struct sockaddr_un);
        if (accept4(fd, (struct sockaddr *) &rem, &rem_sz, 0) == -1) {
            goto cleanup_failure;
        }
        else {
            close(fd);
            waitpid(pid, &status, 0);
            unlink(A4_SOCK);
            return 0;
        }

cleanup_failure:
        close(fd);
cleanup_failure2:
        kill(pid, SIGKILL);
        waitpid(pid, &status, 0);
        unlink(A4_SOCK);
        return 1;
    }
    else {
        if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
            return 1; /* this will be bad: we'll hang */

        loc.sun_family = AF_UNIX;
        strncpy(loc.sun_path, A4_SOCK, sizeof(loc.sun_path) - 1);

        while(connect(fd, (struct sockaddr *) &loc,
                      sizeof(struct sockaddr_un)) == -1 &&
              (errno==ENOENT || errno==ECONNREFUSED))
            ;

        close(fd);
        return 0;
    }
}


--------------060207020908070703050902
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--------------060207020908070703050902--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019