Bug 12991

Summary: system queue is cleared when a port or pipe is rebinded to another user processor.
Product: Base System Reporter: xshen <xshen>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.1-RELEASE   
Hardware: Any   
OS: Any   

Description xshen 1999-08-05 23:10:00 UTC
* run a small server-client program based on UNIX Domain Socket on FreeBSD;
* server close the listen socket after the completion of one connection;
* client forks several children to connect to the server concurrently;
* Not all the clients' connections will be handled by the server because the closing listening socket causes kernel clear the system queue and all other requests in it.
* run the same program on Linux and Solaris the contents of the system queue can be preserved for a while, and the system queue has nothing to do with close() by user processes.
* If I want to keep the contents of the queue on FreeBSD, what should I do?

Fix: 

Not available yet.
How-To-Repeat: Server:
char LINK_FILE[]="foo";
int listen_socket, conn_socket, clilen;
fd_set rset;
sockaddr_un addr1, addr2;
for(;;){
   unlink(LINK_FILE);
   listen_socket = socket(AF_UNIX, SOCK_STREAM, 0);
   bzero(&addr1, sizeof(addr1));
   addr1.sun_family = AF_UNIX;
   strncpy(addr1.sun_path, LINK_FILE, sizeof(addr1.sun_path)-1);
   bind(listen_socket, (struct sockaddr *)&addr1, SUN_LEN(&addr1));
   FD_ZERO(&rset);
   listen(listen_socket, 5);
   FD_SET(listen_socket, &rset);
   if((nready=select(listen_socket+1,&rset,NULL,NULL,NULL))>0){ 
      if(FD_ISSET(listen_socket, &rset)){
         clilen = sizeof(addr2);
         conn_socket=accept(listen_socket,(struct sockaddr *)&addr2,&clilen);
         read(conn_socket, pin, 1024); 
         write(conn_socket, pout, 1024); 
         close(conn_socket);
         close(listen_socket);
      }
   }
}

client:
int total, child, sock;
for(total=0; total<child; total++){
   if(!fork()){
      sock = open_socket(total);
      write(sock, pout, 1024);
      read(sock, pin, 1024);
      close(sock);
   } 
}
do{
   wait(&status);
   k++;
}while(k<child);
Comment 1 hoek freebsd_committer freebsd_triage 1999-08-22 21:45:05 UTC
Responsible Changed
From-To: gnats-admin->freebsd-bugs

Misfiled PR 
Comment 2 Mike Barcroft freebsd_committer freebsd_triage 2001-07-21 01:06:14 UTC
State Changed
From-To: open->closed


This is a question, not a problem report.