conn->data->close(conn);
}
+/* Calls the snd_buf() function of the data layer if any, otherwise
+ * returns 0.
+ */
+static inline int conn_data_snd_buf(struct connection *conn)
+{
+ if (!conn->data->snd_buf)
+ return 0;
+ return conn->data->snd_buf(conn);
+}
+
/* set polling depending on the change between the CURR part of the
* flags and the new flags in connection C. The connection flags are
* updated with the new flags at the end of the operation. Only the bits
void (*read)(struct connection *conn); /* read callback after poll() */
void (*write)(struct connection *conn); /* write callback after poll() */
void (*close)(struct connection *); /* close the data channel on the connection */
-
+ int (*snd_buf)(struct connection *conn); /* callback used to send a buffer contents */
};
/* A stream interface has 3 parts :
* This function is called to send buffer data to a stream socket.
* It returns -1 in case of unrecoverable error, otherwise zero.
*/
-static int sock_raw_write_loop(struct stream_interface *si, struct buffer *b)
+static int sock_raw_write_loop(struct connection *conn)
{
+ struct stream_interface *si = container_of(conn, struct stream_interface, conn);
+ struct buffer *b = si->ob;
int write_poll = MAX_WRITE_POLL_LOOPS;
int ret, max;
if (b->flags & BF_SHUTW)
return;
- if (sock_raw_write_loop(si, b) < 0)
+ if (conn_data_snd_buf(conn) < 0)
goto out_error;
/* OK all done */
(fdtab[si_fd(si)].ev & FD_POLL_OUT))) /* we'll be called anyway */
return;
- if (sock_raw_write_loop(si, ob) < 0) {
+ if (conn_data_snd_buf(&si->conn) < 0) {
/* Write error on the file descriptor. We mark the FD as STERROR so
* that we don't use it anymore and we notify the task.
*/
.chk_snd = sock_raw_chk_snd,
.read = sock_raw_read,
.write = sock_raw_write,
+ .snd_buf = sock_raw_write_loop,
.close = NULL,
};