[MINOR] introduce structures required to support Linux kernel splicing

When CONFIG_HAP_LINUX_SPLICE is defined, the buffer structure will be
slightly enlarged to support information needed for kernel splicing
on Linux.

A first attempt consisted in putting this information into the stream
interface, but in the long term, it appeared really awkward. This
version puts the information into the buffer. The platform-dependant
part is conditionally added and will only enlarge the buffers when
compiled in.

One new flag has also been added to the buffers: BF_KERN_SPLICING.
It indicates that the application considers it is appropriate to
use splicing to forward remaining data.
diff --git a/include/proto/buffers.h b/include/proto/buffers.h
index 1cd6650..9ebc6ff 100644
--- a/include/proto/buffers.h
+++ b/include/proto/buffers.h
@@ -54,6 +54,9 @@
 	buf->flags = BF_EMPTY;
 	buf->r = buf->lr = buf->w = buf->data;
 	buf->max_len = BUFSIZE;
+#if defined(CONFIG_HAP_LINUX_SPLICE)
+	buf->splice.prod = buf->splice.cons = -1; /* closed */
+#endif
 }
 
 /* returns 1 if the buffer is empty, 0 otherwise */
diff --git a/include/types/buffers.h b/include/types/buffers.h
index 11383f2..ca80809 100644
--- a/include/types/buffers.h
+++ b/include/types/buffers.h
@@ -83,6 +83,7 @@
 #define BF_HIJACK         0x040000  /* the producer is temporarily replaced by ->hijacker */
 #define BF_ANA_TIMEOUT    0x080000  /* the analyser timeout has expired */
 #define BF_READ_ATTACHED  0x100000  /* the read side is attached for the first time */
+#define BF_KERN_SPLICING  0x200000  /* kernel splicing desired for this buffer */
 
 /* Use these masks to clear the flags before going back to lower layers */
 #define BF_CLEAR_READ     (~(BF_READ_NULL|BF_READ_PARTIAL|BF_READ_ERROR|BF_READ_ATTACHED))
@@ -140,6 +141,12 @@
 	unsigned long long total;       /* total data read */
 	struct stream_interface *prod;  /* producer attached to this buffer */
 	struct stream_interface *cons;  /* consumer attached to this buffer */
+	struct {
+#if defined(CONFIG_HAP_LINUX_SPLICE)
+		int prod;               /* -1 or fd of the pipe's end towards the producer */
+		int cons;               /* -1 or fd of the pipe's end towards the consumer */
+#endif
+	} splice;
 	char data[BUFSIZE];
 };
 
diff --git a/src/session.c b/src/session.c
index aacde92..cd44199 100644
--- a/src/session.c
+++ b/src/session.c
@@ -64,6 +64,24 @@
 		sess_change_server(s, NULL);
 	}
 
+#if defined(CONFIG_HAP_LINUX_SPLICE)
+	if (s->req->splice.prod >= 0)
+		close(s->req->splice.prod);
+	if (s->req->splice.cons >= 0)
+		close(s->req->splice.cons);
+	
+	if (s->req->splice.prod >= 0 || s->req->splice.cons >= 0)
+		usedpipes--;
+
+	if (s->rep->splice.prod >= 0)
+		close(s->rep->splice.prod);
+	if (s->rep->splice.cons >= 0)
+		close(s->rep->splice.cons);
+
+	if (s->rep->splice.prod >= 0 || s->rep->splice.cons >= 0)
+		usedpipes--;
+#endif
+
 	pool_free2(pool2_buffer, s->req);
 	pool_free2(pool2_buffer, s->rep);