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

Issues with Connector on net sockets


Hi there

I rewrote my socket forward client code so it uses the "new" connector
API now. But sadly there are a few issues.

First of all: Is this supposed to work with more than one channel in a
single event loop?

Here some pseudo code to understand what I'm doing:

id =0; ope_cnt=0;
do {
	/* ADD Tunnel */
	if (getNewConnectionRequest(&fw_data)) {
		chann[id] = ssh_open_chan(session, fw_data->dest);

		/* local -> remote */
		connector_in[id]  = ssh_connector_new(session);
		ssh_connector_set_out_channel(connector_in[id], chann[id], SSH_CONNECTOR_STDOUT);
		ssh_connector_set_in_fd(connector_in[id], fw_data->forwardsock);
		ssh_event_add_connector(event, connector_in[id]);

		/* remote -> local */
		connector_out[id] = ssh_connector_new(session);
		ssh_connector_set_out_fd(connector_out[id], fw_data->forwardsock);
		ssh_connector_set_in_channel(connector_out[id], chann[id], SSH_CONNECTOR_STDOUT);
		ssh_event_add_connector(event, connector_out[id]);

		/* stderr */
		connector_err[id] = ssh_connector_new(session);
		ssh_connector_set_out_fd(connector_err[id], 2));
		ssh_connector_set_in_channel(connector_err[id], config[channel_currid].channel, SSH_CONNECTOR_STDERR);
		ssh_event_add_connector(event, connector_err[id]);

		id++;
		open_cnt++;
	}

	ssh_event_dopoll(event, 50);

	/* REMOVE Closed Tunnels */
	for (i=0; i < id; i++) {
		if(chann[i] && ssh_channel_is_closed(chann[i])) { 

		ssh_event_remove_connector(event, connector_in[i]);
		 ....

		ssh_connector_free(connector_in[i]);
		 ....

		ssh_channel_free(chann[i]);
		chann[i] = NULL;
		open_cnt--;
	}

} while (open_cnt > 0);
/* END */

When there is only one channel, things work like expected (with one
exception - see other issue below).

When there are two or more channels and one gets closed, all the other
get blocked in some way: They stay connected, but it seems that there is
no read/write done between the socket and the channel. Still the
mainloop is running. I can add new channels, which also seems to
resurrect the other connectors.
I.e. after removing one ore more connectors, we have to add another to
make things work again... Or maybe I have to remove and re-add all
remaining connectors to the event again?

Then there is a second issue when the remote side (connected to the
socket on the server side) closes the connection. It seems that the
connector does not  detect this, and the connection hangs forever. How
can this be solved?

Cheers,
Till



Follow-Ups:
Re: Issues with Connector on net socketsg4-lisz@xxxxxxxxxxxx
Re: Issues with Connector on net socketsg4-lisz@xxxxxxxxxxxx
Archive administrator: postmaster@lists.cynapses.org