Blame SOURCES/dhcp-4.2.5-reap_orphan_sockets.patch

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

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

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