Ticket #67: ticket_67.patch
-
cherrypy/_cpconfig.py
old new 36 36 cpg.configOption.socketQueueSize = 5 # Size of the socket queue 37 37 cpg.configOption.protocolVersion = "HTTP/1.0" 38 38 39 # Parameters used to tell what kind of server we want 40 # Note that numberOfProcesses, threading and forking conflict 41 # wich each other: if one has a non-null value, the other 42 # ones should be null (for numberOfProcesses, null means equal to one) 43 cpg.configOption.processPool = 0 # Used if we want to fork n processes 44 # at the beginning. In this case, all 45 # processes will listen on the same 46 # socket (this only works on unix) 47 cpg.configOption.threading = 0 # Used if we want to create a new 48 # thread for each request 49 cpg.configOption.forking = 0 # Used if we want to create a new process 50 # for each request 51 cpg.configOption.threadPool = 0 # Used if we want to create a pool 52 # of threads at the beginning 39 # Create a pool of threads 40 cpg.configOption.threadPool = 1 53 41 54 42 # Variables used to tell if this is an SSL server 55 43 cpg.configOption.sslKeyFile = "" … … 99 87 ('server', 'socketPort', 'int'), 100 88 ('server', 'socketFile', 'str'), 101 89 ('server', 'reverseDNS', 'int'), 102 ('server', 'processPool', 'int'),103 90 ('server', 'threadPool', 'int'), 104 ('server', 'threading', 'int'),105 ('server', 'forking', 'int'),106 91 ('server', 'sslKeyFile', 'str'), 107 92 ('server', 'sslCertificateFile', 'str'), 108 93 ('server', 'sslClientCertificateVerification', 'int'), … … 142 127 _cpLogMessage(" socketFile: %s" % cpg.configOption.socketFile, 'CONFIG') 143 128 _cpLogMessage(" reverseDNS: %s" % cpg.configOption.reverseDNS, 'CONFIG') 144 129 _cpLogMessage(" socketQueueSize: %s" % cpg.configOption.socketQueueSize, 'CONFIG') 145 _cpLogMessage(" processPool: %s" % cpg.configOption.processPool, 'CONFIG')146 130 _cpLogMessage(" threadPool: %s" % cpg.configOption.threadPool, 'CONFIG') 147 _cpLogMessage(" threading: %s" % cpg.configOption.threading, 'CONFIG')148 _cpLogMessage(" forking: %s" % cpg.configOption.forking, 'CONFIG')149 131 _cpLogMessage(" sslKeyFile: %s" % cpg.configOption.sslKeyFile, 'CONFIG') 150 132 if cpg.configOption.sslKeyFile: 151 133 _cpLogMessage(" sslCertificateFile: %s" % cpg.configOption.sslCertificateFile, 'CONFIG') … … 167 149 raise "CherryError: protocolVersion must be 'HTTP/1.1' or 'HTTP/1.0'" 168 150 if _reverseDNS not in (0,1): raise "CherryError: reverseDNS must be '0' or '1'" 169 151 if _socketFile and not hasattr(socket, 'AF_UNIX'): raise "CherryError: Configuration file has socketFile, but this is only available on Unix machines" 170 if _processPool!=1 and not hasattr(os, 'fork'): raise "CherryError: Configuration file has processPool, but forking is not available on this operating system"171 if _forking and not hasattr(os, 'fork'): raise "CherryError: Configuration file has forking, but forking is not available on this operating system"172 152 if _sslKeyFile: 173 153 try: 174 154 global SSL … … 176 156 except: raise "CherryError: PyOpenSSL 0.5.1 or later must be installed to use SSL. You can get it from http://pyopenssl.sourceforge.net" 177 157 if _socketPort and _socketFile: raise "CherryError: In configuration file: socketPort and socketFile conflict with each other" 178 158 if not _socketFile and not _socketPort: _socketPort=8000 # Default port 179 if _processPool==1: severalProcs=0180 else: severalProcs=1181 159 if _threadPool==1: severalThreads=0 182 160 else: severalThreads=1 183 if severalThreads+severalProcs+_threading+_forking>1: raise "CherryError: In configuration file: threadPool, processPool, threading and forking conflict with each other"184 161 if _sslKeyFile and not _sslCertificateFile: raise "CherryError: Configuration file has sslKeyFile but no sslCertificateFile" 185 162 if _sslCertificateFile and not _sslKeyFile: raise "CherryError: Configuration file has sslCertificateFile but no sslKeyFile" 186 163 try: sys.stdout.flush() … … 189 166 if _sessionStorageType not in ('', 'custom', 'ram', 'file', 'cookie'): raise "CherryError: Configuration file an invalid sessionStorageType: '%s'"%_sessionStorageType 190 167 if _sessionStorageType in ('custom', 'ram', 'cookie') and _sessionStorageFileDir!='': raise "CherryError: Configuration file has sessionStorageType set to 'custom, 'ram' or 'cookie' but a sessionStorageFileDir is specified" 191 168 if _sessionStorageType=='file' and _sessionStorageFileDir=='': raise "CherryError: Configuration file has sessionStorageType set to 'file' but no sessionStorageFileDir" 192 if _sessionStorageType=='ram' and (_forking or severalProcs):193 print "CherryWarning: 'ram' sessions might be buggy when using several processes"194 169

