Blame SOURCES/dhcp-4.2.5-reap_orphan_sockets.patch

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

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

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