BIND 10 trac2003, updated. 85fcef34522d4b51557583680a168372da7193f7 [2003] added get_total_len() DNSTCPSendBuffer and use it for better log msg.
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Jun 8 21:44:49 UTC 2012
The branch, trac2003 has been updated
via 85fcef34522d4b51557583680a168372da7193f7 (commit)
from 44ff85906acca45a6e94197b8c3eb9c306b94408 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 85fcef34522d4b51557583680a168372da7193f7
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Fri Jun 8 14:04:15 2012 -0700
[2003] added get_total_len() DNSTCPSendBuffer and use it for better log msg.
-----------------------------------------------------------------------
Summary of changes:
src/lib/python/isc/server_common/dns_tcp.py | 11 +++++++++--
.../isc/server_common/server_common_messages.mes | 4 ++--
.../python/isc/server_common/tests/dns_tcp_test.py | 5 +++++
3 files changed, 16 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/server_common/dns_tcp.py b/src/lib/python/isc/server_common/dns_tcp.py
index 270d11c..3b78d0d 100644
--- a/src/lib/python/isc/server_common/dns_tcp.py
+++ b/src/lib/python/isc/server_common/dns_tcp.py
@@ -74,6 +74,12 @@ class DNSTCPSendBuffer:
self.__lenbuf = struct.pack('H', socket.htons(self.__data_size))
self.__databuf = data
+ def get_total_len(self):
+ '''Return the total length of the buffer, including the length field.
+
+ '''
+ return self.__data_size + self.__len_size
+
def get_data(self, pos):
'''Return a portion of data from a specified position.
@@ -235,15 +241,16 @@ class DNSTCPContext:
try:
cc = self.__sock.send(data)
except socket.error as ex:
+ total_len = self.__send_buffer.get_total_len()
if ex.errno == errno.EAGAIN:
logger.debug(logger.DBGLVL_TRACE_DETAIL,
PYSERVER_COMMON_DNS_TCP_SEND_PENDING,
ClientFormatter(self.__remote_addr),
- self.__send_marker)
+ self.__send_marker, total_len)
return self.SENDING
logger.warn(PYSERVER_COMMON_DNS_TCP_SEND_ERROR,
ClientFormatter(self.__remote_addr),
- self.__send_marker, ex)
+ self.__send_marker, total_len, ex)
self.__sock.close()
self.__sock = None
return self.CLOSED
diff --git a/src/lib/python/isc/server_common/server_common_messages.mes b/src/lib/python/isc/server_common/server_common_messages.mes
index c0fc83f..bd4e3cc 100644
--- a/src/lib/python/isc/server_common/server_common_messages.mes
+++ b/src/lib/python/isc/server_common/server_common_messages.mes
@@ -27,7 +27,7 @@ transmitted over a TCP connection, possibly after multiple send
operations. The destination address and the total size of the message
(including the 2-byte length field) are shown in the log message.
-% PYSERVER_COMMON_DNS_TCP_SEND_ERROR failed to send TCP message to %1 (%2 bytes sent): %3
+% PYSERVER_COMMON_DNS_TCP_SEND_ERROR failed to send TCP message to %1 (%2/%3 bytes sent): %4
A DNS message has been attempted to be sent out over a TCP connection,
but it failed due to some network error. Although it's not expected
to happen too often, it can still happen for various reasons. The
@@ -37,7 +37,7 @@ be taken at the server side. When this message is logged, the
corresponding TCP connection was closed immediately after the error
was detected.
-% PYSERVER_COMMON_DNS_TCP_SEND_PENDING sent part TCP message to %1 (up to %2 bytes)
+% PYSERVER_COMMON_DNS_TCP_SEND_PENDING sent part TCP message to %1 (up to %2/%3 bytes)
Debug message. A part of DNS message has been transmitted over a TCP
connection, and it's suspended because further attempt would block.
The destination address and the total size of the message that has
diff --git a/src/lib/python/isc/server_common/tests/dns_tcp_test.py b/src/lib/python/isc/server_common/tests/dns_tcp_test.py
index e5306b6..c46906b 100644
--- a/src/lib/python/isc/server_common/tests/dns_tcp_test.py
+++ b/src/lib/python/isc/server_common/tests/dns_tcp_test.py
@@ -78,6 +78,11 @@ class BufferTest(unittest.TestCase):
self.check_length_field(buf, 0)
self.assertEqual(None, buf.get_data(2))
+ def test_get_total_len(self):
+ self.assertEqual(14, DNSTCPSendBuffer(b'x' * 12).get_total_len())
+ self.assertEqual(2, DNSTCPSendBuffer(b'').get_total_len())
+ self.assertEqual(65537, DNSTCPSendBuffer(b'X' * 65535).get_total_len())
+
class FakeSocket:
'''Emulating python socket w/o involving IO while allowing inspection.'''
def __init__(self, proto=socket.IPPROTO_TCP):
More information about the bind10-changes
mailing list