rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / network / isc-dhcp / patches / 003-Manage_41845.patch
blob80cdf9b6ebb38ae6de44b776e8cf1f31c41eedd2
1 This patch adds a method to manage the resource limit which was
2 introduced by the fix for ISC-Bugs #41845. This patch was developed
3 in-house. ISC did not express any interest in incorporating this patch
4 into their code since they consider the limit to be a mitigating
5 solution.
7 diff -r 1680283c6725 includes/omapip/omapip.h
8 --- a/includes/omapip/omapip.h Tue Jan 16 13:35:26 2018 -0800
9 +++ b/includes/omapip/omapip.h Tue Jan 16 18:01:14 2018 -0800
10 @@ -467,6 +467,9 @@
12 extern omapi_object_type_t *omapi_object_types;
14 +#if defined (sun)
15 +void omapi_set_max_fd_value (void);
16 +#endif
17 void omapi_type_relinquish (void);
18 isc_result_t omapi_init (void);
19 isc_result_t omapi_object_type_register (omapi_object_type_t **,
20 diff -r 1680283c6725 omapip/listener.c
21 --- a/omapip/listener.c Tue Jan 16 13:35:26 2018 -0800
22 +++ b/omapip/listener.c Tue Jan 16 18:01:14 2018 -0800
23 @@ -40,6 +40,10 @@
24 trace_type_t *trace_listener_accept;
25 #endif
27 +#if defined (sun)
28 +static int conn_limit = MAX_FD_VALUE; /* max number of open sockets allowed */
29 +#endif
31 OMAPI_OBJECT_ALLOC (omapi_listener,
32 omapi_listener_object_t, omapi_type_listener)
34 @@ -209,6 +213,35 @@
35 return l -> socket;
38 +#if defined (sun)
39 +/* If OMAPI_CONN_LIMIT environment variable is set, obtain value. */
40 +const char *fname = "omapi_set_max_fd_value";
41 +void omapi_set_max_fd_value (void)
43 + const char *env;
44 + char *end = NULL;
45 + int envval = conn_limit;
47 + env = getenv("OMAPI_CONN_LIMIT");
48 + if (env != NULL) {
49 + errno = 0;
50 + envval = (int)strtol(env, &end, 10);
51 + if (errno != 0 || env == end || *end != '\0' || envval < 0) {
52 + (void) log_error("%s: \"%s\" is not a valid connection "
53 + "limit value\n", fname, env);
54 + errno = 0;
55 + } else {
56 + conn_limit = envval;
57 + }
58 + }
59 + (void) log_debug("%s: conn_limit = %d%s\n", fname, conn_limit,
60 + (conn_limit == MAX_FD_VALUE) ? " (default)" :
61 + (conn_limit == 0) ? " (unlimited)" : "");
63 + return;
65 +#endif
67 /* Reader callback for a listener object. Accept an incoming connection. */
68 isc_result_t omapi_accept (omapi_object_t *h)
70 @@ -233,7 +266,13 @@
71 return ISC_R_UNEXPECTED;
74 +#if !defined (sun)
75 if ((MAX_FD_VALUE != 0) && (socket > MAX_FD_VALUE)) {
76 +#else
77 + if ((conn_limit != 0) && (socket > conn_limit)) {
78 + (void) log_debug("omapi_accept: No more available "
79 + "sockets - closing latest.\n");
80 +#endif
81 close(socket);
82 return (ISC_R_NORESOURCES);
84 diff -r 1680283c6725 server/dhcpd.c
85 --- a/server/dhcpd.c Tue Jan 16 13:35:26 2018 -0800
86 +++ b/server/dhcpd.c Tue Jan 16 18:01:14 2018 -0800
87 @@ -452,6 +452,10 @@
88 path_dhcpd_conf = s;
91 +#if defined (sun)
92 + omapi_set_max_fd_value ();
93 +#endif
95 #ifdef DHCPv6
96 if (local_family == AF_INET6) {
97 /* DHCPv6: override DHCPv4 lease and pid filenames */