summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_listen_socket.h
blob: 8bf320bc190207ef8447d5e5cba814e261662e76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) NGINX, Inc.
 */

#ifndef _NXT_LISTEN_SOCKET_H_INCLUDED_
#define _NXT_LISTEN_SOCKET_H_INCLUDED_


typedef struct {
    /* nxt_socket_t is int. */
    nxt_socket_t              socket;
    int                       backlog;

    nxt_work_queue_t          *work_queue;
    nxt_work_handler_t        handler;

    nxt_sockaddr_t            *sockaddr;

    uint32_t                  count;

    uint8_t                   flags;
    uint8_t                   read_after_accept;   /* 1 bit */

#if (NXT_TLS)
    uint8_t                   tls;                 /* 1 bit */
#endif
#if (NXT_INET6 && defined IPV6_V6ONLY)
    uint8_t                   ipv6only;            /* 2 bits */
#endif

    uint8_t                   socklen;
    uint8_t                   address_length;
} nxt_listen_socket_t;


#if (NXT_LINUX || NXT_FREEBSD || NXT_MACOSX || NXT_OPENBSD)
/*
 * A backlog is limited by system-wide sysctl {net.core,kern.ipc}.somaxconn.
 * This is supported by Linux, FreeBSD 2.2, OpenBSD 2.0, and MacOSX.
 */
#define NXT_LISTEN_BACKLOG    -1

#else
/*
 * Solaris and NetBSD treat negative value as 0.
 * 511 is a safe default.
 */
#define NXT_LISTEN_BACKLOG    511
#endif


NXT_EXPORT nxt_int_t nxt_listen_socket(nxt_task_t *task, nxt_socket_t s,
    int backlog);

NXT_EXPORT nxt_int_t nxt_listen_socket_create(nxt_task_t *task, nxt_mp_t *mp,
    nxt_listen_socket_t *ls);
NXT_EXPORT nxt_int_t nxt_listen_socket_update(nxt_task_t *task,
    nxt_listen_socket_t *ls, nxt_listen_socket_t *prev);
NXT_EXPORT void nxt_listen_socket_remote_size(nxt_listen_socket_t *ls);
NXT_EXPORT size_t nxt_listen_socket_pool_min_size(nxt_listen_socket_t *ls);


#endif /* _NXT_LISTEN_SOCKET_H_INCLUDED_ */