[svn] commit: r3375 - in /branches/trac216/src/bin/xfrin: tests/xfrin_test.py xfrin.py.in
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Oct 27 14:04:50 UTC 2010
Author: shentingting
Date: Wed Oct 27 14:04:50 2010
New Revision: 3375
Log:
delete connect function and EWOULDBLOCK error code, add a test case for send_data function
Modified:
branches/trac216/src/bin/xfrin/tests/xfrin_test.py
branches/trac216/src/bin/xfrin/xfrin.py.in
Modified: branches/trac216/src/bin/xfrin/tests/xfrin_test.py
==============================================================================
--- branches/trac216/src/bin/xfrin/tests/xfrin_test.py (original)
+++ branches/trac216/src/bin/xfrin/tests/xfrin_test.py Wed Oct 27 14:04:50 2010
@@ -171,6 +171,9 @@
if self.response_generator != None:
self.response_generator()
return len(data)
+
+ def mock_send(self, data):
+ return 0
def create_response_data(self, response = True, bad_qid = False,
rcode = Rcode.NOERROR(),
@@ -274,6 +277,12 @@
self.conn_sockets[0].send(b"shutdown")
self.assertRaises(XfrinException, super(MockXfrinConnection,
self.conn)._select)
+ def test_send_data_nodate(self):
+ self.conn._socket.close()
+ self.conn._socket = MockSocket()
+ self.conn.send = self.conn.mock_send
+ self.assertRaises(XfrinException, self.conn._send_data, b"test no data")
+
def test_init_ip6(self):
# This test simply creates a new XfrinConnection object with an
# IPv6 address, tries to bind it to an IPv6 wildcard address/port
Modified: branches/trac216/src/bin/xfrin/xfrin.py.in
==============================================================================
--- branches/trac216/src/bin/xfrin/xfrin.py.in (original)
+++ branches/trac216/src/bin/xfrin/xfrin.py.in Wed Oct 27 14:04:50 2010
@@ -27,7 +27,7 @@
import select
import random
import time
-from errno import EINPROGRESS, EWOULDBLOCK, ECONNRESET, \
+from errno import ECONNRESET,\
ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, errorcode
from optparse import OptionParser, OptionValueError
@@ -93,23 +93,12 @@
self._verbose = verbose
self._master_address = master_addrinfo[4]
- def connect(self, address):
- try:
- self._socket.connect(address)
- except socket.error as why:
- if why.args[0] in (EINPROGRESS, EWOULDBLOCK):
- return
- else:
- raise
-
def send(self, data):
try:
result = self._socket.send(data)
return result
except socket.error as why:
- if why.args[0] == EWOULDBLOCK:
- return 0
- elif why.args[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED):
+ if why.args[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED):
self.close()
return 0
else:
@@ -142,7 +131,7 @@
'''Connect to master in TCP.'''
try:
- self.connect(self._master_address)
+ self._socket.connect(self._master_address)
return True
except socket.error as e:
self.log_msg('Failed to connect:(%s), %s' % (self._master_address,
@@ -162,12 +151,13 @@
msg.add_question(query_question)
return msg
-
def _send_data(self, data):
size = len(data)
total_count = 0
while total_count < size:
count = self.send(data[total_count:])
+ if count == 0:
+ raise XfrinException("send data failed!")
total_count += count
def _send_query(self, query_type):
More information about the bind10-changes
mailing list