Opened 15 years ago

Last modified 12 years ago

#279 enhancement new

inetd UDP support broken

Reported by: itamarst Owned by:
Priority: normal Milestone:
Component: runner Keywords:
Cc: spiv, itamarst, Moshe Zadka Branch:


Change History (13)

comment:1 Changed 15 years ago by itamarst

inetd and procmon modules have main() function which is old
app and kinda icky as well.

comment:2 Changed 15 years ago by itamarst

Also it has no tests! I am upgrading this to a bug.

comment:3 Changed 15 years ago by spiv

I'll take this.

comment:4 Changed 15 years ago by Moshe Zadka

Procmon should be updated enough now. It's all up to inetd now.

comment:5 Changed 15 years ago by Moshe Zadka

this should be upgraded to urgent, at least as far as inetdtap is concerned

comment:6 Changed 15 years ago by Moshe Zadka

upgrading to urgent, as per radix's request

comment:7 Changed 15 years ago by Moshe Zadka

Here's a patch porting the tap module to new application

Index: twisted/runner/
RCS file: /cvs/Twisted/twisted/runner/,v
retrieving revision 1.1
diff -u -r1.1
--- twisted/runner/  5 Dec 2002 07:59:31 -0000       1.1
+++ twisted/runner/  7 Oct 2003 18:11:08 -0000
@@ -21,14 +21,14 @@

 Maintainer: U{Andrew Bennetts<>}

-Future Plans: Bugfixes (don't call reactor.listenTCP or forkPassingFD when
-creating a TAP!), more configurability.
+Future Plans: more configurability.

 import pwd, grp
 from twisted.runner import inetd, inetdconf
 from twisted.python import log, usage
 from twisted.internet.protocol import ServerFactory
+from twisted.application import internet, service

 class Options(usage.Options):
@@ -41,7 +41,27 @@
     optFlags = [['nointernal', 'i', "Don't run internal services"]]

-def updateApplication(app, config):
+class RPCServer(internet.TCPServer):
+    def __init__(self, rpcVersions, rpcConf, proto, service):
+        internet.TCPServer.__init__(0, ServerFactory())
+        self.rpcConf = rpcConf
+        self.proto = proto
+        self.service = service
+    def startService(self):
+        internet.TCPServer.startService(self)
+        import portmap
+        portNo = self._port.getHost()[2]
+        service = self.service
+        for version in rpcVersions:
+            portmap.set([name], version, self.proto,
+                        portNo)
+            inetd.forkPassingFD(service.program, service.programArgs,
+                                os.environ, service.user,, p)
+def makeService(config):
+    s = service.MultiService()

     conf = inetdconf.InetdConf()
@@ -129,20 +149,16 @@
             factory = ServerFactory()
             factory.protocol = inetd.internalProtocols[]
         elif rpc:
-            proto = protocolDict[protocol]
-            p = reactor.listenTCP(0, ServerFactory())
-            portNo = p.getHost()[2]
-            for version in rpcVersions:
-                portmap.set([name], version, proto, portNo)
-            forkPassingFD(service.program, service.programArgs, os.environ,
-                          service.user,, p)
+            i = RPCServer(rpcVersions, rpcConf, proto, service)
+            i.setServiceParent(s)
             # Non-internal non-rpc services use InetdFactory
             factory = inetd.InetdFactory(service)

         if protocol == 'tcp':
-            app.listenTCP(service.port, factory)
+            klass = internet.TCPServer
         elif protocol == 'udp':
-            app.listenUDP(service.port, factory)
+            klass = internet.UDPServer
+        klass(service.port, factory).setServiceParent(s)
+        return s

comment:8 Changed 15 years ago by itamarst

UDP ports accept a DatagramProtocol, not a factory.

comment:9 Changed 15 years ago by Moshe Zadka

In general, I suspect the runner.inetd approach to UDP is correct.
I merely converted blindly from the previous version :)

comment:10 Changed 15 years ago by Moshe Zadka

That's "incorrect", sorry.

comment:11 Changed 15 years ago by Moshe Zadka

/cvs/Twisted/twisted/runner/,v  <--
new revision: 1.2; previous revision: 1.1
Fixed new application problem.
Renaming to "inetd UDP support broken" and downgrading to "feature"
(since it works in the common cases where there are no UDP non-RPC

UDP support is non-trivial -- you need to start an application, but sometimes
let it remain up for a while before it dies, etc. etc. Read the docs :)

comment:12 Changed 12 years ago by spiv

Component: runner

comment:13 Changed 7 years ago by <automation>

Owner: spiv deleted
Note: See TracTickets for help on using tickets.