]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
[master] Plugs a socket descriptor leak in OMAPI
authorThomas Markwalder <tmark@isc.org>
Thu, 7 Dec 2017 16:23:36 +0000 (11:23 -0500)
committerThomas Markwalder <tmark@isc.org>
Thu, 7 Dec 2017 16:23:36 +0000 (11:23 -0500)
    Merges in rt46767.

RELNOTES
omapip/buffer.c
omapip/message.c

index a41f3c87de34880b895f5fc4061bc605fe8db819..c511428414b7c61639fbd402b402dd430320b24e 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -1254,6 +1254,11 @@ dhcp-users@lists.isc.org.
   to accomodate a change in behavior in BIND9 isc_heap_delete().
   [ISC-bugs #46719]
 
+- Plugged a socket descriptor leak in OMAPI, that can occur when there is
+  data pending to be written to an OMAPI connection, when the connection
+  is closed by the reader.
+  [ISc-Bugs #46767]
+
                        Changes since 4.2.0 (new features)
 
 - If a client renews before 'dhcp-cache-threshold' percent of its lease
index 6e0621b53347f912e1a9564589241d4b19f529f4..a21f0a80a4a2ca921016359d7b8c797b2f5b31ad 100644 (file)
@@ -565,6 +565,15 @@ isc_result_t omapi_connection_writer (omapi_object_t *h)
                        omapi_buffer_dereference (&buffer, MDL);
                }
        }
+
+       /* If we had data left to write when we're told to disconnect,
+       * we need recall disconnect, now that we're done writing.
+       * See rt46767. */
+       if (c->out_bytes == 0 && c->state == omapi_connection_disconnecting) {
+               omapi_disconnect (h, 1);
+               return ISC_R_SHUTTINGDOWN;
+       }
+
        return ISC_R_SUCCESS;
 }
 
index ee15d821495ba0573765e09882fce180d74810c4..37abbd25984cbeed70dff252788a0051300d670c 100644 (file)
@@ -339,7 +339,7 @@ isc_result_t omapi_message_unregister (omapi_object_t *mo)
 }
 
 #ifdef DEBUG_PROTOCOL
-static const char *omapi_message_op_name(int op) {
+const char *omapi_message_op_name(int op) {
        switch (op) {
        case OMAPI_OP_OPEN:    return "OMAPI_OP_OPEN";
        case OMAPI_OP_REFRESH: return "OMAPI_OP_REFRESH";