[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Busyloop in port forwarding after closed channel


Hello all,here is what I'm trying to do:
My environment is Linux.

I need to tunnel XML-RPC requests through a SSH tunnel to a remote machine. This is all written in C with an XMLRPC client written on top of XMLRPC-C.
I'm opening a session to the remote host and a local server socket for incoming http requests.
Then I'm starting a new thread to handle the incoming http requests. The thread uses ssh_select to poll the socket from the SSH session, the local server socket and a command pipe to control the thread.
If a client connects to the local socket, ssh_select returns, I'm accep(2)ing the new local connection and create and connect a new channel from the session to the ssh server. The new local session and the new channel are added to ssh_select and I'm back waiting for something to happen.
When the client sends its HTTP request through the newly accepted socket, ssh_select returns, I'm reading the request and stuff it into the channel to the remote host. Then I'm waiting for the response from the remote server. ssh_select indicates that something is available from the channel, I'm reading the response and send it on through the local socket to the http client. When channel_read returns 0 (e.g. the channel is closed) I'm freeing the channel and closing the client socket.
Now comes the problem: Despite the fact that there is no active channel, ssh_select indicates that the socket from the session is ready to be read. What do I do now? There seems to be no function to handle a readable session socket without an open channel.
Thanks in advance and kind regards  Joerg

Archive administrator: postmaster@lists.cynapses.org