void tcpv4_add_listener(struct listener *listener);
void tcpv6_add_listener(struct listener *listener);
int tcp_connect_server(struct stream_interface *si);
-int tcp_connect_probe(int fd);
+int tcp_connect_probe(struct connection *conn);
int tcp_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir);
int tcp_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir);
int tcp_inspect_request(struct session *s, struct buffer *req, int an_bit);
void (*shutw)(struct stream_interface *); /* shutw function */
void (*chk_rcv)(struct stream_interface *); /* chk_rcv function */
void (*chk_snd)(struct stream_interface *); /* chk_snd function */
- int (*read)(int fd); /* read callback after poll() */
- int (*write)(int fd); /* write callback after poll() */
+ int (*read)(struct connection *conn); /* read callback after poll() */
+ int (*write)(struct connection *conn); /* write callback after poll() */
void (*close)(struct connection *); /* close the data channel on the connection */
};
goto leave;
if (fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR))
- if (!conn->data->read(fd))
+ if (!conn->data->read(conn))
ret |= FD_WAIT_READ;
if (conn->flags & CO_FL_ERROR)
goto leave;
if (fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR))
- if (!conn->data->write(fd))
+ if (!conn->data->write(conn))
ret |= FD_WAIT_WRITE;
if (conn->flags & CO_FL_ERROR)
/* still waiting for a connection to establish and no data to
* send in order to probe it ? Then let's retry the connect().
*/
- if (!tcp_connect_probe(fd))
+ if (!tcp_connect_probe(conn))
ret |= FD_WAIT_WRITE;
}
* once the connection is established. It returns zero if it needs some polling
* before being called again.
*/
-int tcp_connect_probe(int fd)
+int tcp_connect_probe(struct connection *conn)
{
- struct connection *conn = fdtab[fd].owner;
+ int fd = conn->t.sock.fd;
struct stream_interface *si = container_of(conn, struct stream_interface, conn);
struct buffer *b = si->ob;
int retval = 0;
#include <types/global.h>
/* main event functions used to move data between sockets and buffers */
-static int sock_raw_read(int fd);
-static int sock_raw_write(int fd);
+static int sock_raw_read(struct connection *conn);
+static int sock_raw_write(struct connection *conn);
static void sock_raw_data_finish(struct stream_interface *si);
static void sock_raw_shutr(struct stream_interface *si);
static void sock_raw_shutw(struct stream_interface *si);
* able to read more data without polling first. Returns non-zero
* otherwise.
*/
-static int sock_raw_read(int fd)
+static int sock_raw_read(struct connection *conn)
{
- struct connection *conn = fdtab[fd].owner;
+ int fd = conn->t.sock.fd;
struct stream_interface *si = container_of(conn, struct stream_interface, conn);
struct buffer *b = si->ib;
int ret, max, retval, cur_read;
retval = 1;
- if (!conn)
- goto out_wakeup;
-
/* stop immediately on errors. Note that we DON'T want to stop on
* POLL_ERR, as the poller might report a write error while there
* are still data available in the recv buffer. This typically
* It returns 0 if the caller needs to poll before calling it again, otherwise
* non-zero.
*/
-static int sock_raw_write(int fd)
+static int sock_raw_write(struct connection *conn)
{
- struct connection *conn = fdtab[fd].owner;
+ int fd = conn->t.sock.fd;
struct stream_interface *si = container_of(conn, struct stream_interface, conn);
struct buffer *b = si->ob;
int retval = 1;
fprintf(stderr,"sock_raw_write : fd=%d, owner=%p\n", fd, fdtab[fd].owner);
#endif
- retval = 1;
- if (!conn)
- goto out_wakeup;
-
if (conn->flags & CO_FL_ERROR)
goto out_error;