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>
diff --git a/src/hlua.c b/src/hlua.c
index fa67b15..abfb2b5 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -2084,6 +2084,13 @@
 
 	hlua = hlua_gethlua(L);
 	appctx = objt_appctx(socket->s->si[0].end);
+
+	/* inform the stream that we want to be notified whenever the
+	 * connection completes.
+	 */
+	si_applet_cant_get(&socket->s->si[0]);
+	si_applet_cant_put(&socket->s->si[0]);
+
 	if (!hlua_com_new(hlua, &appctx->ctx.hlua.wake_on_write))
 		WILL_LJMP(luaL_error(L, "out of memory"));
 	WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_socket_connect_yield, TICK_ETERNITY, 0));