Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Martin M. Hunt" <hunt@redhat.com>
To: Andrew Cagney <ac131313@cygnus.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] new tcp_open
Date: Mon, 03 Dec 2001 13:26:00 -0000	[thread overview]
Message-ID: <200112032126.NAA04413@cygnus.com> (raw)
In-Reply-To: <3C0BDA64.7080902@cygnus.com>

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.


  reply	other threads:[~2001-12-03 21:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-03 11:18 Martin M. Hunt
2001-12-03 12:02 ` Andrew Cagney
2001-12-03 13:26   ` Martin M. Hunt [this message]
2001-12-03 13:36     ` Andrew Cagney
2001-12-03 22:13       ` Martin M. Hunt
2001-12-18  2:41 ` Orjan Friberg
2001-12-18  2:57   ` Martin M. Hunt
2001-12-18  3:22     ` Andrew Cagney
2001-12-18 12:29       ` Martin M. Hunt
2001-12-19 15:32         ` Elena Zannoni
2001-12-20  3:39           ` Martin M. Hunt
2001-12-20  3:04             ` Andrew Cagney
2001-12-18  3:40     ` Orjan Friberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200112032126.NAA04413@cygnus.com \
    --to=hunt@redhat.com \
    --cc=ac131313@cygnus.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox