Opened 13 years ago

Closed 13 years ago

#1695 enhancement closed fixed (fixed)

raising an exception from datagramReceived should not kill a listening UDP Port

Reported by: radix Owned by:
Priority: highest Milestone:
Component: core Keywords:
Cc: radix, itamarst, Glyph, PenguinOfDoom, ghazel, Jean-Paul Calderone, teratorn Branch:
Author:

Description

the fact that readPrecisely is buggy (or whatever) shouldn't mean that the Port should be closed.

2006/04/30 19:10 CDT [twisted.names.dns.DNSDatagramProtocol (UDP)] Traceback (most recent call last):
          File "/home/t-names/Twisted/twisted/python/log.py", line 53, in callWithLogger
            return callWithContext({"system": lp}, func, *args, **kw)
          File "/home/t-names/Twisted/twisted/python/log.py", line 38, in callWithContext
            return context.call({ILogContext: newCtx}, func, *args, **kw)
          File "/home/t-names/Twisted/twisted/python/context.py", line 59, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File "/home/t-names/Twisted/twisted/python/context.py", line 37, in callWithContext
            return func(*args,**kw)
        --- <exception caught here> ---
          File "/home/t-names/Twisted/twisted/internet/selectreactor.py", line 139, in _doReadOrWrite
            why = getattr(selectable, method)()
          File "/home/t-names/Twisted/twisted/internet/udp.py", line 126, in doRead
            self.protocol.datagramReceived(data, addr)
          File "/home/t-names/Twisted/twisted/names/dns.py", line 1088, in datagramReceived
            m.fromStr(data)
          File "/home/t-names/Twisted/twisted/names/dns.py", line 1047, in fromStr
            self.decode(strio)
          File "/home/t-names/Twisted/twisted/names/dns.py", line 992, in decode
            header = readPrecisely(strio, self.headerSize)
          File "/home/t-names/Twisted/twisted/names/dns.py", line 153, in readPrecisely
            raise EOFError
        exceptions.EOFError:
 
2006/04/30 19:10 CDT [twisted.names.dns.DNSDatagramProtocol (UDP)] (Port 53 Closed)
2006/04/30 19:10 CDT [twisted.names.dns.DNSDatagramProtocol (UDP)] Stopping protocol <twisted.names.dns.DNSDatagramProtocol instance at 0xb798580c>

Change History (8)

comment:1 Changed 13 years ago by Glyph

I disagree.

Fix readPrecisely, or fix this specifically in twisted.names; the behavior of uncaught exceptions when they propogate all the way to the reactor is to disable the event source in question.

comment:2 Changed 13 years ago by Jean-Paul Calderone

Keywords: review added
Priority: normalhighest

Offline discussion lead to a solution which involved changes to the error handling behavior of udp.Port.

Please review in udp-app-error-1695

comment:3 Changed 13 years ago by Jean-Paul Calderone

Cc: radix itamarst Glyph PenguinOfDoom ghazel Jean-Paul Calderone teratorn added
Keywords: review removed
Owner: changed from Glyph to PenguinOfDoom

Actually, this still fails on iocp.

comment:4 Changed 13 years ago by radix

Keywords: review added
Owner: changed from PenguinOfDoom to radix
Status: newassigned

comment:5 Changed 13 years ago by radix

Keywords: review removed
Owner: changed from radix to Jean-Paul Calderone
Status: assignednew

Looks good. I notice that you apparently support the exception-handling even for connected cases in IOCP but not in the basic posix UDP support. That's not a big deal, since it's an advertised feature of connected UDP, so go ahead and merge (unless you want to also support it for connected UDP, in which case you should write a test and fix it).

+1

comment:6 Changed 13 years ago by radix

Sorry, I misread that IOCP code. It's not the connected-UDP case, it's a deprecated case. I suggest *not* catching the error from the deprecated case.

comment:7 Changed 13 years ago by Jean-Paul Calderone

Resolution: fixed
Status: newclosed

(In [16891]) Merge udp-app-error-1695

Author: exarkun Reviewer: radix Fixes #1695

This adds try/except handling around calls to datagramReceived. Exceptions are handled by logging them. The port which generated them is no longer disconnected.

comment:8 Changed 9 years ago by <automation>

Owner: Jean-Paul Calderone deleted
Note: See TracTickets for help on using tickets.