Blame SOURCES/dhcp-4.3.6-omapi-leak.patch

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

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

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