MEDIUM: stream: implement stream_buf_available()

This function replaces stream_res_available(), which is used as a callback
for the buffer allocator. It now carefully checks which stream interface
was blocked on a buffer allocation, tries to allocate the input buffer to
this stream interface, and wakes the task up once such a buffer was found.
It will automatically remove the SI_FL_WAIT_ROOM flag upon success since
the info this flag indicates becomes wrong as soon as the buffer is
allocated.

The code is still far from being perfect because if a call to si_cs_recv()
fails to allocate a buffer, we'll still end up passing via process_stream()
again, but this could be improved in the future by using finer-grained
wake-up notifications.
diff --git a/include/proto/stream.h b/include/proto/stream.h
index 0e1cf66..8c6773e 100644
--- a/include/proto/stream.h
+++ b/include/proto/stream.h
@@ -57,6 +57,7 @@
 /* Update the stream's backend and server time stats */
 void stream_update_time_stats(struct stream *s);
 void stream_release_buffers(struct stream *s);
+int stream_buf_available(void *arg);
 
 /* returns the session this stream belongs to */
 static inline struct session *strm_sess(const struct stream *strm)
@@ -347,18 +348,6 @@
 	LIST_INIT(&sess->by_srv);
 }
 
-/* Callback used to wake up a stream when a buffer is available. The stream <s>
- * is woken up is if it is not already running and if it is not already in the
- * task run queue. This functions returns 1 is the stream is woken up, otherwise
- * it returns 0. */
-static int inline stream_res_wakeup(struct stream *s)
-{
-	if (s->task->state & TASK_RUNNING)
-		return 0;
-	task_wakeup(s->task, TASK_WOKEN_RES);
-	return 1;
-}
-
 void service_keywords_register(struct action_kw_list *kw_list);
 
 #endif /* _PROTO_STREAM_H */