]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
12 years agoMEDIUM: ssl: add support for SNI and wildcard certificates
Emeric Brun [Fri, 7 Sep 2012 15:30:07 +0000 (17:30 +0200)] 
MEDIUM: ssl: add support for SNI and wildcard certificates

A side effect of this change is that the "ssl" keyword on "bind" lines is now
just a boolean and that "crt" is needed to designate certificate files or
directories.

Note that much refcounting was needed to have the free() work correctly due to
the number of cert aliases which can make a context be shared by multiple names.

12 years agoCONTRIB: halog: sort URLs by avg bytes_read or total bytes_read
Baptiste [Sat, 8 Sep 2012 21:10:03 +0000 (23:10 +0200)] 
CONTRIB: halog: sort URLs by avg bytes_read or total bytes_read

The patch attached to this mail brings ability to sort URLs by
averaged bytes read and total bytes read in HALog tool.
In most cases, bytes read is also the object size.
The purpose of this patch is to know which URL consume the most
bandwith, in average or in total.
It may be interesting as well to know the standard deviation (ecart
type in french) for some counters (like bytes_read).

The results:
- Sorting by average bytes read per URL:
./halog -uba <~/tmp/haproxy.log | column -t | head
2246 lines in, 302 lines out, 194 parsing errors
18    0    5101     283    5101   283    126573  2278327  /lib/exe/js.php
1     0    1        1      1      1      106734  106734   /wp-admin/images/screenshots/theme-customizer.png
2     0    2        1      2      1      106511  213022   /wp-admin/css/wp-admin.css
1     0    1        1      1      1      96698   96698    /wp-admin/images/screenshots/captions-1.png
1     0    1        1      1      1      73165   73165    /wp-admin/images/screenshots/flex-header-1.png
4     0    0        0      0      0      64832   259328   /cuisine/wp-content/plugins/stats/open-flash-chart.swf
1     0    0        0      0      0      48647   48647    /wp-admin/images/screenshots/flex-header-3.png
1     0    0        0      0      0      44046   44046    /wp-admin/images/screenshots/captions-2.png
1     0    1        1      1      1      38830   38830    /wp-admin/images/screenshots/flex-header-2.png

- Sorting by total bytes read per URL:
./halog -ubt <~/tmp/haproxy.log | column -t | head
2246 lines in, 302 lines out, 194 parsing errors
18    0    5101     283    5101   283    126573  2278327  /lib/exe/js.php
60    0    14387    239    14387  239    10081   604865   /lib/exe/css.php
64    2    8820     137    8819   142    7742    495524   /doku.php
14    0    250      17     250    17     24045   336632   /wp-admin/load-scripts.php
71    0    6422     90     6422   90     4048    287419   /wp-admin/
4     0    0        0      0      0      64832   259328   /cuisine/wp-content/plugins/stats/open-flash-chart.swf
2     0    2        1      2      1      106511  213022   /wp-admin/css/wp-admin.css
31    3    5423     174    5040   180    6804    210931   /index
10    0    429      42     429    42     18009   180093   /cuisine/files/2011/10/tarte_figue_amande-e1318281546905-225x300.jpg

12 years agoBUILD: makefile: report USE_OPENSSL status in build options
Willy Tarreau [Sat, 8 Sep 2012 09:28:56 +0000 (11:28 +0200)] 
BUILD: makefile: report USE_OPENSSL status in build options

12 years agoMEDIUM: config: centralize handling of SSL config per bind line
Willy Tarreau [Fri, 7 Sep 2012 14:58:00 +0000 (16:58 +0200)] 
MEDIUM: config: centralize handling of SSL config per bind line

SSL config holds many parameters which are per bind line and not per
listener. Let's use a per-bind line config instead of having it
replicated for each listener.

At the moment we only do this for the SSL part but this should probably
evolved to handle more of the configuration and maybe even the state per
bind line.

12 years agoBUILD: shut a gcc warning introduced by commit 269ab31
Willy Tarreau [Fri, 7 Sep 2012 20:18:59 +0000 (22:18 +0200)] 
BUILD: shut a gcc warning introduced by commit 269ab31

Usual warning on unchecked write() on which no operation is possible.

12 years agoLICENSE: add licence exception for OpenSSL
William Lallemand [Fri, 7 Sep 2012 08:48:59 +0000 (10:48 +0200)] 
LICENSE: add licence exception for OpenSSL

According to OpenSSL FAQ, GPL programs need an exception to use OpenSSL.

    http://openssl.org/support/faq.html#LEGAL2

12 years agoMINOR: config: make the tasks "nice" value configurable on "bind" lines.
Willy Tarreau [Thu, 6 Sep 2012 12:26:36 +0000 (14:26 +0200)] 
MINOR: config: make the tasks "nice" value configurable on "bind" lines.

This is very convenient to reduce SSL processing priority compared to
other traffic. This applies to CPU usage only, but has a direct impact
on latency under congestion.

12 years agoMEDIUM: connection: improve error handling around the data layer
Willy Tarreau [Thu, 6 Sep 2012 12:12:03 +0000 (14:12 +0200)] 
MEDIUM: connection: improve error handling around the data layer

Better avoid calling the data functions upon error or handshake than
having to put conditions everywhere, which are too easy to forget (one
check for CO_FL_ERROR was missing, but this was harmless).

12 years agoBUG: tcp: close socket fd upon connect error
Willy Tarreau [Thu, 6 Sep 2012 12:04:41 +0000 (14:04 +0200)] 
BUG: tcp: close socket fd upon connect error

When the data layer fails to initialize (eg: out of memory for SSL), we
must close the socket fd we just allocated.

12 years agoMEDIUM: config: implement maxsslconn in the global section
Willy Tarreau [Thu, 6 Sep 2012 09:58:37 +0000 (11:58 +0200)] 
MEDIUM: config: implement maxsslconn in the global section

SSL connections take a huge amount of memory, and unfortunately openssl
does not check malloc() returns and easily segfaults when too many
connections are used.

The only solution against this is to provide a global maxsslconn setting
to reject SSL connections above the limit in order to avoid reaching
unsafe limits.

12 years agoMINOR: session: do not send an HTTP/500 error on SSL sockets
Willy Tarreau [Thu, 6 Sep 2012 09:32:07 +0000 (11:32 +0200)] 
MINOR: session: do not send an HTTP/500 error on SSL sockets

If a session fails its initialization, we don't want to send HTTP/500
over the socket if it's not a raw data layer.

12 years agoMEDIUM: config: support per-listener backlog and maxconn
Willy Tarreau [Thu, 6 Sep 2012 09:10:55 +0000 (11:10 +0200)] 
MEDIUM: config: support per-listener backlog and maxconn

