LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-26-2009, 04:05 AM   #1
cvamshi
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 0
BSD Select() call hangs


Hi all,

We are developing a network application which was hanging after it ran for a few days. We couldnt find the exact reason for its hang. But when we tried to run it under the dbx we saw one of the threads hung in the select call.

Here is the stack trace...

#0 0xffffe410 in __kernel_vsyscall ()
#1 0x00690a41 in ___newselect_nocancel () from /lib/tls/libc.so.6
#2 0xf7c8927f in MySocket::checkSocketRead () from /opt/SharedComponents/lib/libmysocket.so

And the code corresponding to this call is

const int timeout = 1000;
m_sock->checkSocketRead( timeout );

And in CheckSocketRead call…

tm.tv_sec = timeout / 1000;
tm.tv_usec = (timeout % 1000) * 1000;
tptr = &tm;

// Directly call the BSD socket select
int ret = call_select((int)m_socket + 1, &read_set, NULL, &except_set, tptr);

We are here putting a timeout of 1 second. But still the select call seems to hang.

I ran the thread under the strace and saw that
//Select call takes almost 1 second as expected
select(27, [26], NULL, [26], {412316860416000, 67108864}) = 0 (Timeout) <0.096305>
//Some Timer function
time(NULL) = 1250833595 <0.000007>
//Now some read function is called… we don't call this… So it should be internal to the select command… Why are we checking this?
read(26, 0xf53688ad, 1117) = -1 EAGAIN (Resource temporarily unavailable) <0.000007>


Can some one explain what is happening here? Why is the select hanging even after we set the timeout as 1 second?

Thanks,
Vamshi
 
Old 08-27-2009, 04:24 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
This doesn't look good:
select(27, [26], NULL, [26], {412316860416000, 67108864}) = 0 (Timeout) <0.096305>

Your timeout isn't 1 second, it's 412316860416000 seconds (some more, in fact). There is probably something wrong with the timeout variable.
 
Old 08-28-2009, 06:37 AM   #3
cvamshi
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks Mara for the reply...

But when i see at it again the value seems to be 1. Do you suggest there was some kind of corruption in the timeout value?

select(27, [26], NULL, [26], {1, 67108864}) = 0 (Timeout) <0.999924>
time(NULL) = 1250833596 <0.000006>
read(26, 0xf53688ad, 1117) = -1 EAGAIN (Resource temporarily unavailable) <0.000017>
select(27, [26], NULL, [26], {1, 67108864}) = 0 (Timeout) <0.999241>
time(NULL) = 1250833597 <0.000006>
read(26, 0xf53688ad, 1117) = -1 EAGAIN (Resource temporarily unavailable) <0.000005>
select(27, [26], NULL, [26], {1, 67108864}) = 0 (Timeout) <0.999949>


Thanks in advance

Vamshi
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on using select() function call with FIFO Sathya Programming 12 05-30-2008 09:33 AM
nohup + java > select: interrupted system call mivz Linux - Software 2 02-03-2006 02:28 AM
question about select sys call xatzipol Programming 1 10-30-2005 09:22 AM
C sockets Select call when to use? cranium2004 Programming 1 03-14-2005 05:56 AM
IPC in socket using select system call Gomathy Linux - Networking 0 01-28-2005 06:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration