Author: markt
Date: Mon Nov 28 17:21:40 2016
New Revision: 1771775

URL: http://svn.apache.org/viewvc?rev=1771775&view=rev
Log:
Fix DAEMON-282
Suppress spurious "The data area passed to a system call is too small" error 
message in the log when procrun fails to stop the service.

Modified:
    commons/proper/daemon/trunk/src/changes/changes.xml
    commons/proper/daemon/trunk/src/native/windows/src/service.c

Modified: commons/proper/daemon/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/changes/changes.xml?rev=1771775&r1=1771774&r2=1771775&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/changes/changes.xml (original)
+++ commons/proper/daemon/trunk/src/changes/changes.xml Mon Nov 28 17:21:40 2016
@@ -67,6 +67,11 @@
       <action issue="DAEMON-358" type="fix" dev="markt" due-to="Gustavo 
Romero">
         Update apsupport.m4 add support for 64-bit PowerPC architectures.
       </action>
+      <action issue="DAEMON-282" type="fix" dev="markt">
+        Suppress spurious &quot;The data area passed to a system call is too
+        small&quot; error message in the log when procrun fails to stop the
+        service.
+      </action>
     </release>
   </body>
 </document>

Modified: commons/proper/daemon/trunk/src/native/windows/src/service.c
URL: 
http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/src/service.c?rev=1771775&r1=1771774&r2=1771775&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/src/service.c (original)
+++ commons/proper/daemon/trunk/src/native/windows/src/service.c Mon Nov 28 
17:21:40 2016
@@ -147,8 +147,15 @@ apxServiceOpen(APXHANDLE hService, LPCWS
         lpService->stServiceEntry.szObjectName[0] = L'\0';
     }
     if (!QueryServiceConfigW(lpService->hService, NULL, 0, &dwNeeded)) {
-        if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+        if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+               // This is expected. The call is expected to fail with the 
required
+               // buffer size set in dwNeeded.
+               // Clear the last error to prevent it being logged if a genuine
+               // error occurs
+               SetLastError(ERROR_SUCCESS);
+        } else {
             apxLogWrite(APXLOG_MARK_SYSERR);
+        }
     }
     /* TODO: Check GetLastError  ERROR_INSUFFICIENT_BUFFER */
     lpService->stServiceEntry.lpConfig =  
(LPQUERY_SERVICE_CONFIGW)apxPoolAlloc(hService->hPool,


Reply via email to