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

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

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

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