Blame SOURCES/dhcp-4.2.5-reap_orphan_sockets.patch

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

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

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