With SSL, connections are much more expensive, so it is important to be
able to limit concurrent connections per listener in order to limit the
memory usage.

12 years agoBUG/MEDIUM: workaround an eglibc bug which truncates the pidfiles when nbproc > 1
Willy Tarreau [Wed, 5 Sep 2012 06:02:48 +0000 (08:02 +0200)] 
BUG/MEDIUM: workaround an eglibc bug which truncates the pidfiles when nbproc > 1

Thomas Heil reported that when using nbproc > 1, his pidfiles were
regularly truncated. The issue could be tracked down to the presence
of a call to lseek(pidfile, 0, SEEK_SET) just before the close() call
in the children, resulting in the file being truncated by the children
while the parent was feeding it. This unexpected lseek() is transparently
performed by fclose().

Since there is no way to have the file automatically closed during the
fork, the only solution is to bypass the libc and use open/write/close
instead of fprintf() and fclose().

The issue was observed on eglibc 2.15.

12 years agoBUILD: ssl: use MAP_ANON instead of MAP_ANONYMOUS
Willy Tarreau [Tue, 4 Sep 2012 13:43:25 +0000 (15:43 +0200)] 
BUILD: ssl: use MAP_ANON instead of MAP_ANONYMOUS

FreeBSD uses the former, Linux uses the latter but generally also
defines the former as an alias of the latter. Just checked on other
OSes and AIX defines both. So better use MAP_ANON which seems to be
more commonly defined.

12 years agoMEDIUM: ssl: add support for prefer-server-ciphers option
David BERARD [Tue, 4 Sep 2012 13:15:13 +0000 (15:15 +0200)] 
MEDIUM: ssl: add support for prefer-server-ciphers option

I wrote a small path to add the SSL_OP_CIPHER_SERVER_PREFERENCE OpenSSL option
to frontend, if the 'prefer-server-ciphers' keyword is set.

Example :
bind 10.11.12.13 ssl /etc/haproxy/ssl/cert.pem ciphers RC4:HIGH:!aNULL:!MD5 prefer-server-ciphers

This option mitigate the effect of the BEAST Attack (as I understand), and it
equivalent to :
- Apache HTTPd SSLHonorCipherOrder option.
- Nginx ssl_prefer_server_ciphers option.

[WT: added a test for the support of the option]

12 years agoBUILD: fix build error without SSL (ssl_cert)
Willy Tarreau [Tue, 4 Sep 2012 13:13:20 +0000 (15:13 +0200)] 
BUILD: fix build error without SSL (ssl_cert)

One last-minute optimization broke the build without SSL support.
Move ssl_cert out of the #ifdef/#endif and it's OK.

12 years agoBUILD: include sys/socket.h to fix build failure on FreeBSD
Willy Tarreau [Tue, 4 Sep 2012 12:18:33 +0000 (14:18 +0200)] 
BUILD: include sys/socket.h to fix build failure on FreeBSD

Joris Dedieu reported that include/common/standard.h needs this.

12 years agoBUILD: ssl: fix shctx build on RHEL with futex
Willy Tarreau [Tue, 4 Sep 2012 10:26:26 +0000 (12:26 +0200)] 
BUILD: ssl: fix shctx build on RHEL with futex

On RHEL/CentOS, linux/futex.h uses an u32 type which is never declared
anywhere. Let's set it with a #define in order to fix the issue without
causing conflicts with possible typedefs on other platforms.

12 years agoBUILD: http: rename error_message http_error_message to fix conflicts on RHEL
Willy Tarreau [Tue, 4 Sep 2012 10:19:04 +0000 (12:19 +0200)] 
BUILD: http: rename error_message http_error_message to fix conflicts on RHEL

Duncan Hall reported a build issue on CentOS where error_message conflicts
with another system declaration when SSL is enabled. Rename the function.

12 years agoBUG: ssl: mark the connection as waiting for an SSL connection during the handshake
Willy Tarreau [Tue, 4 Sep 2012 06:03:39 +0000 (08:03 +0200)] 
BUG: ssl: mark the connection as waiting for an SSL connection during the handshake

The WAIT_L6_CONN was designed especially to ensure that the connection
was not marked ready before the SSL layer was OK, but we forgot to set
the flag, resulting in a rejected handshake when ssl was combined with
accept-proxy because accept-proxy would validate the connection alone
and the SSL handshake would then believe in a client-initiated reneg
and kill it.

12 years agoMEDIUM: config: add "nosslv3" and "notlsv1" on bind and server lines
Willy Tarreau [Mon, 3 Sep 2012 21:55:16 +0000 (23:55 +0200)] 
MEDIUM: config: add "nosslv3" and "notlsv1" on bind and server lines

This is aimed at disabling SSLv3 and TLSv1 respectively. SSLv2 is always
disabled. This can be used in some situations where one version looks more
suitable than the other.

12 years agoMEDIUM: config: add a "ciphers" keyword to set SSL cipher suites
Willy Tarreau [Mon, 3 Sep 2012 21:34:19 +0000 (23:34 +0200)] 
MEDIUM: config: add a "ciphers" keyword to set SSL cipher suites

This is supported for both servers and listeners. The cipher suite
simply follows the "ciphers" keyword.

12 years agoMINOR: ssl add global setting tune.sslcachesize to set SSL session cache size.
Emeric Brun [Mon, 3 Sep 2012 10:10:29 +0000 (12:10 +0200)] 
MINOR: ssl add global setting tune.sslcachesize to set SSL session cache size.

This new global setting allows the user to change the SSL cache size in
number of sessions. It defaults to 20000.

12 years agoMEDIUM: ssl: replace OpenSSL's session cache with the shared cache
Emeric Brun [Mon, 3 Sep 2012 09:53:36 +0000 (11:53 +0200)] 
MEDIUM: ssl: replace OpenSSL's session cache with the shared cache

OpenSSL's session cache is now totally disabled and we use our own
implementation instead.

12 years agoMEDIUM: ssl: add shared memory session cache implementation.
Emeric Brun [Mon, 3 Sep 2012 09:14:36 +0000 (11:14 +0200)] 
MEDIUM: ssl: add shared memory session cache implementation.

This SSL session cache was developped at Exceliance and is the same that
was proposed for stunnel and stud. It makes use of a shared memory area
between the processes so that sessions can be handled by any process. It
is only useful when haproxy runs with nbproc > 1, but it does not hurt
performance at all with nbproc = 1. The aim is to totally replace OpenSSL's
internal cache.

The cache is optimized for Linux >= 2.6 and specifically for x86 platforms.
On Linux/x86, it makes use of futexes for inter-process locking, with some
x86 assembly for the locked instructions. On other architectures, GCC
builtins are used instead, which are available starting from gcc 4.1.

On other operating systems, the locks fall back to pthread mutexes so
libpthread is automatically linked. It is not recommended since pthreads
are much slower than futexes. The lib is only linked if SSL is enabled.

12 years agoMINOR: ssl: disable TCP quick-ack by default on SSL listeners
Willy Tarreau [Mon, 3 Sep 2012 20:33:40 +0000 (22:33 +0200)] 
MINOR: ssl: disable TCP quick-ack by default on SSL listeners

Since the SSL handshake involves an immediate reply from the server
to the client, there's no point responding with a quick-ack before
sending the data, so disable quick-ack by default, just as it is done
for HTTP.

This shows a 2-2.5% transaction rate increase on a dual-core atom.

12 years agoBUILD: add optional support for SSL via the USE_OPENSSL flag
Emeric Brun [Fri, 18 May 2012 13:48:30 +0000 (15:48 +0200)] 
BUILD: add optional support for SSL via the USE_OPENSSL flag

When this flag is set, the SSL data layer is enabled.
At the moment, only the GNU makefile was touched, the other ones
make the option handling a bit tricky.

12 years agoMEDIUM: ssl: protect against client-initiated renegociation
Emeric Brun [Mon, 3 Sep 2012 18:36:47 +0000 (20:36 +0200)] 
MEDIUM: ssl: protect against client-initiated renegociation

CVE-2009-3555 suggests that client-initiated renegociation should be
prevented in the middle of data. The workaround here consists in having
the SSL layer notify our callback about a handshake occurring, which in
turn causes the connection to be marked in the error state if it was
already considered established (which means if a previous handshake was
completed). The result is that the connection with the client is immediately
aborted and any pending data are dropped.

12 years agoMEDIUM: config: add support for the 'ssl' option on 'server' lines
Emeric Brun [Fri, 18 May 2012 14:02:00 +0000 (16:02 +0200)] 
MEDIUM: config: add support for the 'ssl' option on 'server' lines

This option currently takes no option and simply turns SSL on for all
connections going to the server. It is likely that more options will
be needed in the future.

12 years agoMEDIUM: config: add the 'ssl' keyword on 'bind' lines
Emeric Brun [Fri, 18 May 2012 14:32:13 +0000 (16:32 +0200)] 
MEDIUM: config: add the 'ssl' keyword on 'bind' lines

"bind" now supports "ssl" followed by a PEM cert+key file name.

12 years agoMEDIUM: ssl: add new files ssl_sock.[ch] to provide the SSL data layer
Emeric Brun [Fri, 18 May 2012 13:47:34 +0000 (15:47 +0200)] 
MEDIUM: ssl: add new files ssl_sock.[ch] to provide the SSL data layer

This data layer supports socket-to-buffer and buffer-to-socket operations.
No sock-to-pipe nor pipe-to-sock functions are provided, since splicing does
not provide any benefit with data transformation. At best it could save a
memcpy() and avoid keeping a buffer allocated but that does not seem very
useful.

An init function and a close function are provided because the SSL context
needs to be allocated/freed.

A data-layer shutw() function is also provided because upon successful
shutdown, we want to store the SSL context in the cache in order to reuse
it for future connections and avoid a new key generation.

The handshake function is directly called from the connection handler.
At this point it is not certain whether this will remain this way or
if a new ->handshake callback will be added to the data layer so that
the connection handler doesn't care about SSL.

The sock-to-buf and buf-to-sock functions are all capable of enabling
the SSL handshake at any time. This also implies polling in the opposite
direction to what was expected. The upper layers must take that into
account (it is OK right now with the stream interface).

12 years agoMEDIUM: connection: add a new handshake flag for SSL (CO_FL_SSL_WAIT_HS).
Emeric Brun [Fri, 18 May 2012 13:47:34 +0000 (15:47 +0200)] 
MEDIUM: connection: add a new handshake flag for SSL (CO_FL_SSL_WAIT_HS).

This flag is part of the CO_FL_HANDSHAKE family since the SSL handshake
may appear at any time.

12 years agoMINOR: server: add SSL context to servers if USE_OPENSSL is defined
Emeric Brun [Fri, 18 May 2012 13:46:21 +0000 (15:46 +0200)] 
MINOR: server: add SSL context to servers if USE_OPENSSL is defined

This will be needed to accept outgoing SSL connections.

12 years agoMINOR: protocol: add SSL context to listeners if USE_OPENSSL is defined
Emeric Brun [Fri, 18 May 2012 13:46:21 +0000 (15:46 +0200)] 
MINOR: protocol: add SSL context to listeners if USE_OPENSSL is defined

This will be needed to accept incoming SSL connections.

12 years agoCLEANUP: includes: fix includes for a number of users of fd.h
Willy Tarreau [Sun, 2 Sep 2012 20:34:23 +0000 (22:34 +0200)] 
CLEANUP: includes: fix includes for a number of users of fd.h

It appears that fd.h includes a number of unneeded files and was
included from standard.h, and as such served as an intermediary
to provide almost everything to everyone.

By removing its useless includes, a long dependency chain broke
but could easily be fixed.

12 years agoCLEANUP: fdtab: flatten the struct and merge the spec struct with the rest
Willy Tarreau [Sun, 2 Sep 2012 20:19:18 +0000 (22:19 +0200)] 
CLEANUP: fdtab: flatten the struct and merge the spec struct with the rest

The "spec" sub-struct was using 8 bytes for only 5 needed. There is no
reason to keep it as a struct, it doesn't bring any value. By flattening
it, we can merge the single byte with the next single byte, resulting in
an immediate saving of 4 bytes (20%). Interestingly, tests have shown a
steady performance gain of 0.6% after this change, which can possibly be
attributed to a more cache-line friendly struct.

12 years agoCLEANUP: fd: remove fdtab->flags
Willy Tarreau [Sun, 2 Sep 2012 20:14:47 +0000 (22:14 +0200)] 
CLEANUP: fd: remove fdtab->flags

These flags were added for TCP_CORK. They were only set at various places
but never checked by any user since TCP_CORK was replaced with MSG_MORE.
Simply get rid of this now.

12 years agoMAJOR: stream_interface: continue to update data polling flags during handshakes
Willy Tarreau [Mon, 3 Sep 2012 14:51:27 +0000 (16:51 +0200)] 
MAJOR: stream_interface: continue to update data polling flags during handshakes

Since data and socket polling flags were split, it became possible to update
data flags even during handshakes. In fact this is very important otherwise
it is not possible to poll for writes if some data are to be forwarded during
a handshake (eg: data received during an SSL connect).

12 years agoMEDIUM: connection: avoid calling handshakes when polling is required
Willy Tarreau [Sun, 2 Sep 2012 16:48:46 +0000 (18:48 +0200)] 
MEDIUM: connection: avoid calling handshakes when polling is required

If a data handler suddenly switches to a handshake mode and detects the
need for polling in either direction, we don't want to loop again through
the handshake handlers because we know we won't be able to do anything.

Similarly, we don't want to call again the data handlers after a loop
through the handshake handlers if polling is required.

No performance change was observed, it might only be observed during
high rate SSL renegociation.

12 years agoMEDIUM: connection: complete the polling cleanups
Willy Tarreau [Sun, 2 Sep 2012 16:34:44 +0000 (18:34 +0200)] 
MEDIUM: connection: complete the polling cleanups

I/O handlers now all use __conn_{sock,data}_{stop,poll,want}_* instead
of returning dummy flags. The code has become slightly simpler because
some tricks such as the MIN_RET_FOR_READ_LOOP are not needed anymore,
and the data handlers which switch to a handshake handler do not need
to disable themselves anymore.

12 years agoMEDIUM: connection: only call tcp_connect_probe when nothing was attempted yet
Willy Tarreau [Sat, 1 Sep 2012 15:59:22 +0000 (17:59 +0200)] 
MEDIUM: connection: only call tcp_connect_probe when nothing was attempted yet

It was observed that after a failed send() on EAGAIN, a second connect()
would still be attempted in tcp_connect_probe() because there was no way
to know that a send() had failed.

By checking the WANT_WR status flag, we know if a previous write attempt
failed on EAGAIN, so we don't try to connect again if we know this has
already failed.

With this simple change, the second connect() has disappeared.

12 years agoMAJOR: connection: rearrange the polling flags.
Willy Tarreau [Sat, 1 Sep 2012 15:26:16 +0000 (17:26 +0200)] 
MAJOR: connection: rearrange the polling flags.

Polling flags were set for data and sock layer, but while this does make
sense for the ENA flag, it does not for the POL flag which translates the
detection of an EAGAIN condition. So now we remove the {DATA,SOCK}_POL*
flags and instead introduce two new layer-independant flags (WANT_RD and
WANT_WR). These flags are only set when an EAGAIN is encountered so that
polling can be enabled.

In order for these flags to have any meaning they are not persistent and
have to be cleared by the connection handler before calling the I/O and
data callbacks. For this reason, changes detection has been slightly
improved. Instead of comparing the WANT_* flags with CURR_*_POL, we only
check if the ENA status changes, or if the polling appears, since we don't
want to detect the useless poll to ena transition. Tests show that this
has eliminated one useless call to __fd_clr().

Finally the conn_set_polling() function which was becoming complex and
required complex operations from the caller was split in two and replaced
its two only callers (conn_update_data_polling and conn_update_sock_polling).
The two functions are now much smaller due to the less complex conditions.
Note that it would be possible to re-merge them and only pass a mask but
this does not appear much interesting.

12 years agoCLEANUP: frontend: remove the old proxy protocol decoder
Willy Tarreau [Fri, 31 Aug 2012 15:52:35 +0000 (17:52 +0200)] 
CLEANUP: frontend: remove the old proxy protocol decoder

This one used to rely on a stream analyser which was inappropriate.
It's not used anymore.

12 years agoMAJOR: connection: make the PROXY decoder a handshake handler
Willy Tarreau [Fri, 31 Aug 2012 15:43:29 +0000 (17:43 +0200)] 
MAJOR: connection: make the PROXY decoder a handshake handler

The PROXY protocol is now decoded in the connection before other
handshakes. This means that it may be extracted from a TCP stream
before SSL is decoded from this stream.

12 years agoMAJOR: session: introduce embryonic sessions
Willy Tarreau [Fri, 31 Aug 2012 14:01:23 +0000 (16:01 +0200)] 
MAJOR: session: introduce embryonic sessions

When an incoming connection request is accepted, a connection
structure is needed to store its state. However we don't want to
fully initialize a session until the data layer is about to be
ready.

As long as the connection is physically stored into the session,
it's not easy to split both allocations.

As such, we only initialize the minimum requirements of a session,
which results in what we call an embryonic session. Then once the
data layer is ready, we can complete the function's initialization.

Doing so avoids buffers allocation and ensures that a session only
sees ready connections.

The frontend's client timeout is used as the handshake timeout. It
is likely that another timeout will be used in the future.

12 years agoMEDIUM: connection: add an ->init function to data layer
Willy Tarreau [Fri, 31 Aug 2012 11:54:11 +0000 (13:54 +0200)] 
MEDIUM: connection: add an ->init function to data layer

SSL need to initialize the data layer before proceeding with data. At
the moment, this data layer is automatically initialized from itself,
which will not be possible once we extract connection from sessions
since we'll only create the data layer once the handshake is finished.

So let's have the application layer initialize the data layer before
using it.

12 years agoMINOR: tcp: replace tcp_src_to_stktable_key with addr_to_stktable_key
Willy Tarreau [Thu, 30 Aug 2012 20:59:48 +0000 (22:59 +0200)] 
MINOR: tcp: replace tcp_src_to_stktable_key with addr_to_stktable_key

Make it more obvious that this function does not depend on any knowledge
of the session. This is important to plan for TCP rules that can run on
connection without any initialized session yet.

12 years agoMEDIUM: proto_tcp: remove any dependence on stream_interface
Willy Tarreau [Thu, 30 Aug 2012 20:23:13 +0000 (22:23 +0200)] 
MEDIUM: proto_tcp: remove any dependence on stream_interface

The last uses of the stream interfaces were in tcp_connect_server() and
could easily and more appropriately be moved to its callers, si_connect()
and connect_server(), making a lot more sense.

Now the function should theorically be usable for health checks.

It also appears more obvious that the file is split into two distinct
parts :
  - the protocol layer used at the connection level
  - the tcp analysers executing tcp-* rules and their samples/acls.

12 years agoMEDIUM: stream_interface: remove CAP_SPLTCP/CAP_SPLICE flags
Willy Tarreau [Thu, 30 Aug 2012 19:23:53 +0000 (21:23 +0200)] 
MEDIUM: stream_interface: remove CAP_SPLTCP/CAP_SPLICE flags

These ones are implicitly handled by the connection's data layer, no need
to rely on them anymore and reaching them maintains undesired dependences
on stream-interface.

12 years agoMAJOR: connection: move the addr field from the stream_interface
Willy Tarreau [Thu, 30 Aug 2012 19:11:38 +0000 (21:11 +0200)] 
MAJOR: connection: move the addr field from the stream_interface

We need to have the source and destination addresses in the connection.
They were lying in the stream interface so let's move them. The flags
SI_FL_FROM_SET and SI_FL_TO_SET have been moved as well.

It's worth noting that tcp_connect_server() almost does not use the
stream interface anymore except for a few flags.

It has been identified that once we detach the connection from the SI,
it will probably be needed to keep a copy of the server-side addresses
in the SI just for logging purposes. This has not been implemented right
now though.

12 years agoREORG: connection: move the target pointer from si to connection
Willy Tarreau [Thu, 30 Aug 2012 13:49:18 +0000 (15:49 +0200)] 
REORG: connection: move the target pointer from si to connection

The target is per connection and is directly used by the connection, so
we need it there. It's not needed anymore in the SI however.

12 years agoCLEANUP: channel: use "channel" instead of "buffer" in function names
Willy Tarreau [Mon, 27 Aug 2012 22:06:31 +0000 (00:06 +0200)] 
CLEANUP: channel: use "channel" instead of "buffer" in function names

This is a massive rename of most functions which should make use of the
word "channel" instead of the word "buffer" in their names.

In concerns the following ones (new names) :

unsigned long long channel_forward(struct channel *buf, unsigned long long bytes);
static inline void channel_init(struct channel *buf)
static inline int channel_input_closed(struct channel *buf)
static inline int channel_output_closed(struct channel *buf)
static inline void channel_check_timeouts(struct channel *b)
static inline void channel_erase(struct channel *buf)
static inline void channel_shutr_now(struct channel *buf)
static inline void channel_shutw_now(struct channel *buf)
static inline void channel_abort(struct channel *buf)
static inline void channel_stop_hijacker(struct channel *buf)
static inline void channel_auto_connect(struct channel *buf)
static inline void channel_dont_connect(struct channel *buf)
static inline void channel_auto_close(struct channel *buf)
static inline void channel_dont_close(struct channel *buf)
static inline void channel_auto_read(struct channel *buf)
static inline void channel_dont_read(struct channel *buf)
unsigned long long channel_forward(struct channel *buf, unsigned long long bytes)

Some functions provided by channel.[ch] have kept their "buffer" name because
they are really designed to act on the buffer according to some information
gathered from the channel. They have been moved together to the same place in
the file for better readability but they were not changed at all.

The "buffer" memory pool was also renamed "channel".

12 years agoCLEANUP: channel: usr CF_/CHN_ prefixes instead of BF_/BUF_
Willy Tarreau [Mon, 27 Aug 2012 21:14:58 +0000 (23:14 +0200)] 
CLEANUP: channel: usr CF_/CHN_ prefixes instead of BF_/BUF_

Get rid of these confusing BF_* flags. Now channel naming should clearly
be used everywhere appropriate.

No code was changed, only a renaming was performed. The comments about
channel operations was updated.

12 years agoREORG: channel: move buffer_{replace,insert_line}* to buffer.{c,h}
Willy Tarreau [Mon, 27 Aug 2012 20:08:00 +0000 (22:08 +0200)] 
REORG: channel: move buffer_{replace,insert_line}* to buffer.{c,h}

These functions do not depend on the channel flags anymore thus they're
much better suited to be used on plain buffers. Move them from channel
to buffer.

12 years agoMAJOR: channel: remove the BF_FULL flag
Willy Tarreau [Mon, 27 Aug 2012 18:53:34 +0000 (20:53 +0200)] 
MAJOR: channel: remove the BF_FULL flag

This is similar to the recent removal of BF_OUT_EMPTY. This flag was very
problematic because it relies on permanently changing information such as the
to_forward value, so it had to be updated upon every change to the buffers.
Previous patch already got rid of its users.

One part of the change is sensible : the flag was also part of BF_MASK_STATIC,
which is used by process_session() to rescan all analysers in case the flag's
status changes. At first glance, none of the analysers seems to change its
mind base on this flag when it is subject to change, so it seems fine not to
add variation checks here. Otherwise it's possible that checking the buffer's
input and output is more reliable than checking the flag's replacement.

12 years agoMAJOR: channel: stop relying on BF_FULL to take action
Willy Tarreau [Mon, 27 Aug 2012 18:46:07 +0000 (20:46 +0200)] 
MAJOR: channel: stop relying on BF_FULL to take action

This flag is quite complex to get right and updating it everywhere is a
major pain, especially since the buffer/channel split. This is the first
step of getting rid of it. Instead now it's dynamically computed whenever
needed.

12 years agoMINOR: buffer: provide a new buffer_full() function
Willy Tarreau [Mon, 27 Aug 2012 17:51:36 +0000 (19:51 +0200)] 
MINOR: buffer: provide a new buffer_full() function

This one only focuses on the input part of the buffer and is dedicated
to analysers.

12 years agoMINOR: channel: rename bi_full to channel_full as it checks the whole channel
Willy Tarreau [Mon, 27 Aug 2012 16:54:20 +0000 (18:54 +0200)] 
MINOR: channel: rename bi_full to channel_full as it checks the whole channel

Since the function takes care of the forward count and involves more than
buffer knowledge, rename it.

12 years agoREORG: buffer: move buffer_flush, b_adv and b_rew to buffer.h
Willy Tarreau [Fri, 24 Aug 2012 20:56:11 +0000 (22:56 +0200)] 
REORG: buffer: move buffer_flush, b_adv and b_rew to buffer.h

These one now operate over real buffers, not channels anymore.

12 years agoMAJOR: channel: remove the BF_OUT_EMPTY flag
Willy Tarreau [Fri, 24 Aug 2012 20:40:29 +0000 (22:40 +0200)] 
MAJOR: channel: remove the BF_OUT_EMPTY flag

This flag was very problematic because it was composite in that both changes
to the pipe or to the buffer had to cause this flag to be updated, which is
not always simple (eg: there may not even be a channel attached to a buffer
at all).

There were not that many users of this flags, mostly setters. So the flag got
replaced with a macro which reports whether the channel is empty or not, by
checking both the pipe and the buffer.

One part of the change is sensible : the flag was also part of BF_MASK_STATIC,
which is used by process_session() to rescan all analysers in case the flag's
status changes. At first glance, none of the analysers seems to change its
mind base on this flag when it is subject to change, so it seems fine not to
add variation checks here. Otherwise it's possible that checking the buffer's
output size is more useful than checking the flag's replacement.

12 years agoREORG: buffers: split buffers into chunk,buffer,channel
Willy Tarreau [Fri, 24 Aug 2012 17:22:53 +0000 (19:22 +0200)] 
REORG: buffers: split buffers into chunk,buffer,channel

Many parts of the channel definition still make use of the "buffer" word.

12 years agoCLEANUP: connection: split sock_ops into data_ops, app_cp and si_ops
Willy Tarreau [Fri, 24 Aug 2012 16:12:41 +0000 (18:12 +0200)] 
CLEANUP: connection: split sock_ops into data_ops, app_cp and si_ops

Some parts of the sock_ops structure were only used by the stream
interface and have been moved into si_ops. Some of them were callbacks
to the stream interface from the connection and have been moved into
app_cp as they're the application seen from the connection (later,
health-checks will need to use them). The rest has moved to data_ops.

Normally at this point the connection could live without knowing about
stream interfaces at all.

12 years agoMEDIUM: stream-interface: don't remove WAIT_DATA when a handshake is in progress
Willy Tarreau [Fri, 24 Aug 2012 11:02:24 +0000 (13:02 +0200)] 
MEDIUM: stream-interface: don't remove WAIT_DATA when a handshake is in progress

This doesn't make sense and will only require that it's enabled again.

12 years agoMAJOR: stream-interface: fix splice not to call chk_snd by itself
Willy Tarreau [Fri, 24 Aug 2012 10:53:56 +0000 (12:53 +0200)] 
MAJOR: stream-interface: fix splice not to call chk_snd by itself

In recent splice fixes we made splice call chk_snd, but this was due
to inappropriate checks in conn_notify_si() which prevented the chk_snd()
call from being performed. Now that this has been fixed, remove this
duplicate code.

12 years agoMAJOR: stream-interface: don't commit polling changes in every callback
Willy Tarreau [Fri, 24 Aug 2012 10:52:22 +0000 (12:52 +0200)] 
MAJOR: stream-interface: don't commit polling changes in every callback

It's more efficient to centralize polling changes, which is already done
in the connection handler. So now all I/O callbacks just change flags and
rely on the connection handler for the commit. The special case of the
send loop is handled by the chk_snd() function which does an update at
the end.

12 years agoMEDIUM: proxy-proto: don't use buffer flags in conn_si_send_proxy()
Willy Tarreau [Fri, 24 Aug 2012 10:14:49 +0000 (12:14 +0200)] 
MEDIUM: proxy-proto: don't use buffer flags in conn_si_send_proxy()

These ones should only be handled by the stream interface at the end
of the handshake now. Similarly a number of information are now taken
at the connection level rather than at the data level (eg: shutdown).

Fast polling updates have been used instead of slow ones since the
function is only called by the connection handler.

12 years agoMAJOR: stream-interface: make conn_notify_si() more robust
Willy Tarreau [Fri, 24 Aug 2012 10:12:53 +0000 (12:12 +0200)] 
MAJOR: stream-interface: make conn_notify_si() more robust

This function was relying on the result of file descriptor polling
which is inappropriate as it may be subject to race conditions during
handshakes. Make it more robust by relying solely on buffer activity.

12 years agoMAJOR: stream-interface: restore splicing mechanism
Willy Tarreau [Thu, 23 Aug 2012 22:46:52 +0000 (00:46 +0200)] 
MAJOR: stream-interface: restore splicing mechanism

The splicing is now provided by the data-layer rcv_pipe/snd_pipe functions
which in turn are called by the stream interface's recv and send callbacks.

The presence of the rcv_pipe/snd_pipe functions is used to attest support
for splicing at the data layer. It looks like the stream-interface's
SI_FL_CAP_SPLICE flag does not make sense anymore as it's used as a proxy
for the pointers above.

It also appears that we call chk_snd() from the recv callback and then
try to call it again in update_conn(). It is very likely that this last
function will progressively slip into the recv/send callbacks in order
to avoid duplicate check code.

The code works right now with and without splicing. Only raw_sock provides
support for it and it is automatically selected when the various splice
options are set. However it looks like splice-auto doesn't enable it, which
possibly means that the streamer detection code does not work anymore, or
that it's only called at a time where it's too late to enable splicing (in
process_session).

12 years agoMAJOR: connection: split the send call into connection and stream interface
Willy Tarreau [Tue, 21 Aug 2012 16:22:06 +0000 (18:22 +0200)] 
MAJOR: connection: split the send call into connection and stream interface

Similar to what was done on the receive path, the data layer now provides
only an snd_buf() callback that is iterated over by the stream interface's
si_conn_send_loop() function.

The data layer now has no knowledge about channels nor stream interfaces.

The splice() code still need to be ported as it currently is disabled.

12 years agoREORG: stream-interface: move sock_raw_read() to si_conn_recv_cb()
Willy Tarreau [Mon, 20 Aug 2012 19:41:06 +0000 (21:41 +0200)] 
REORG: stream-interface: move sock_raw_read() to si_conn_recv_cb()

The recv function is now generic and is usable to iterate any connection-to-buf
reading function from a stream interface. So let's move it to stream-interface.

12 years agoMINOR: stream-interface: add an rcv_buf callback to sock_ops
Willy Tarreau [Mon, 20 Aug 2012 18:27:59 +0000 (20:27 +0200)] 
MINOR: stream-interface: add an rcv_buf callback to sock_ops

This one is to be used by the read I/O handlers.

12 years agoMAJOR: raw_sock: temporarily disable splicing
Willy Tarreau [Mon, 20 Aug 2012 18:21:01 +0000 (20:21 +0200)] 
MAJOR: raw_sock: temporarily disable splicing

It's too hard to convert splicing to connection+buf for now, so let's disable
it in order to make progress.

12 years agoMAJOR: raw_sock: extract raw_sock_to_buf() from raw_sock_read()
Willy Tarreau [Mon, 20 Aug 2012 15:30:32 +0000 (17:30 +0200)] 
MAJOR: raw_sock: extract raw_sock_to_buf() from raw_sock_read()

This is the start of the stream connection iterator which calls the
data-layer reader. This still looks a bit tricky but is OK. Splicing
is not handled at all at the moment.

12 years agoREORG: sock_raw: rename the files raw_sock*
Willy Tarreau [Mon, 20 Aug 2012 15:01:35 +0000 (17:01 +0200)] 
REORG: sock_raw: rename the files raw_sock*

The "raw_sock" prefix will be more convenient for naming functions as
it will be prefixed with the data layer and suffixed with the data
direction. So let's rename the files now to avoid any further confusion.

The #include directive was also removed from a number of files which do
not need it anymore.

12 years agoMINOR: connection: provide conn_{data|sock}_{read0|shutw} functions
Willy Tarreau [Mon, 20 Aug 2012 14:55:48 +0000 (16:55 +0200)] 
MINOR: connection: provide conn_{data|sock}_{read0|shutw} functions

These functions are used to report unidirectional shutdown and to disable
polling in the related direction.

12 years agoREORG/MAJOR: extract "struct buffer" from "struct channel"
Willy Tarreau [Mon, 2 Jul 2012 15:01:20 +0000 (17:01 +0200)] 
REORG/MAJOR: extract "struct buffer" from "struct channel"

At the moment, the struct is still embedded into the struct channel, but
all the functions have been updated to use struct buffer only when possible,
otherwise struct channel. Some functions would likely need to be splitted
between a buffer-layer primitive and a channel-layer function.

Later the buffer should become a pointer in the struct buffer, but doing so
requires a few changes to the buffer allocation calls.

12 years agoREORG/MAJOR: use "struct channel" instead of "struct buffer"
Willy Tarreau [Mon, 2 Jul 2012 13:11:27 +0000 (15:11 +0200)] 
REORG/MAJOR: use "struct channel" instead of "struct buffer"

This is a massive rename. We'll then split channel and buffer.

This change needs a lot of cleanups. At many locations, the parameter
or variable is still called "buf" which will become ambiguous. Also,
the "struct channel" is still defined in buffers.h.

12 years agoMEDIUM: stream-interface: provide a generic stream_sock_read0() function
Willy Tarreau [Mon, 20 Aug 2012 13:38:41 +0000 (15:38 +0200)] 
MEDIUM: stream-interface: provide a generic stream_sock_read0() function

This function is used by the data layer when a zero has been read over a
connection. At the moment it only handles sockets and nothing else. Once
the complete split is done between buffers and stream interfaces, it should
become possible to work regardless on the connection type.

12 years agoMEDIUM: stream-interface: provide a generic si_conn_send_cb callback
Willy Tarreau [Mon, 20 Aug 2012 13:09:53 +0000 (15:09 +0200)] 
MEDIUM: stream-interface: provide a generic si_conn_send_cb callback

The connection send() callback is supposed to be generic for a
stream-interface, and consists in calling the lower layer snd_buf
function. Move this function to the stream interface and remove
the sock-raw and sock-ssl clones.

12 years agoMEDIUM: stream-interface: provide a generic stream_int_chk_snd_conn() function
Willy Tarreau [Mon, 20 Aug 2012 13:01:10 +0000 (15:01 +0200)] 
MEDIUM: stream-interface: provide a generic stream_int_chk_snd_conn() function

This one can be used by both sock_raw and sock_ssl instead of each having their own.

12 years agoMEDIUM: stream-interface: add a snd_buf() callback to sock_ops
Willy Tarreau [Mon, 20 Aug 2012 12:02:10 +0000 (14:02 +0200)] 
MEDIUM: stream-interface: add a snd_buf() callback to sock_ops

This callback is used to send data from the buffer to the socket. It is
the old write_loop() call of the data layer which is used both by the
->write() callback and the ->chk_snd() function. The reason for having
it as a pointer is that it's the only remaining part which causes the
write and chk_snd() functions to be different between raw and ssl.

12 years agoMEDIUM: stream-interface: offer a generic chk_rcv function for connections
Willy Tarreau [Mon, 20 Aug 2012 10:38:36 +0000 (12:38 +0200)] 
MEDIUM: stream-interface: offer a generic chk_rcv function for connections

sock_raw and sock_ssl use a pretty generic chk_rcv function, so let's move
this function to the stream_interface and remove specific functions. Later
we might have a single chk_rcv function.

12 years agoMEDIUM: stream_interface: offer a generic function for connection updates
Willy Tarreau [Mon, 20 Aug 2012 10:06:26 +0000 (12:06 +0200)] 
MEDIUM: stream_interface: offer a generic function for connection updates

We need to have a generic function to be called by upper layers when buffer
flags have been updated (the si->update function). At the moment, both sock_raw
and sock_ssl had their own which basically was a copy-paste. Since these
functions are only used to update stream interface flags, it is logical to
have them handled by the stream interface code.

This allowed us to remove the stream_interface-specific update function from
sock_raw and sock_ssl which now use the generic code.

The stream_sock_update_conn callback has also been more appropriately renamed
conn_notify_si() since it's meant to be called by lower layers to notify the
SI and possibly upper layers about incoming changes.

12 years agoMINOR: fd: get rid of FD_WAIT_*
Willy Tarreau [Fri, 17 Aug 2012 21:55:05 +0000 (23:55 +0200)] 
MINOR: fd: get rid of FD_WAIT_*

These flags were used to ease a transition which has been completed,
so they're not needed anymore. Get rid of them.

12 years agoMEDIUM: checks: don't use FD_WAIT_* anymore
Willy Tarreau [Fri, 17 Aug 2012 21:53:56 +0000 (23:53 +0200)] 
MEDIUM: checks: don't use FD_WAIT_* anymore

make use of fd_poll_* instead in preparation for a later adoption by the
connection subsystem.

12 years agoMAJOR: make use of conn_{data|sock}_{poll|stop|want}* in connection handlers
Willy Tarreau [Thu, 9 Aug 2012 12:45:22 +0000 (14:45 +0200)] 
MAJOR: make use of conn_{data|sock}_{poll|stop|want}* in connection handlers

This is a second attempt at getting rid of FD_WAIT_*. Now the situation is
much better since native I/O handlers can directly manipulate the FD using
fd_{poll|want|stop}_* and the connection handlers manipulate connection-level
flags using the conn_{data|sock}_* equivalent.

Proceeding this way ensures that the connection flags always reflect the
reality even after data<->handshake switches.

12 years agoMEDIUM: connection: make use of the new polling functions
Willy Tarreau [Fri, 17 Aug 2012 15:33:53 +0000 (17:33 +0200)] 
MEDIUM: connection: make use of the new polling functions

Now the connection handler, the handshake callbacks and the I/O callbacks
make use of the connection-layer polling functions to enable or disable
polling on a file descriptor.

Some changes still need to be done to avoid using the FD_WAIT_* constants.

12 years agoMEDIUM: connection: add definitions for dual polling mechanisms
Willy Tarreau [Fri, 17 Aug 2012 09:55:04 +0000 (11:55 +0200)] 
MEDIUM: connection: add definitions for dual polling mechanisms

The conflicts we're facing with polling is that handshake handlers have
precedence over data handlers and may change the polling requirements
regardless of what is expected by the data layer. This causes issues
such as missed events.

The real need is to have three polling levels :
  - the "current" one, which is effective at any moment
  - the data one, which reflects what the data layer asks for
  - the sock one, which reflects what the socket layer asks for

Depending on whether a handshake is in progress or not, either one of the
last two will replace the current one, and the change will be propagated
to the lower layers.

At the moment, the shutdown status is not considered, and only handshakes
are used to decide which layer to chose. This will probably change.

12 years agoMEDIUM: fd: add fd_poll_{recv,send} for use when explicit polling is required
Willy Tarreau [Thu, 9 Aug 2012 10:14:03 +0000 (12:14 +0200)] 
MEDIUM: fd: add fd_poll_{recv,send} for use when explicit polling is required

The old EV_FD_SET() macro was confusing, as it would enable receipt but there
was no way to indicate that EAGAIN was received, hence the recently added
FD_WAIT_* flags. They're not enough as we're still facing a conflict between
EV_FD_* and FD_WAIT_*. So let's offer I/O functions what they need to explicitly
request polling.

12 years agoMAJOR: fd: replace all EV_FD_* macros with new fd_*_* inline calls
Willy Tarreau [Thu, 9 Aug 2012 10:11:58 +0000 (12:11 +0200)] 
MAJOR: fd: replace all EV_FD_* macros with new fd_*_* inline calls

These functions have a more explicity meaning and will offer provisions
for explicit polling.

EV_FD_ISSET() has been left for now as it is still in use in checks.

12 years agoMAJOR: stream_int: use a common stream_int_shut*() functions regardless of the data...
Willy Tarreau [Mon, 6 Aug 2012 17:31:45 +0000 (19:31 +0200)] 
MAJOR: stream_int: use a common stream_int_shut*() functions regardless of the data layer

Up to now, we had to use a shutr/shutw interface per data layer, which
basically means 3 distinct functions when we include SSL :
  - generic stream_interface
  - sock_raw
  - sock_ssl

With this change, the code located in the stream_interface manages all the
stream_interface and buffer updates, and calls the data layer hooks when
needed.

At the moment, the socket layer hook had been implicitly considered as
being a regular socket, so the si_shut*() functions call the normal
shutdown() and EV_FD_CLR() functions on the fd if a socket layer is
defined. This may change in the future. The stream_int_shut*()
functions don't call EV_FD_CLR() so that they can later be embedded
in lower layers.

Thus, the si->data->shutr() is not called anymore and si->data->shutw()
is called to close the data layer only (eg: only for SSL).

Proceeding like this is very important because it's the only way to be
able not to rely on these functions when called from the connection
handlers, and call the data layers' instead.

12 years agoMEDIUM: sock_raw: introduce a read0 callback that is different from shutr
Willy Tarreau [Mon, 6 Aug 2012 15:00:18 +0000 (17:00 +0200)] 
MEDIUM: sock_raw: introduce a read0 callback that is different from shutr

This one is supposed to be called by the lower layer upon receiving a shutr
notification, which is different from the call performed by the upper layer.
Specifically, this function will ultimately not call EV_FD_* but will just
manipulate event flags instead. The function also does not call shutw anymore
and instead performs the necessary work.

Splitting it into si-specific part and data-specific parts will not be easy.

12 years agoREORG: connection: replace si_data_close() with conn_data_close()
Willy Tarreau [Mon, 6 Aug 2012 13:06:49 +0000 (15:06 +0200)] 
REORG: connection: replace si_data_close() with conn_data_close()

This close function only applies to connection-specific parts and
the stream-interface entry may soon disappear. Move this to the
connection instead.

12 years agoMINOR: sock_raw: move calls to si_data_close upper
Willy Tarreau [Mon, 6 Aug 2012 10:23:51 +0000 (12:23 +0200)] 
MINOR: sock_raw: move calls to si_data_close upper

Some users of si_data_close() need to have the fd still open,
so we must move the call before fd_delete().

12 years agoMEDIUM: fd: remove the EV_FD_COND_* primitives
Willy Tarreau [Mon, 30 Jul 2012 12:29:35 +0000 (14:29 +0200)] 
MEDIUM: fd: remove the EV_FD_COND_* primitives

These primitives were initially introduced so that callers were able to
conditionally set/disable polling on a file descriptor and check in return
what the state was. It's been long since we last had an "if" on this, and
all pollers' functions were the same for cond_* and their systematic
counter parts, except that this required a check and a specific return
value that are not always necessary.

So let's simplify the FD API by removing this now unused distinction and
by making all specific functions return void.

12 years agoMAJOR: connection: call data layer handshakes from the handler
Willy Tarreau [Thu, 12 Jul 2012 13:32:13 +0000 (15:32 +0200)] 
MAJOR: connection: call data layer handshakes from the handler

Handshakes is not called anymore from the data handlers, they're only
called from the connection handler when their flag is set.

Also, this move has uncovered an issue with the stream interface notifier :
it doesn't consider the FD_WAIT_* flags possibly set by the handshake
handlers. This will result in a stuck handshake when no data is in the
output buffer. In order to cover this, for now we'll perform the EV_FD_SET
in the SSL handshake function, but this needs to be addressed separately
from the stream interface operations.

12 years agoMINOR: rearrange tcp_connect_probe() and fix wrong return codes
Willy Tarreau [Mon, 23 Jul 2012 18:05:00 +0000 (20:05 +0200)] 
MINOR: rearrange tcp_connect_probe() and fix wrong return codes

Sometimes we returned the need for polling while it was not needed. Remove
some of the spaghetti in the function.

12 years agoMAJOR: connection: add a new CO_FL_CONNECTED flag
Willy Tarreau [Mon, 23 Jul 2012 17:45:44 +0000 (19:45 +0200)] 
MAJOR: connection: add a new CO_FL_CONNECTED flag

This new flag is used to indicate that the connection was already
connected. It can be used by I/O handlers to know that a connection
has just completed. It is used by stream_sock_update_conn(), allowing
the sock_opt handlers not to manipulate the SI timeout nor the
BF_WRITE_NULL flag anymore.

12 years agoMEDIUM: stream_interface: centralize the SI_FL_ERR management
Willy Tarreau [Mon, 23 Jul 2012 17:19:51 +0000 (19:19 +0200)] 
MEDIUM: stream_interface: centralize the SI_FL_ERR management

It's better to have only stream_sock_update_conn() handle the conversion
of the CO_FL_ERROR flag to SI_FL_ERR than having it in each and every I/O
callback.

12 years agoMEDIUM: stream_interface: pass connection instead of fd in sock_ops
Willy Tarreau [Mon, 23 Jul 2012 16:53:03 +0000 (18:53 +0200)] 
MEDIUM: stream_interface: pass connection instead of fd in sock_ops

The sock_ops I/O callbacks made use of an FD till now. This has become
inappropriate and the struct connection is much more useful. It also
fixes the race condition introduced by previous change.