Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 17th, 2012  |  syntax: None  |  size: 1.79 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Possible causes of a deadlock in socket select
  2. bool ConnectionTCPBase::dataAvailable( int timeout )
  3.   {
  4.     if( m_socket < 0 )
  5.       return true; // let recv() catch the closed fd
  6.  
  7.     fd_set fds;
  8.     struct timeval tv;
  9.  
  10.     FD_ZERO( &fds );
  11.     // the following causes a C4127 warning in VC++ Express 2008 and possibly other versions.
  12.     // however, the reason for the warning can't be fixed in gloox.
  13.     FD_SET( m_socket, &fds );
  14.  
  15.     tv.tv_sec = timeout / 1000000;
  16.     tv.tv_usec = timeout % 1000000;
  17.  
  18.     return ( ( select( m_socket + 1, &fds, 0, 0, timeout == -1 ? 0 : &tv ) > 0 )
  19.              && FD_ISSET( m_socket, &fds ) != 0 );
  20.   }
  21.        
  22. Thread 2 (Thread 0x7fe226ac2700 (LWP 10774)):
  23. #0  0x00007fe224711ff3 in select () at ../sysdeps/unix/syscall-template.S:82
  24. #1  0x00000000004706a9 in gloox::ConnectionTCPBase::dataAvailable (this=0xcaeb60, timeout=<value optimized out>) at connectiontcpbase.cpp:103
  25. #2  0x000000000046c4cb in gloox::ConnectionTCPClient::recv (this=0xcaeb60, timeout=10) at connectiontcpclient.cpp:131
  26. #3  0x0000000000471476 in gloox::ConnectionTLS::recv (this=0xd1a950, timeout=648813712) at connectiontls.cpp:89
  27. #4  0x00000000004324cc in glooxd::C2S::recv (this=0xc5d120, timeout=10) at c2s.cpp:124
  28. #5  0x0000000000435ced in glooxd::C2S::run (this=0xc5d120) at c2s.cpp:75
  29. #6  0x000000000042d789 in CNetwork::run (this=0xc56df0) at src/Network.cpp:343
  30. #7  0x000000000043115f in threading::ThreadManager::threadWorker (data=0xc56e10) at src/ThreadManager.cpp:15
  31. #8  0x00007fe2249bc9ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
  32. #9  0x00007fe22471970d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
  33. #10 0x0000000000000000 in ?? ()
  34.        
  35. // let recv() catch the closed fd
  36.        
  37. fd_set fds_copy = fds;
  38. select( m_socket + 1, &fds, 0, &fds_copy, timeout == -1 ? 0 : &tv )