Blame SOURCES/dhcp-4.2.5-reap_orphan_sockets.patch

45d60a
commit ccff9ed69d0b26d33ce9cac8e83dab535b64d627
45d60a
Author: Thomas Markwalder <tmark@isc.org>
45d60a
Date:   Tue Dec 5 15:12:34 2017 -0500
45d60a

45d60a
    [46767] Plugged a socket descriptor leak in OMAPI
45d60a
    
45d60a
    If disconnect is triggered by the reader closing the socket, while there
45d60a
    is data left to write, the socket would be orphaned.
45d60a
    
45d60a
    omapip/buffer.c
45d60a
        omapi_connection_writea() - added logic to recall disconnect once
45d60a
        pending data has been written
45d60a
    
45d60a
    omapip/message.c
45d60a
        Removed static declaration from omapi_message_unregister so you can
45d60a
        actually compile when DEBUG_PROTOCOL is defined.
45d60a
    
45d60a
    Added a release note
45d60a

45d60a
diff --git a/omapip/buffer.c b/omapip/buffer.c
45d60a
index 6e0621b..a21f0a8 100644
45d60a
--- a/omapip/buffer.c
45d60a
+++ b/omapip/buffer.c
45d60a
@@ -565,6 +565,15 @@ isc_result_t omapi_connection_writer (omapi_object_t *h)
45d60a
 			omapi_buffer_dereference (&buffer, MDL);
45d60a
 		}
45d60a
 	}
45d60a
+
45d60a
+	/* If we had data left to write when we're told to disconnect,
45d60a
+	* we need recall disconnect, now that we're done writing.
45d60a
+	* See rt46767. */
45d60a
+	if (c->out_bytes == 0 && c->state == omapi_connection_disconnecting) {
45d60a
+		omapi_disconnect (h, 1);
45d60a
+		return ISC_R_SHUTTINGDOWN;
45d60a
+	}
45d60a
+
45d60a
 	return ISC_R_SUCCESS;
45d60a
 }
45d60a
 
45d60a
diff --git a/omapip/message.c b/omapip/message.c
45d60a
index ee15d82..37abbd2 100644
45d60a
--- a/omapip/message.c
45d60a
+++ b/omapip/message.c
45d60a
@@ -339,7 +339,7 @@ isc_result_t omapi_message_unregister (omapi_object_t *mo)
45d60a
 }
45d60a
 
45d60a
 #ifdef DEBUG_PROTOCOL
45d60a
-static const char *omapi_message_op_name(int op) {
45d60a
+const char *omapi_message_op_name(int op) {
45d60a
 	switch (op) {
45d60a
 	case OMAPI_OP_OPEN:    return "OMAPI_OP_OPEN";
45d60a
 	case OMAPI_OP_REFRESH: return "OMAPI_OP_REFRESH";