in reply to Passing sockets between segregated threads
... it fails in multithreaded mode during the fdopen() with a "Bad file descriptor" error.
The likely cause is that you are allowing the original file handle to go out of scope and get garbage collected (closed) before the thread to which you pass the fileno has a chance to dup it.
One way to tackle this is to save a copy of the file handle in a hash indexed by it's fileno within the accept thread and then have a separate queue that the responder threads post the filenos to when they close them. The accept thread then monitors this queue and when a fileno is posted to it, it retrieves it and uses it to delete the relevant key from the socket cache to complete the cleanup.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Passing sockets between segregated threads
by renodino (Curate) on Oct 20, 2005 at 17:11 UTC | |
by BrowserUk (Patriarch) on Oct 20, 2005 at 17:55 UTC | |
by renodino (Curate) on Oct 20, 2005 at 18:01 UTC | |
by BrowserUk (Patriarch) on Oct 20, 2005 at 18:03 UTC |