mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matti Aarnio <matti.aarnio@zmailer.org>
To: "Sparks, Jamie" <JAMIE.SPARKS@cubic.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: select() stress
Date: Mon, 17 Mar 2003 17:43:44 +0200	[thread overview]
Message-ID: <20030317154344.GG29167@mea-ext.zmailer.org> (raw)
In-Reply-To: <Pine.WNT.4.44.0303171010580.1544-100000@GOLDENEAGLE.gameday2000>

On Mon, Mar 17, 2003 at 10:28:59AM -0500, Sparks, Jamie wrote:
> Hello,
> 
>   I'm running some code ported from an sgi running Irix 6.5 on a
>   redhat 7.1 box: 2.4.7-10, i686.  Control hangs on a select()
>   statement forever.  The select is never completed, so I can't
>   check errno.

  You do set two socket fds for read monitoring, no write-sockets,
  nor exceptions, and most definitely, no timeouts.

  If, for some reason, whoever is supposed to send something to
  those sockets does not do it, e.g. due to some odd buffering
  somewhere, you are effectively stuck.


>   Please reply to me personally as I'm not currently subscribed:
>   jamie.sparks@cubic.com
> 
>   on sgi, the call is:
> 
>   select(getdtablehi(), &socklist, NULL, NULL, NULL);
> 
>   where socklist is declared as:  FD_SET socklist;
> 
>   on linux, there is no getdtablehi() equivalent, so I use
>   getdtablesize() in its place.  getdtablehi() returns the
>   number of fd's currently open and getdtablesize() returns
>   the number of fd's that *can* be open.

  I would be carefull with that, and explicitely code
  additional things to find out current highest fd in
  the interest set:

>   here's the code:
> 
>   for (;;)
>   {
	int highfd;

>     printf("CLEARING sockets\n");
>     FD_ZERO(&socklist); /* Always clear the structure first. */
>     FD_SET(Sockfd[0], &socklist);
	highfd = Sockfd[0];
>     FD_SET(Sockfd[1], &socklist);
	if (Sockfd[1] > highfd) highfd = Sockfd[1];
>
>     int len = -1;
>     bool wasDequeued =false;
>     if (!StateManager::getSaveInProgress()&& StateManager::hasQueuedPdus())
>     {
>       FD_ZERO(&socklist); /* Always clear the structure first. */
>       pdu = StateManager::dequeuePostPduProcess();
>       len = sizeof(pdu);
>       wasDequeued = true;
>       printf("PDU DEqueued from StateManager since Save has completed\n");
>     }
>     else
>     {
>       printf("prior to select\n");
>       // orig sgi if (select(getdtablehi(), &socklist, NULL, NULL, NULL) < 0)

	int rc = select(highfd + 1, &socklist, NULL, NULL, NULL);
	if (rc < 0) ...

>       /*  ****************************** */
>       /*  THIS select() STATEMENT NEVER COMPLETES */
>       /*  ****************************** */
>       if (select(getdtablesize(), &socklist, NULL, NULL, NULL) < 0)
>       {
>         if (errno != EINTR) perror("WeapTerrain");
> 	continue;
>       }
> 
>       printf("after select\n");
> 			}
>       printf("Prior to finding which socket\n");
> 
>       for (ii=0;ii<2;ii++)
>       {
>         len = -1;
>         if (FD_ISSET(Sockfd[ii],&socklist))
> 	{
>           if (!ii)
> 	  {
>             len = waitForSocketMessage(Sockfd[ii],&pdu,
> 	    sizeof(pdu));
> 	  } else if (ii)
> 	  {
> 	    len = 0;
> 	  }
> 	}
> 
> 	if (wasDequeued){len = sizeof(pdu);wasDequeued=false;}
> 
>         if (len == sizeof(pdu) && StateManager::getSaveInProgress())
> 	{
>           StateManager::queuePostPduProcess(pdu);
>           printf("incoming PDU queued in StateManager since SaveInProgress\n");
> 	  continue;
>         }
> 
>         if (len >= 0)
> 	{
> 	  printf("LEN?TYPE = %d %d\n",len, pdu.dpdu.detonation_header.type);
>         }
> 
> 
>   Please reply to me personally as I'm not currently subscribed:
>   jamie.sparks@cubic.com
> 
>   thanks,
> 
>   Jamie

  reply	other threads:[~2003-03-17 15:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-17 15:28 Sparks, Jamie
2003-03-17 15:43 ` Matti Aarnio [this message]
2003-03-17 16:15 ` Richard B. Johnson
2003-03-17 18:00   ` Miquel van Smoorenburg
2003-03-17 18:24   ` Olaf Titz
2003-03-18 10:28   ` DervishD
2003-03-18 13:06     ` Richard B. Johnson
2003-03-18 14:42       ` DervishD
2003-03-18 14:46       ` DervishD
2003-03-18 14:49 Sparks, Jamie
2003-03-18 15:05 ` Richard B. Johnson
2003-03-18 15:05   ` Sparks, Jamie
2003-03-19  4:18     ` Chris Friesen

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=20030317154344.GG29167@mea-ext.zmailer.org \
    --to=matti.aarnio@zmailer.org \
    --cc=JAMIE.SPARKS@cubic.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®