Message139821
| Author |
François-Xavier.Bourlet |
| Recipients |
François-Xavier.Bourlet |
| Date |
2011年07月05日.01:55:29 |
| SpamBayes Score |
1.8211088e-06 |
| Marked as misclassified |
No |
| Message-id |
<1309830930.03.0.793190602228.issue12498@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Actually the class asyncore.dispatcher_with_send do not handle properly disconnection. When the endpoint shutdown his sending part of the socket, but keep the socket open in reading, the current implementation of dispatcher_with_send will close the socket without sending pending data.
Adding this method to the class fix the problem:
def handle_close(self):
if not self.writable():
dispatcher.close()
Note also that this class try to initiate a send even if the socket is maybe not ready for writing:
Here's a simple fix:
def send(self, data):
if self.debug:
self.log_info('sending %s' % repr(data))
self.out_buffer = self.out_buffer + data
- self.initiate_send()
Last but not last, the buffer size of each socket send are way to small (512, a third of an usual TCP frame). Here's the code with a bumped value:
def initiate_send(self):
num_sent = 0
- num_sent = dispatcher.send(self, self.out_buffer[:512])
+ num_sent = dispatcher.send(self, self.out_buffer[:8192])
self.out_buffer = self.out_buffer[num_sent:]
Thanks for reading, |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年07月05日 01:55:30 | François-Xavier.Bourlet | set | recipients:
+ François-Xavier.Bourlet |
| 2011年07月05日 01:55:30 | François-Xavier.Bourlet | set | messageid: <1309830930.03.0.793190602228.issue12498@psf.upfronthosting.co.za> |
| 2011年07月05日 01:55:29 | François-Xavier.Bourlet | link | issue12498 messages |
| 2011年07月05日 01:55:29 | François-Xavier.Bourlet | create |
|