BUG/MEDIUM: lua: outgoing connection was broken since 1.6-dev2

Tsvetan Tsvetanov reported that the following Lua code fails in
dev2 and dev3 :

	function hello(txn)
	    local request_msg = txn.req:dup()
	    local tsm_sock = core.tcp()
	    tsm_sock:connect("127.0.0.1", 7777)
	    local res = tsm_sock:send(request_msg)
	    local response = tsm_sock:receive('*l')
	    txn.res:send(response)
	    txn:close()
	end

Thierry diagnosed that it was caused by commit 563cc37 ("MAJOR: stream:
use a regular ->update for all stream interfaces"). It broke lua's
ability to establish outgoing connections.

The reason is that the applet used to be notified about established
connections just after the stream analyser loop, and that's not the
case anymore. In peers, this issue didn't happen because peers use
a handshake so after sending data, the response is received and wakes
the applet up again. Here we have to indicate that we want to send or
receive data, this will cause the notification to happen as soon as
the connection is ready. This is similar to pretending that we're
working on a full buffer after all. In theory subscribing for reads
is not needed, but it's added here for completeness.

Reported-By: Tsvetan Tsvetanov <cpi.cecko@gmail.com>
1 file changed