LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 03-17-2005, 07:55 PM   #1
jwstric2
Member
 
Registered: Jan 2004
Posts: 105

Rep: Reputation: 15
race condition in close socket??


Here's my problem.. Seems to only occur on localhost connections because they happen so fast.

(These are nonblocking sockets by the way)

1. I close a socket after its data transfer
2. Accept another incoming conneciton, it seems to get the same fd as the last socket closed.
3. Set the fd_set
4. Enter select loop which falls through
5. Sometimes though after trying to read or write to this new socket I get a Resouce Not Available.

I took out step 1 and everything seems to work fine.

Any possible idea of whats going on? I have an idea that file descriptor information is not immediately cleaned up. If so how can I prevent this?
 
Old 03-17-2005, 08:25 PM   #2
AltF4
Member
 
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532

Rep: Reputation: 31
did you do a "shutdown()" on the socket before closing it ?
 
Old 03-17-2005, 08:43 PM   #3
jwstric2
Member
 
Registered: Jan 2004
Posts: 105

Original Poster
Rep: Reputation: 15
yes I do actually. as I stated I believe it to be some sort of race condition because remote connections never produce the race condition it seems. I can also put in a small sleep after the close and everything seems to work. This shouldn't happen though I think.
 
Old 03-18-2005, 06:01 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
So you use close(), shutdown() (which direction?) or both?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Kernel race condition exploit solution jlangelier Slackware 12 01-14-2005 11:15 AM
Close socket/port THETEZ Linux - General 4 03-28-2004 09:05 PM
P-thread+race condition+mutex+Peterson's algorithm bangla_linux Programming 3 10-29-2003 04:01 AM
Linus Torvalds enters race for California Governor bosewicht Linux - General 2 09-02-2003 01:13 PM
Linus Torvalds enters race for California Governor fancypiper General 10 09-02-2003 01:11 PM


All times are GMT -5. The time now is 10:19 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration