Properly close omapi connection (#1523547)

This commit is contained in:
Pavel Zhukov 2017-12-08 11:07:37 +01:00
parent e701b476ce
commit 956986ca88
2 changed files with 61 additions and 1 deletions

View File

@ -0,0 +1,52 @@
commit ccff9ed69d0b26d33ce9cac8e83dab535b64d627
Author: Thomas Markwalder <tmark@isc.org>
Date: Tue Dec 5 15:12:34 2017 -0500
[46767] Plugged a socket descriptor leak in OMAPI
If disconnect is triggered by the reader closing the socket, while there
is data left to write, the socket would be orphaned.
omapip/buffer.c
omapi_connection_writea() - added logic to recall disconnect once
pending data has been written
omapip/message.c
Removed static declaration from omapi_message_unregister so you can
actually compile when DEBUG_PROTOCOL is defined.
Added a release note
diff --git a/omapip/buffer.c b/omapip/buffer.c
index 6e0621b..a21f0a8 100644
--- a/omapip/buffer.c
+++ b/omapip/buffer.c
@@ -565,6 +565,15 @@ isc_result_t omapi_connection_writer (omapi_object_t *h)
omapi_buffer_dereference (&buffer, MDL);
}
}
+
+ /* If we had data left to write when we're told to disconnect,
+ * we need recall disconnect, now that we're done writing.
+ * See rt46767. */
+ if (c->out_bytes == 0 && c->state == omapi_connection_disconnecting) {
+ omapi_disconnect (h, 1);
+ return ISC_R_SHUTTINGDOWN;
+ }
+
return ISC_R_SUCCESS;
}
diff --git a/omapip/message.c b/omapip/message.c
index ee15d82..37abbd2 100644
--- a/omapip/message.c
+++ b/omapip/message.c
@@ -339,7 +339,7 @@ isc_result_t omapi_message_unregister (omapi_object_t *mo)
}
#ifdef DEBUG_PROTOCOL
-static const char *omapi_message_op_name(int op) {
+const char *omapi_message_op_name(int op) {
switch (op) {
case OMAPI_OP_OPEN: return "OMAPI_OP_OPEN";
case OMAPI_OP_REFRESH: return "OMAPI_OP_REFRESH";

View File

@ -20,7 +20,7 @@ Summary: Dynamic host configuration protocol software
Name: dhcp
Version: 4.3.6
%global VERSION %%{version}%%{prever}
Release: 7%{?dist}
Release: 8%{?dist}
# NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to
# dcantrell maintaining the package) made incorrect use of the epoch and
# that's why it is at 12 now. It should have never been used, but it was.
@ -77,6 +77,7 @@ Patch36: dhcp-option97-pxe-client-id.patch
Patch37: dhcp-stateless-DUID-LLT.patch
Patch38: dhcp-dhclient-preinit6s.patch
Patch39: dhcp-handle_ctx_signals.patch
Patch40: dhcp-4.3.6-omapi-leak.patch
BuildRequires: autoconf
@ -339,6 +340,10 @@ rm bind/bind.tar.gz
# add signal handlers for proper work with share context
%patch39 -p1 -b .signals
# close omapi socker descriptions properly
# https://bugzilla.redhat.com/1523547
%patch40 -p1 -b .omapi-leak
# DHCLIENT_DEFAULT_PREFIX_LEN 64 -> 128
# https://bugzilla.gnome.org/show_bug.cgi?id=656610
sed -i -e 's|DHCLIENT_DEFAULT_PREFIX_LEN 64|DHCLIENT_DEFAULT_PREFIX_LEN 128|g' includes/site.h
@ -665,6 +670,9 @@ done
%endif
%changelog
* Fri Dec 8 2017 Pavel Zhukov <pzhukov@redhat.com> - 12:4.3.6-8
- Fix omapi SD leak (#1523547)
* Thu Nov 9 2017 Pavel Zhukov <pzhukov@redhat.com> - 12:4.3.6-7
- Add patch for proper signal handling with shared context (#1457871)