From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21833 invoked by alias); 3 Dec 2001 21:26:53 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 21754 invoked from network); 3 Dec 2001 21:26:51 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 3 Dec 2001 21:26:51 -0000 Received: from there (cse.cygnus.com [205.180.230.236]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with SMTP id NAA04413; Mon, 3 Dec 2001 13:26:49 -0800 (PST) Message-Id: <200112032126.NAA04413@cygnus.com> Content-Type: text/plain; charset="iso-8859-1" From: "Martin M. Hunt" Organization: Red Hat Inc To: Andrew Cagney Subject: Re: [RFA] new tcp_open Date: Mon, 03 Dec 2001 13:26:00 -0000 X-Mailer: KMail [version 1.3.2] Cc: gdb-patches@sources.redhat.com References: <200112031918.LAA18199@cygnus.com> <3C0BDA64.7080902@cygnus.com> In-Reply-To: <3C0BDA64.7080902@cygnus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SW-Source: 2001-12/txt/msg00063.txt.bz2 On Monday 03 December 2001 12:02 pm, Andrew Cagney wrote: > Outch! > > > /* Use Non-blocking connect. connect() will return 0 if connected > > already. */ n = connect (scb->fd, (struct sockaddr *) &sockaddr, sizeof > > (sockaddr)); if (n) > > { > > Should this also be checking errno to confirm that it was EINPROGRESS? > Little point in trying to connect to a socket that isn't valid. The select handles it, but that isn't obvious. I'll insert the standard error check after the connect. > > t.tv_usec = 500000; /* 0.5 seconds */ > > > > n = select (scb->fd + 1, &rset, &wset, NULL, &t); > > secs++; > > } > > while (n == 0 && secs <= TIMEOUT); > > Can I just suggest tinkering with this so that the 15 seconds is clearer > - at present it happens cos 0.5 * 30 = 15. Yeah, it did make more sense when the select was timing out at 1 second intervals, but I decided to lower it to make the GUI more responsive. How about this? /* seconds to wait for connect */ #define TIMEOUT 15 /* how many times per second to poll ui_loop_hook */ #define POLL_INTERVAL 2 [...] t.tv_sec = 0; t.tv_usec = 1000000 / POLL_INTERVAL; n = select (scb->fd + 1, &rset, &wset, NULL, &t); polls++; } while (n == 0 && polls <= TIMEOUT * POLL_INTERVAL); if (n < 0 || polls > TIMEOUT * POLL_INTERVAL) { if (polls > TIMEOUT * POLL_INTERVAL) errno = ETIMEDOUT; tcp_close (scb); return -1; } > The only other potential problem I can see is with FIONBIO. Hopefully > that is fairly common and where it turns out to not be available > something can be worked out. It really should be available everywhere. This is standard socket stuff. If for some reason the socket does not get set to non-blocking, it will block, but still connect. > Tried it on cygwin? Yes. It works. -- Martin Hunt GDB Engineer Red Hat, Inc.