home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.protocols.tcp-ip      TCP and IP network protocols.      14,669 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 13,834 of 14,669   
   Barry Margolin to Jorgen Grahn   
   Re: thread blocked while deleting a sock   
   27 Feb 12 21:55:26   
   
   From: barmar@alum.mit.edu   
      
   In article ,   
    Jorgen Grahn  wrote:   
      
   > On Mon, 2012-02-27, Marco Peng wrote:   
   > > Hello to all,   
   > >   
   > > I have below function, but the thread will be bloked at the line   
   > >     delete pListenSocket; // Close and delete   
   > >   
   > > If I put some cpu timing switching function prior to it, then no   
   > > blocking pop up.   
   > >     printf("xyz\n");  // or sleep(100);   
   > >     delete pListenSocket; // Close and delete   
   > >   
   > > Can I get some help from any one? Thanks a lot!   
   > >   
   > > the function   
   > > int Socketpair (int domain, int type, int protocol, Socket **   
   > > ppReadSocket, Socket ** ppWriteSocket)   
   > > {   
   > > 	Socket * pListenSocket = NULL;   
   > > 	Socket * pConnectSocket = NULL;   
   > > 	Socket * pAcceptSocket = NULL;   
   > ...   
   >   
   > Noone can help you without somehow knowing what a Socket is. You   
   > appear to use some C++ library which wraps your file descriptors and   
   > possibly other things as C++ objects.   
   >   
   > (And the library doesn't seem very good. I'm a C++ guy myself, but I   
   > believe wrapping sockets in objects, virtual inheritance, factories   
   > and pointers looks attractive at first, but eventually it's a bad   
   > idea.)   
   >   
   > Try running strace or whatever your OS supplies, and see what your   
   > program really is doing when it gets stuck.   
      
   It probably has something to do with the Socket's destructor method,   
   performing some action that blocks.  Although this is a listening   
   socket, and I'm not sure what you might do in a destructor that would   
   block on this type.  On a connected socket it might be waiting for the   
   other end to close, or for buffers to be flushed, etc.   
      
   I agree with the strace suggestion -- find out precisely what system   
   call it's blocked in, and that should help.   
      
   --   
   Barry Margolin   
   Arlington, MA   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca