blob: be8525b86031d081c0d44f2deb6306597465efa0 [file] [log] [blame]
Willy Tarreau92fb9832007-10-16 17:34:28 +02001/*
2 * UNIX SOCK_STREAM protocol layer (uxst)
3 *
Willy Tarreaueb472682010-05-28 18:46:57 +02004 * Copyright 2000-2010 Willy Tarreau <w@1wt.eu>
Willy Tarreau92fb9832007-10-16 17:34:28 +02005 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
13#include <ctype.h>
14#include <errno.h>
15#include <fcntl.h>
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19#include <syslog.h>
20#include <time.h>
21
Willy Tarreau92fb9832007-10-16 17:34:28 +020022#include <sys/socket.h>
23#include <sys/stat.h>
24#include <sys/types.h>
25#include <sys/un.h>
26
Willy Tarreau4c7e4b72020-05-27 12:58:42 +020027#include <haproxy/api.h>
Willy Tarreau7ea393d2020-06-04 18:02:10 +020028#include <haproxy/connection.h>
Willy Tarreau8d366972020-05-27 16:10:29 +020029#include <haproxy/errors.h>
Willy Tarreaub2551052020-06-09 09:07:15 +020030#include <haproxy/fd.h>
Willy Tarreauf268ee82020-06-04 17:05:57 +020031#include <haproxy/global.h>
Willy Tarreau853b2972020-05-27 18:01:47 +020032#include <haproxy/list.h>
Willy Tarreau213e9902020-06-04 14:58:24 +020033#include <haproxy/listener.h>
Willy Tarreauaeed4a82020-06-04 22:01:04 +020034#include <haproxy/log.h>
Willy Tarreaub2551052020-06-09 09:07:15 +020035#include <haproxy/protocol.h>
Willy Tarreau18b7df72020-08-28 12:07:22 +020036#include <haproxy/sock.h>
Willy Tarreauf1725582020-08-28 15:30:11 +020037#include <haproxy/sock_unix.h>
Willy Tarreau92b4f132020-06-01 11:05:15 +020038#include <haproxy/time.h>
Willy Tarreaub2551052020-06-09 09:07:15 +020039#include <haproxy/tools.h>
Willy Tarreaud6788052020-05-27 15:59:00 +020040#include <haproxy/version.h>
Willy Tarreau92fb9832007-10-16 17:34:28 +020041
Willy Tarreau92fb9832007-10-16 17:34:28 +020042
Emeric Bruncf20bf12010-10-22 16:06:11 +020043static int uxst_bind_listener(struct listener *listener, char *errmsg, int errlen);
Olivier Houchardfdcb0072019-05-06 18:32:29 +020044static int uxst_connect_server(struct connection *conn, int flags);
Willy Tarreau9d5be5c2017-09-15 07:55:51 +020045static void uxst_add_listener(struct listener *listener, int port);
Willy Tarreau5ddf1ce2020-09-25 19:27:39 +020046static void uxst_enable_listener(struct listener *listener);
47static void uxst_disable_listener(struct listener *listener);
Willy Tarreaucb66ea62020-09-25 17:12:32 +020048static int uxst_suspend_receiver(struct receiver *rx);
Willy Tarreaudabf2e22007-10-28 21:59:24 +010049
50/* Note: must not be declared <const> as its list will be overwritten */
51static struct protocol proto_unix = {
52 .name = "unix_stream",
Willy Tarreaub0254cb2020-09-04 08:07:11 +020053 .fam = &proto_fam_unix,
Willy Tarreaua54553f2020-09-16 17:50:45 +020054 .ctrl_type = SOCK_STREAM,
Willy Tarreaudabf2e22007-10-28 21:59:24 +010055 .sock_domain = PF_UNIX,
56 .sock_type = SOCK_STREAM,
57 .sock_prot = 0,
Willy Tarreaucb66ea62020-09-25 17:12:32 +020058 .add = uxst_add_listener,
59 .listen = uxst_bind_listener,
Willy Tarreau5ddf1ce2020-09-25 19:27:39 +020060 .enable = uxst_enable_listener,
61 .disable = uxst_disable_listener,
Willy Tarreau7b2febd2020-10-09 17:18:29 +020062 .unbind = default_unbind_listener,
Willy Tarreaue03204c2020-10-09 17:02:21 +020063 .suspend = default_suspend_listener,
Willy Tarreau686fa3d2020-09-25 19:09:53 +020064 .rx_enable = sock_enable,
65 .rx_disable = sock_disable,
Willy Tarreauf58b8db2020-10-09 16:32:08 +020066 .rx_unbind = sock_unbind,
Willy Tarreaucb66ea62020-09-25 17:12:32 +020067 .rx_suspend = uxst_suspend_receiver,
Willy Tarreau7d053e42020-10-15 09:19:43 +020068 .rx_listening = sock_accepting_conn,
Willy Tarreaubbebbbf2012-05-07 21:22:09 +020069 .accept = &listener_accept,
Willy Tarreau47f48c42014-05-09 22:57:47 +020070 .connect = &uxst_connect_server,
Willy Tarreaud7f331c2020-09-25 17:01:43 +020071 .receivers = LIST_HEAD_INIT(proto_unix.receivers),
72 .nb_receivers = 0,
Willy Tarreaudabf2e22007-10-28 21:59:24 +010073};
74
Willy Tarreau0108d902018-11-25 19:14:37 +010075INITCALL1(STG_REGISTER, protocol_register, &proto_unix);
76
Willy Tarreaudabf2e22007-10-28 21:59:24 +010077/********************************
78 * 1) low-level socket functions
79 ********************************/
80
81
Cyril Bonté1f5848a2010-11-14 17:03:19 +010082/********************************
83 * 2) listener-oriented functions
84 ********************************/
85
Cyril Bonté1f5848a2010-11-14 17:03:19 +010086/* This function creates a UNIX socket associated to the listener. It changes
87 * the state from ASSIGNED to LISTEN. The socket is NOT enabled for polling.
Willy Tarreau8ab505b2013-01-24 01:41:38 +010088 * The return value is composed from ERR_NONE, ERR_RETRYABLE and ERR_FATAL. It
89 * may return a warning or an error message in <errmsg> if the message is at
90 * most <errlen> bytes long (including '\0'). Note that <errmsg> may be NULL if
91 * <errlen> is also zero.
Willy Tarreau92fb9832007-10-16 17:34:28 +020092 */
Cyril Bonté1f5848a2010-11-14 17:03:19 +010093static int uxst_bind_listener(struct listener *listener, char *errmsg, int errlen)
Willy Tarreau92fb9832007-10-16 17:34:28 +020094{
Willy Tarreaucd5e5ea2020-09-02 17:21:02 +020095 int fd, err;
96 int ready;
Willy Tarreaucd5e5ea2020-09-02 17:21:02 +020097 char *msg = NULL;
Willy Tarreau92fb9832007-10-16 17:34:28 +020098
Willy Tarreau3c5efa22014-07-07 18:36:45 +020099 err = ERR_NONE;
100
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100101 /* ensure we never return garbage */
Willy Tarreau8ab505b2013-01-24 01:41:38 +0100102 if (errlen)
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100103 *errmsg = 0;
104
105 if (listener->state != LI_ASSIGNED)
106 return ERR_NONE; /* already bound */
Willy Tarreau0b915012020-09-01 10:47:07 +0200107
Willy Tarreauad33acf2020-09-02 18:40:02 +0200108 if (!(listener->rx.flags & RX_F_BOUND)) {
109 msg = "receiving socket not bound";
110 goto uxst_return;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200111 }
112
Willy Tarreaucd5e5ea2020-09-02 17:21:02 +0200113 fd = listener->rx.fd;
Willy Tarreau7d053e42020-10-15 09:19:43 +0200114 ready = sock_accepting_conn(&listener->rx) > 0;
Willy Tarreau40aa0702013-03-10 23:51:38 +0100115
Willy Tarreaucd5e5ea2020-09-02 17:21:02 +0200116 if (!ready && /* only listen if not already done by external process */
Willy Tarreaue2711c72019-02-27 15:39:41 +0100117 listen(fd, listener_backlog(listener)) < 0) {
Willy Tarreau3c5efa22014-07-07 18:36:45 +0200118 err |= ERR_FATAL | ERR_ALERT;
Willy Tarreaub40dc942010-11-07 12:10:51 +0100119 msg = "cannot listen to UNIX socket";
Willy Tarreaucd5e5ea2020-09-02 17:21:02 +0200120 goto uxst_close_return;
Willy Tarreau92fb9832007-10-16 17:34:28 +0200121 }
122
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100123 /* the socket is now listening */
Willy Tarreaua37b2442020-09-24 07:23:45 +0200124 listener_set_state(listener, LI_LISTEN);
Willy Tarreau3c5efa22014-07-07 18:36:45 +0200125 return err;
126
Willy Tarreaucd5e5ea2020-09-02 17:21:02 +0200127 uxst_close_return:
Cyril Bonté1f5848a2010-11-14 17:03:19 +0100128 close(fd);
Willy Tarreauad33acf2020-09-02 18:40:02 +0200129 uxst_return:
Willy Tarreau40aa0702013-03-10 23:51:38 +0100130 if (msg && errlen) {
Willy Tarreaucd5e5ea2020-09-02 17:21:02 +0200131 const char *path = ((struct sockaddr_un *)&listener->rx.addr)->sun_path;
132 snprintf(errmsg, errlen, "%s [%s]", msg, path);
Willy Tarreau40aa0702013-03-10 23:51:38 +0100133 }
Willy Tarreau3c5efa22014-07-07 18:36:45 +0200134 return err;
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100135}
136
Willy Tarreau32282382017-09-15 07:44:44 +0200137/* Add <listener> to the list of unix stream listeners (port is ignored). The
138 * listener's state is automatically updated from LI_INIT to LI_ASSIGNED.
139 * The number of listeners for the protocol is updated.
Willy Tarreaudaacf362019-07-24 16:45:02 +0200140 *
141 * Must be called with proto_lock held.
142 *
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100143 */
Willy Tarreau9d5be5c2017-09-15 07:55:51 +0200144static void uxst_add_listener(struct listener *listener, int port)
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100145{
146 if (listener->state != LI_INIT)
147 return;
Willy Tarreaua37b2442020-09-24 07:23:45 +0200148 listener_set_state(listener, LI_ASSIGNED);
Willy Tarreaub7436612020-08-28 19:51:44 +0200149 listener->rx.proto = &proto_unix;
Willy Tarreaud7f331c2020-09-25 17:01:43 +0200150 LIST_ADDQ(&proto_unix.receivers, &listener->rx.proto_list);
151 proto_unix.nb_receivers++;
Willy Tarreaudabf2e22007-10-28 21:59:24 +0100152}
153
Willy Tarreau5ddf1ce2020-09-25 19:27:39 +0200154/* Enable receipt of incoming connections for listener <l>. The receiver must
155 * still be valid. Does nothing in early boot (needs fd_updt).
156 */
157static void uxst_enable_listener(struct listener *l)
158{
159 if (fd_updt)
160 fd_want_recv(l->rx.fd);
161}
162
163/* Disable receipt of incoming connections for listener <l>. The receiver must
164 * still be valid. Does nothing in early boot (needs fd_updt).
165 */
166static void uxst_disable_listener(struct listener *l)
167{
168 if (fd_updt)
169 fd_stop_recv(l->rx.fd);
170}
171
Willy Tarreaucb66ea62020-09-25 17:12:32 +0200172/* Suspend a receiver. Returns < 0 in case of failure, 0 if the receiver
173 * was totally stopped, or > 0 if correctly suspended. Nothing is done for
Willy Tarreaufd0e0082014-07-07 21:07:51 +0200174 * plain unix sockets since currently it's the new process which handles
Willy Tarreaue53608b2020-09-24 18:20:37 +0200175 * the renaming. Abstract sockets are completely unbound and closed so
176 * there's no need to stop the poller.
Willy Tarreaufd0e0082014-07-07 21:07:51 +0200177 */
Willy Tarreaucb66ea62020-09-25 17:12:32 +0200178static int uxst_suspend_receiver(struct receiver *rx)
Willy Tarreaufd0e0082014-07-07 21:07:51 +0200179{
Willy Tarreaucb66ea62020-09-25 17:12:32 +0200180 struct listener *l = LIST_ELEM(rx, struct listener *, rx);
181
182 if (((struct sockaddr_un *)&rx->addr)->sun_path[0])
Willy Tarreaufd0e0082014-07-07 21:07:51 +0200183 return 1;
184
Christopher Faulet510c0d62018-03-16 10:04:47 +0100185 /* Listener's lock already held. Call lockless version of
186 * unbind_listener. */
Willy Tarreau75c98d12020-10-09 15:55:23 +0200187 do_unbind_listener(l);
Willy Tarreaufd0e0082014-07-07 21:07:51 +0200188 return 0;
189}
190
Willy Tarreau47f48c42014-05-09 22:57:47 +0200191
192/*
193 * This function initiates a UNIX connection establishment to the target assigned
Willy Tarreauca9f5a92019-07-17 16:40:37 +0200194 * to connection <conn> using (si->{target,dst}). The source address is ignored
Willy Tarreau47f48c42014-05-09 22:57:47 +0200195 * and will be selected by the system. conn->target may point either to a valid
196 * server or to a backend, depending on conn->target. Only OBJ_TYPE_PROXY and
197 * OBJ_TYPE_SERVER are supported. The <data> parameter is a boolean indicating
198 * whether there are data waiting for being sent or not, in order to adjust data
199 * write polling and on some platforms. The <delack> argument is ignored.
200 *
201 * Note that a pending send_proxy message accounts for data.
202 *
203 * It can return one of :
Willy Tarreaue7dff022015-04-03 01:14:29 +0200204 * - SF_ERR_NONE if everything's OK
205 * - SF_ERR_SRVTO if there are no more servers
206 * - SF_ERR_SRVCL if the connection was refused by the server
207 * - SF_ERR_PRXCOND if the connection has been limited by the proxy (maxconn)
208 * - SF_ERR_RESOURCE if a system resource is lacking (eg: fd limits, ports, ...)
209 * - SF_ERR_INTERNAL for any other purely internal errors
Tim Düsterhus4896c442016-11-29 02:15:19 +0100210 * Additionally, in the case of SF_ERR_RESOURCE, an emergency log will be emitted.
Willy Tarreau47f48c42014-05-09 22:57:47 +0200211 *
Willy Tarreaue7dff022015-04-03 01:14:29 +0200212 * The connection's fd is inserted only when SF_ERR_NONE is returned, otherwise
Willy Tarreau47f48c42014-05-09 22:57:47 +0200213 * it's invalid and the caller has nothing to do.
214 */
Olivier Houchardfdcb0072019-05-06 18:32:29 +0200215static int uxst_connect_server(struct connection *conn, int flags)
Willy Tarreau47f48c42014-05-09 22:57:47 +0200216{
217 int fd;
218 struct server *srv;
219 struct proxy *be;
220
Willy Tarreau47f48c42014-05-09 22:57:47 +0200221 switch (obj_type(conn->target)) {
222 case OBJ_TYPE_PROXY:
223 be = objt_proxy(conn->target);
224 srv = NULL;
225 break;
226 case OBJ_TYPE_SERVER:
227 srv = objt_server(conn->target);
228 be = srv->proxy;
229 break;
230 default:
231 conn->flags |= CO_FL_ERROR;
Willy Tarreaue7dff022015-04-03 01:14:29 +0200232 return SF_ERR_INTERNAL;
Willy Tarreau47f48c42014-05-09 22:57:47 +0200233 }
234
Willy Tarreau585744b2017-08-24 14:31:19 +0200235 if ((fd = conn->handle.fd = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) {
Willy Tarreau47f48c42014-05-09 22:57:47 +0200236 qfprintf(stderr, "Cannot get a server socket.\n");
237
238 if (errno == ENFILE) {
239 conn->err_code = CO_ER_SYS_FDLIM;
240 send_log(be, LOG_EMERG,
Willy Tarreauc5532ac2018-01-29 15:06:04 +0100241 "Proxy %s reached system FD limit (maxsock=%d). Please check system tunables.\n",
242 be->id, global.maxsock);
Willy Tarreau47f48c42014-05-09 22:57:47 +0200243 }
244 else if (errno == EMFILE) {
245 conn->err_code = CO_ER_PROC_FDLIM;
246 send_log(be, LOG_EMERG,
Willy Tarreauc5532ac2018-01-29 15:06:04 +0100247 "Proxy %s reached process FD limit (maxsock=%d). Please check 'ulimit-n' and restart.\n",
248 be->id, global.maxsock);
Willy Tarreau47f48c42014-05-09 22:57:47 +0200249 }
250 else if (errno == ENOBUFS || errno == ENOMEM) {
251 conn->err_code = CO_ER_SYS_MEMLIM;
252 send_log(be, LOG_EMERG,
Willy Tarreauc5532ac2018-01-29 15:06:04 +0100253 "Proxy %s reached system memory limit (maxsock=%d). Please check system tunables.\n",
254 be->id, global.maxsock);
Willy Tarreau47f48c42014-05-09 22:57:47 +0200255 }
256 else if (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT) {
257 conn->err_code = CO_ER_NOPROTO;
258 }
259 else
260 conn->err_code = CO_ER_SOCK_ERR;
261
262 /* this is a resource error */
263 conn->flags |= CO_FL_ERROR;
Willy Tarreaue7dff022015-04-03 01:14:29 +0200264 return SF_ERR_RESOURCE;
Willy Tarreau47f48c42014-05-09 22:57:47 +0200265 }
266
267 if (fd >= global.maxsock) {
268 /* do not log anything there, it's a normal condition when this option
269 * is used to serialize connections to a server !
270 */
Christopher Faulet767a84b2017-11-24 16:50:31 +0100271 ha_alert("socket(): not enough free sockets. Raise -n argument. Giving up.\n");
Willy Tarreau47f48c42014-05-09 22:57:47 +0200272 close(fd);
273 conn->err_code = CO_ER_CONF_FDLIM;
274 conn->flags |= CO_FL_ERROR;
Willy Tarreaue7dff022015-04-03 01:14:29 +0200275 return SF_ERR_PRXCOND; /* it is a configuration limit */
Willy Tarreau47f48c42014-05-09 22:57:47 +0200276 }
277
278 if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
279 qfprintf(stderr,"Cannot set client socket to non blocking mode.\n");
280 close(fd);
281 conn->err_code = CO_ER_SOCK_ERR;
282 conn->flags |= CO_FL_ERROR;
Willy Tarreaue7dff022015-04-03 01:14:29 +0200283 return SF_ERR_INTERNAL;
Willy Tarreau47f48c42014-05-09 22:57:47 +0200284 }
285
William Lallemandc03eb012018-11-27 12:02:37 +0100286 if (master == 1 && (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)) {
287 ha_alert("Cannot set CLOEXEC on client socket.\n");
288 close(fd);
289 conn->err_code = CO_ER_SOCK_ERR;
290 conn->flags |= CO_FL_ERROR;
291 return SF_ERR_INTERNAL;
292 }
293
Willy Tarreau47f48c42014-05-09 22:57:47 +0200294 /* if a send_proxy is there, there are data */
Olivier Houchardfdcb0072019-05-06 18:32:29 +0200295 if (conn->send_proxy_ofs)
296 flags |= CONNECT_HAS_DATA;
Willy Tarreau47f48c42014-05-09 22:57:47 +0200297
298 if (global.tune.server_sndbuf)
299 setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &global.tune.server_sndbuf, sizeof(global.tune.server_sndbuf));
300
301 if (global.tune.server_rcvbuf)
302 setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &global.tune.server_rcvbuf, sizeof(global.tune.server_rcvbuf));
303
Willy Tarreauca9f5a92019-07-17 16:40:37 +0200304 if (connect(fd, (struct sockaddr *)conn->dst, get_addr_len(conn->dst)) == -1) {
Willy Tarreau94841792017-01-25 14:27:38 +0100305 if (errno == EINPROGRESS || errno == EALREADY) {
Willy Tarreau7bb21532014-05-10 09:48:28 +0200306 conn->flags |= CO_FL_WAIT_L4_CONN;
307 }
Willy Tarreau94841792017-01-25 14:27:38 +0100308 else if (errno == EISCONN) {
309 conn->flags &= ~CO_FL_WAIT_L4_CONN;
310 }
Willy Tarreau7bb21532014-05-10 09:48:28 +0200311 else if (errno == EAGAIN || errno == EADDRINUSE || errno == EADDRNOTAVAIL) {
Willy Tarreau47f48c42014-05-09 22:57:47 +0200312 char *msg;
313 if (errno == EAGAIN || errno == EADDRNOTAVAIL) {
Lukas Tribus9f256d42016-01-26 20:33:14 +0100314 msg = "can't connect to destination unix socket, check backlog size on the server";
Willy Tarreau47f48c42014-05-09 22:57:47 +0200315 conn->err_code = CO_ER_FREE_PORTS;
316 }
317 else {
318 msg = "local address already in use";
319 conn->err_code = CO_ER_ADDR_INUSE;
320 }
321
322 qfprintf(stderr,"Connect() failed for backend %s: %s.\n", be->id, msg);
323 close(fd);
324 send_log(be, LOG_ERR, "Connect() failed for backend %s: %s.\n", be->id, msg);
325 conn->flags |= CO_FL_ERROR;
Willy Tarreaue7dff022015-04-03 01:14:29 +0200326 return SF_ERR_RESOURCE;
Willy Tarreau47f48c42014-05-09 22:57:47 +0200327 }
328 else if (errno == ETIMEDOUT) {
329 close(fd);
330 conn->err_code = CO_ER_SOCK_ERR;
331 conn->flags |= CO_FL_ERROR;
Willy Tarreaue7dff022015-04-03 01:14:29 +0200332 return SF_ERR_SRVTO;
Willy Tarreau47f48c42014-05-09 22:57:47 +0200333 }
334 else { // (errno == ECONNREFUSED || errno == ENETUNREACH || errno == EACCES || errno == EPERM)
335 close(fd);
336 conn->err_code = CO_ER_SOCK_ERR;
337 conn->flags |= CO_FL_ERROR;
Willy Tarreaue7dff022015-04-03 01:14:29 +0200338 return SF_ERR_SRVCL;
Willy Tarreau47f48c42014-05-09 22:57:47 +0200339 }
340 }
Willy Tarreau7bb21532014-05-10 09:48:28 +0200341 else {
342 /* connect() already succeeded, which is quite usual for unix
Willy Tarreau94841792017-01-25 14:27:38 +0100343 * sockets. Let's avoid a second connect() probe to complete it.
Willy Tarreau7bb21532014-05-10 09:48:28 +0200344 */
345 conn->flags &= ~CO_FL_WAIT_L4_CONN;
Willy Tarreau7bb21532014-05-10 09:48:28 +0200346 }
Willy Tarreau47f48c42014-05-09 22:57:47 +0200347
348 conn->flags |= CO_FL_ADDR_TO_SET;
349
350 /* Prepare to send a few handshakes related to the on-wire protocol. */
351 if (conn->send_proxy_ofs)
352 conn->flags |= CO_FL_SEND_PROXY;
353
354 conn_ctrl_init(conn); /* registers the FD */
Willy Tarreau7bb21532014-05-10 09:48:28 +0200355 fdtab[fd].linger_risk = 0; /* no need to disable lingering */
Willy Tarreau47f48c42014-05-09 22:57:47 +0200356
Willy Tarreau4c69cff2020-03-04 16:38:00 +0100357 if (conn->flags & CO_FL_WAIT_L4_CONN) {
358 fd_want_send(fd);
359 fd_cant_send(fd);
Willy Tarreau8dbd1a22020-07-31 08:59:09 +0200360 fd_cant_recv(fd);
Willy Tarreau4c69cff2020-03-04 16:38:00 +0100361 }
Willy Tarreauccf3f6d2019-09-05 17:05:05 +0200362
Willy Tarreau47f48c42014-05-09 22:57:47 +0200363 if (conn_xprt_init(conn) < 0) {
Willy Tarreau8c829012017-10-05 18:02:11 +0200364 conn_full_close(conn);
Willy Tarreau47f48c42014-05-09 22:57:47 +0200365 conn->flags |= CO_FL_ERROR;
Willy Tarreaue7dff022015-04-03 01:14:29 +0200366 return SF_ERR_RESOURCE;
Willy Tarreau47f48c42014-05-09 22:57:47 +0200367 }
368
Willy Tarreaue7dff022015-04-03 01:14:29 +0200369 return SF_ERR_NONE; /* connection is OK */
Willy Tarreau47f48c42014-05-09 22:57:47 +0200370}
371
Willy Tarreau92fb9832007-10-16 17:34:28 +0200372/*
373 * Local variables:
374 * c-indent-level: 8
375 * c-basic-offset: 8
376 * End:
377 */