[pywin32-checkins] /hgroot/pywin32/pywin32: Make sure any return codes from python ...
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2012-08-28 02:53:55
|
changeset e2e6637fbaa1 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=e2e6637fbaa1 summary: Make sure any return codes from python handler functions are passed back to service framework diffstat: win32/Lib/win32serviceutil.py | 16 ++++++++-------- win32/src/PythonService.cpp | 12 +++++++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diffs (62 lines): diff -r b152e0e96498 -r e2e6637fbaa1 win32/Lib/win32serviceutil.py --- a/win32/Lib/win32serviceutil.py Sat Aug 25 00:53:24 2012 -0400 +++ b/win32/Lib/win32serviceutil.py Sat Aug 25 14:59:12 2012 -0400 @@ -808,27 +808,27 @@ pass def ServiceCtrlHandler(self, control): - self.ServiceCtrlHandlerEx(control, 0, None) + return self.ServiceCtrlHandlerEx(control, 0, None) # The 'Ex' functions, which take additional params def SvcOtherEx(self, control, event_type, data): # The default here is to call self.SvcOther as that is the old behaviour. # If you want to take advantage of the extra data, override this method - self.SvcOther(control) + return self.SvcOther(control) def ServiceCtrlHandlerEx(self, control, event_type, data): if control==win32service.SERVICE_CONTROL_STOP: - self.SvcStop() + return self.SvcStop() elif control==win32service.SERVICE_CONTROL_PAUSE: - self.SvcPause() + return self.SvcPause() elif control==win32service.SERVICE_CONTROL_CONTINUE: - self.SvcContinue() + return self.SvcContinue() elif control==win32service.SERVICE_CONTROL_INTERROGATE: - self.SvcInterrogate() + return self.SvcInterrogate() elif control==win32service.SERVICE_CONTROL_SHUTDOWN: - self.SvcShutdown() + return self.SvcShutdown() else: - self.SvcOtherEx(control, event_type, data) + return self.SvcOtherEx(control, event_type, data) def SvcRun(self): self.ReportServiceStatus(win32service.SERVICE_RUNNING) diff -r b152e0e96498 -r e2e6637fbaa1 win32/src/PythonService.cpp --- a/win32/src/PythonService.cpp Sat Aug 25 00:53:24 2012 -0400 +++ b/win32/src/PythonService.cpp Sat Aug 25 14:59:12 2012 -0400 @@ -988,10 +988,16 @@ if (result==NULL) { ReportPythonError(PYS_E_SERVICE_CONTROL_FAILED); dwResult = ERROR_CALL_NOT_IMPLEMENTED; // correct code? - } else if (PyInt_Check(result)||PyLong_Check(result)) - dwResult = PyInt_AsLong(result); - else + } + else if (result == Py_None) dwResult = NOERROR; + else{ + dwResult = PyInt_AsUnsignedLongMask(result); + if (dwResult == -1 && PyErr_Occurred()){ + ReportPythonError(PYS_E_SERVICE_CONTROL_FAILED); + dwResult = ERROR_SERVICE_SPECIFIC_ERROR; + } + } Py_XDECREF(result); return dwResult; |