tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: Loic Domaigne <loic@ast.dfs.de>
Subject: About netstat hangs...
Date: Wed, 05 May 2004 17:19:50 +0200	[thread overview]
Message-ID: <40990616.2040302@4dp.dfs.de> (raw)

Dear Tru64 Managers,

I have noticed that many people were faced to the "netstat hangs" 
problem. But I didn't found a clear answer regarding that issue.

I ran two weeks ago in that problem too, and here a summary of my 
investigations (on Tru64 4.0F, but this might apply to newer Tru64 as 
well, if I refer to the posts on this list).

If a process writes in a message queue in such way that it overflows the 
queue (for instance, no receiver presents), then when the maximum of 
oustanding messages is reached (40 on my system), netstat hangs. BTW, 
not only netstat, but also program like lsof. As soon as the queue is 
removed, netstat (resp. lsof) works fine again.

I believe, this is a Tru64 issue? Since, the only process that should be 
eventually "punished" is the writer (if IPC_NOWAIT isn't passed to 
msgflg, the writer should block). However, even if a message queue has 
kernel persistence, I don't believe that other processes like netstat 
should block too...

Below, you shall find overflowQ.c, a program that does nothing
but overflow a message queue, as well a description to reproduce the 
problem (steps.txt).

You might known all of this already... But I felt it would be perhaps a 
good idea to post that summary.


Cheers,
Loic.


------------------ overflowQ.c

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <errno.h>

#define MSGQ_KEY 0x1234
#define PERM     0660

struct mymsg {
  long mtype;
  char mtext[1];
};

int
main()
{
  int            msg_id;  /* message Queue id.            */
  struct mymsg   msg;     /* message to send.             */
  int            nmsg;    /* number of msg send.          */
  int            status;  /* status returned by msgsnd(). */ 

  /*
   * Create Message Queue
   */
  if ( (msg_id = msgget (MSGQ_KEY, PERM | IPC_CREAT | IPC_EXCL)) == -1 ) {
    perror ("msgget: ");
    exit (EXIT_FAILURE);
  }  
  /*
   * now write message one by one until Queue is full
   */ 
  msg.mtype    = 1;
  msg.mtext[0] = 'A';
  nmsg         = 0;
  do {
    status = msgsnd (msg_id, &msg, sizeof(msg.mtext), IPC_NOWAIT);
    nmsg++;
    printf ("Sent msg #%d\r", nmsg);
  }
  while ( status == 0 );
  
  if (errno != EAGAIN ) { /* eh? we didn't overflow? */
    perror ("msgsnd: ");
    exit (EXIT_FAILURE);
  }
  
  printf ("Queue full, sent %d messages\n", nmsg-1);
  exit (EXIT_SUCCESS);
}


------------------ steps.txt

===============================
Steps to reproduce the problem:
===============================

bash$ netstat 
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp        0      0  vdphr1.sshd            wks4.33524             ESTABLISHED
tcp        0      0  localhost.3922         localhost.2301         TIME_WAIT
tcp        0      0  localhost.3923         localhost.2301         TIME_WAIT
...

bash$ overflowQ
Queue full, sent 40 messages

bash$ netstat [ hangs... ]

bash$ ipcs -qa 
T      ID        KEY    MODE         OWNER    GROUP  CREATOR   CGROUP CBYTES  QNUM QBYTES LSPID LRPID  STIME    RTIME    CTIME
q       0 0x41003ec7 --rw-------      root   system     root   system      0     0  16384     3 13647 14:24:29 14:24:29  8:37:07
q     130     0x1234 --rw-rw----      loic      vdp     loic      vdp     40    40  16384 13662     0 14:25:06 no-entry 14:25:06

removing the queue solve the problem: 

bash$ ipcrm -q 130 
bash$ netstat 
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp        0      0  vdphr1.sshd            wks4.33524             ESTABLISHED
tcp        0      0  localhost.3939         localhost.2301         TIME_WAIT
tcp        0      0  localhost.3940         localhost.2301         TIME_WAIT
...

Note: there is no need to restart kloadsrv.




             reply	other threads:[~2004-05-05 15:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-05 15:19 Loic Domaigne [this message]
     [not found] ` <"from loic"@ast.dfs.de>
2004-05-05 22:09   ` Command execution in a V5 Cluster vs Non-Cluster environment Narendra Raavi
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox