jfclere commented on code in PR #238:
URL: https://github.com/apache/commons-daemon/pull/238#discussion_r2086433148
##########
src/native/windows/apps/prunsrv/prunsrv.c:
##########
@@ -951,15 +970,34 @@ static BOOL docmdStopService(LPAPXCMDLINE lpCmdline)
NULL);
if (!rv) {
/* Wait for the timeout if any */
- int timeout = SO_STOPTIMEOUT;
- if (timeout) {
- int i;
- for (i = 0; i < timeout; i++) {
- rv = apxServiceCheckStop(hService);
- apxLogWrite(APXLOG_MARK_DEBUG "apxServiceCheck returns
%d.", rv);
- if (rv)
- break;
- }
+ int timeout = SO_STOPTIMEOUT;
+ int waited = waitedSinceStopCmd();
+ int i;
+ if (timeout <= 0) {
+ /* waiting for ever doesn't look OK here */
+ timeout = ONE_MINUTE_SEC;
+ }
+ apxLogWrite(APXLOG_MARK_DEBUG "docmdStopService Waited %d timeout
%d", waited, timeout*1000);
+ if (timeout*1000 > waited) {
+ /*
+ * it took waited to send the command, the service starts
+ * counting the timeout once it receives the STOP command
+ * that is probably after waited but that depends on the
+ * box we are using, we add 1 second just to be sure.
+ */
+ timeout = timeout*1000 + waited + 1000;
+ } else {
+ apxLogWrite(APXLOG_MARK_DEBUG "docmdStopService timeout %d too
small.", timeout*1000);
+ timeout = 1000; /* we might wait 1 s too much but we check if
we have already stopped */
+ }
+ apxLogWrite(APXLOG_MARK_DEBUG "docmdStopService estimated timeout
%d milliseconds.", timeout);
+ /* the SO_STOPTIMEOUT applies to the stop command and to the time
service needs to stop */
+ for (i = 0; i < timeout; i=i+1000) {
Review Comment:
According to my tests QueryServiceStatus() returns immediately even on a
slow VM.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]