mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
This handshake handler must be independant, so move it away from proto_tcp. It has a dedicated connection flag. It is tested before I/O handlers and automatically removes the CO_FL_WAIT_L4_CONN flag upon success. It also sets the BF_WRITE_NULL flag on the stream interface and stops the SI timeout. However it does not perform the task_wakeup(), and relies on the data handler to do so for now. The SI wakeup will have to be moved elsewhere anyway.
54 lines
1.3 KiB
C
54 lines
1.3 KiB
C
/*
|
|
* Connection management functions
|
|
*
|
|
* Copyright 2000-2012 Willy Tarreau <w@1wt.eu>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*
|
|
*/
|
|
|
|
#include <common/compat.h>
|
|
#include <common/config.h>
|
|
|
|
#include <types/connection.h>
|
|
|
|
#include <proto/stream_interface.h>
|
|
|
|
/* I/O callback for fd-based connections. It calls the read/write handlers
|
|
* provided by the connection's sock_ops, which must be valid. It returns
|
|
* FD_WAIT_*.
|
|
*/
|
|
int conn_fd_handler(int fd)
|
|
{
|
|
struct connection *conn = fdtab[fd].owner;
|
|
int ret = 0;
|
|
|
|
if (!conn)
|
|
goto leave;
|
|
|
|
if (conn->flags & CO_FL_ERROR)
|
|
goto leave;
|
|
|
|
if (conn->flags & CO_FL_SI_SEND_PROXY)
|
|
if ((ret = conn_si_send_proxy(conn, CO_FL_SI_SEND_PROXY)))
|
|
goto leave;
|
|
|
|
if (fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR))
|
|
if (!conn->data->read(fd))
|
|
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))
|
|
ret |= FD_WAIT_WRITE;
|
|
leave:
|
|
/* remove the events before leaving */
|
|
fdtab[fd].ev &= ~(FD_POLL_IN | FD_POLL_OUT | FD_POLL_HUP | FD_POLL_ERR);
|
|
return ret;
|
|
}
|