Author: mladen.turk(a)jboss.com
Date: 2007-10-01 05:27:34 -0400 (Mon, 01 Oct 2007)
New Revision: 1069
Modified:
trunk/sight/native/os/windows/scm.c
trunk/sight/native/os/windows/service.c
Log:
Seal Windows service JNI calls
Modified: trunk/sight/native/os/windows/scm.c
===================================================================
--- trunk/sight/native/os/windows/scm.c 2007-10-01 08:54:47 UTC (rev 1068)
+++ trunk/sight/native/os/windows/scm.c 2007-10-01 09:27:34 UTC (rev 1069)
@@ -78,13 +78,15 @@
SIGHT_FREE_WSTRING(database);
return APR_EINVAL;
}
- if (no->native)
- CloseServiceHandle(no->native);
- no->native = OpenSCManagerW(NULL, J2C(database), mode);
- if (!no->native)
- rc = GetLastError();
- else
- no->clean = scm_cleanup;
+ SIGHT_LOCAL_TRY(no) {
+ if (no->native)
+ CloseServiceHandle(no->native);
+ no->native = OpenSCManagerW(NULL, J2C(database), mode);
+ if (!no->native)
+ rc = GetLastError();
+ else
+ no->clean = scm_cleanup;
+ } SIGHT_LOCAL_END(no);
SIGHT_FREE_WSTRING(database);
return APR_FROM_OS_ERROR(rc);
}
@@ -98,9 +100,11 @@
if (no && no->native) {
- CloseServiceHandle(no->native);
- no->native = NULL;
- no->clean = NULL;
+ SIGHT_LOCAL_TRY(no) {
+ CloseServiceHandle(no->native);
+ no->native = NULL;
+ no->clean = NULL;
+ } SIGHT_LOCAL_END(no);
}
}
@@ -123,78 +127,82 @@
void *lpBuffer = NULL;
svc_enum_t *head = NULL;
svc_enum_t *list = NULL;
+
if (!no || !no->pool || !no->native) {
return NULL;
}
if (drivers)
- dwServiceType = SERVICE_DRIVER;
+ dwServiceType = SERVICE_DRIVER;
else
- dwServiceType = SERVICE_WIN32;
+ dwServiceType = SERVICE_WIN32;
if (what == 1)
- dwServiceState = SERVICE_ACTIVE;
+ dwServiceState = SERVICE_ACTIVE;
else if (what == 2)
- dwServiceState = SERVICE_INACTIVE;
+ dwServiceState = SERVICE_INACTIVE;
+ SIGHT_LOCAL_TRY(no) {
+ do {
+ rt = EnumServicesStatusExA(no->native,
+ SC_ENUM_PROCESS_INFO,
+ dwServiceType,
+ dwServiceState,
+ (LPBYTE)lpBuffer,
+ dwSize,
+ &dwSize,
+ &dwNumServices,
+ &dwResumeHandle,
+ NULL);
+ if (!rt && ((rc = GetLastError()) != ERROR_MORE_DATA)) {
+ throwAprException(_E, APR_FROM_OS_ERROR(rc));
+ ea = NULL;
+ SIGHT_LOCAL_BRK(no);
+ goto cleanup;
+ }
+ if (dwNumServices > 0) {
- do {
- rt = EnumServicesStatusExA(no->native,
- SC_ENUM_PROCESS_INFO,
- dwServiceType,
- dwServiceState,
- (LPBYTE)lpBuffer,
- dwSize,
- &dwSize,
- &dwNumServices,
- &dwResumeHandle,
- NULL);
- if (!rt && ((rc = GetLastError()) != ERROR_MORE_DATA)) {
- throwAprException(_E, APR_FROM_OS_ERROR(rc));
+
+ }
+ if (!rt) {
+ if (!(list = (svc_enum_t *)sight_malloc(_E,
+ dwSize + sizeof(svc_enum_t),
+ THROW_FMARK))) {
+ ea = NULL;
+ SIGHT_LOCAL_BRK(no);
+ goto cleanup;
+ }
+ list->next = head;
+ lpBuffer = &list->data[0];
+ /* TODO: Make list ordered as its populated */
+ head = list;
+ }
+ list->size = dwNumServices;
+ cnt += list->size;
+ } while (!rt);
+
+ ea = sight_new_cc_array(_E, SIGHT_CC_STRING, cnt);
+ if (!ea || (*_E)->ExceptionCheck(_E)) {
ea = NULL;
+ SIGHT_LOCAL_BRK(no);
goto cleanup;
}
- if (dwNumServices > 0) {
-
-
- }
- if (!rt) {
- if (!(list = (svc_enum_t *)sight_malloc(_E,
- dwSize + sizeof(svc_enum_t),
- THROW_FMARK))) {
- ea = NULL;
- goto cleanup;
+ while (head) {
+ DWORD i;
+ lpService = (LPENUM_SERVICE_STATUS_PROCESSA)&head->data[0];
+ for (i = 0; i < head->size; i++) {
+ jstring s = (*_E)->NewStringUTF(_E, lpService[i].lpServiceName);
+ if (s)
+ (*_E)->SetObjectArrayElement(_E, ea, idx++, s);
+ else
+ break;
+ if ((*_E)->ExceptionCheck(_E)) {
+ ea = NULL;
+ break;
+ }
+ (*_E)->DeleteLocalRef(_E, s);
}
- list->next = head;
- lpBuffer = &list->data[0];
- /* TODO: Make list ordered as its populated */
- head = list;
+ head = head->next;
}
- list->size = dwNumServices;
- cnt += list->size;
- } while (!rt);
-
- ea = sight_new_cc_array(_E, SIGHT_CC_STRING, cnt);
- if (!ea || (*_E)->ExceptionCheck(_E)) {
- ea = NULL;
- goto cleanup;
- }
- while (head) {
- DWORD i;
- lpService = (LPENUM_SERVICE_STATUS_PROCESSA)&head->data[0];
- for (i = 0; i < head->size; i++) {
- jstring s = (*_E)->NewStringUTF(_E, lpService[i].lpServiceName);
- if (s)
- (*_E)->SetObjectArrayElement(_E, ea, idx++, s);
- else
- break;
- if ((*_E)->ExceptionCheck(_E)) {
- ea = NULL;
- break;
- }
- (*_E)->DeleteLocalRef(_E, s);
- }
- head = head->next;
- }
-
+ } SIGHT_LOCAL_END(no);
cleanup:
free_enum_list(head);
return ea;
Modified: trunk/sight/native/os/windows/service.c
===================================================================
--- trunk/sight/native/os/windows/service.c 2007-10-01 08:54:47 UTC (rev 1068)
+++ trunk/sight/native/os/windows/service.c 2007-10-01 09:27:34 UTC (rev 1069)
@@ -173,85 +173,95 @@
SIGHT_FREE_CSTRING(name);
return APR_EINVAL;
}
- hscm = ns->native;
- if (no->native) {
- CloseServiceHandle(no->native);
- no->native = NULL;
- }
- hsvc = OpenServiceA(hscm, J2S(name), (DWORD)access);
- if (IS_INVALID_HANDLE(hsvc)) {
- rc = GetLastError();
- goto cleanup;
- }
+ SIGHT_LOCAL_TRY(no) {
+ hscm = ns->native;
+ if (no->native) {
+ CloseServiceHandle(no->native);
+ no->native = NULL;
+ }
+ hsvc = OpenServiceA(hscm, J2S(name), (DWORD)access);
+ if (IS_INVALID_HANDLE(hsvc)) {
+ rc = GetLastError();
+ SIGHT_LOCAL_BRK(no);
+ goto cleanup;
+ }
- if (!QueryServiceConfigW(hsvc, NULL,
- 0, &cbBytesNeeded)) {
- rc = GetLastError();
- if (rc == ERROR_INSUFFICIENT_BUFFER) {
+ if (!QueryServiceConfigW(hsvc, NULL,
+ 0, &cbBytesNeeded)) {
+ rc = GetLastError();
+ if (rc == ERROR_INSUFFICIENT_BUFFER) {
+ cbBufSize = cbBytesNeeded;
+ lpServiceConfig = (LPQUERY_SERVICE_CONFIGW)malloc(cbBufSize);
+ if (!lpServiceConfig) {
+ rc = ERROR_OUTOFMEMORY;
+ throwAprMemoryException(_E, THROW_FMARK,
+ apr_get_os_error());
+ SIGHT_LOCAL_BRK(no);
+ goto cleanup;
+ }
+ if (!QueryServiceConfigW(hsvc, lpServiceConfig,
+ cbBufSize, &cbBytesNeeded)) {
+ rc = GetLastError();
+ SIGHT_LOCAL_BRK(no);
+ goto cleanup;
+ }
+ }
+ else {
+ SIGHT_LOCAL_BRK(no);
+ goto cleanup;
+ }
+ }
+ SET_IFIELD_W(0001, thiz, lpServiceConfig->lpBinaryPathName);
+ SET_IFIELD_O(0002, thiz, sight_mw_to_sa(_E,
lpServiceConfig->lpDependencies));
+ SET_IFIELD_W(0003, thiz, lpServiceConfig->lpServiceStartName);
+ SET_IFIELD_W(0004, thiz, lpServiceConfig->lpDisplayName);
+ SET_IFIELD_W(0006, thiz, lpServiceConfig->lpLoadOrderGroup);
+
+ if (!QueryServiceConfig2W(hsvc, SERVICE_CONFIG_DESCRIPTION,
+ NULL, 0, &cbBytesNeeded)) {
+ BYTE *lpBuffer;
+ if (rc != ERROR_INSUFFICIENT_BUFFER) {
+ SIGHT_LOCAL_BRK(no);
+ goto cleanup;
+ }
cbBufSize = cbBytesNeeded;
- lpServiceConfig = (LPQUERY_SERVICE_CONFIGW)malloc(cbBufSize);
+ lpBuffer = (BYTE *)malloc(cbBufSize);
if (!lpServiceConfig) {
rc = ERROR_OUTOFMEMORY;
throwAprMemoryException(_E, THROW_FMARK,
apr_get_os_error());
+ SIGHT_LOCAL_BRK(no);
goto cleanup;
}
- if (!QueryServiceConfigW(hsvc, lpServiceConfig,
- cbBufSize, &cbBytesNeeded)) {
+ if (!QueryServiceConfig2W(hsvc, SERVICE_CONFIG_DESCRIPTION,
+ lpBuffer, cbBufSize, &cbBytesNeeded)) {
rc = GetLastError();
+ free(lpBuffer);
+ SIGHT_LOCAL_BRK(no);
goto cleanup;
}
+ else {
+ LPSERVICE_DESCRIPTIONW lpDesc = (LPSERVICE_DESCRIPTIONW)lpBuffer;
+ SET_IFIELD_W(0005, thiz, lpDesc->lpDescription);
+ }
+ free(lpBuffer);
}
- else {
- goto cleanup;
- }
- }
- SET_IFIELD_W(0001, thiz, lpServiceConfig->lpBinaryPathName);
- SET_IFIELD_O(0002, thiz, sight_mw_to_sa(_E, lpServiceConfig->lpDependencies));
- SET_IFIELD_W(0003, thiz, lpServiceConfig->lpServiceStartName);
- SET_IFIELD_W(0004, thiz, lpServiceConfig->lpDisplayName);
- SET_IFIELD_W(0006, thiz, lpServiceConfig->lpLoadOrderGroup);
-
- if (!QueryServiceConfig2W(hsvc, SERVICE_CONFIG_DESCRIPTION,
- NULL, 0, &cbBytesNeeded)) {
- BYTE *lpBuffer;
- if (rc != ERROR_INSUFFICIENT_BUFFER) {
- goto cleanup;
- }
- cbBufSize = cbBytesNeeded;
- lpBuffer = (BYTE *)malloc(cbBufSize);
- if (!lpServiceConfig) {
- rc = ERROR_OUTOFMEMORY;
- throwAprMemoryException(_E, THROW_FMARK,
- apr_get_os_error());
- goto cleanup;
- }
- if (!QueryServiceConfig2W(hsvc, SERVICE_CONFIG_DESCRIPTION,
- lpBuffer, cbBufSize, &cbBytesNeeded)) {
+ if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
+ buf, sizeof(buf), &cbBytesNeeded)) {
rc = GetLastError();
- free(lpBuffer);
- goto cleanup;
}
else {
- LPSERVICE_DESCRIPTIONW lpDesc = (LPSERVICE_DESCRIPTIONW)lpBuffer;
- SET_IFIELD_W(0005, thiz, lpDesc->lpDescription);
+ lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
+ SET_IFIELD_I(0007, thiz, lpStatus->dwWin32ExitCode);
+ SET_IFIELD_I(0008, thiz, lpStatus->dwServiceSpecificExitCode);
+ SET_IFIELD_I(0009, thiz, lpStatus->dwProcessId);
+ CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
+
+ no->native = hsvc;
+ no->clean = svc_cleanup;
+ rc = ERROR_SUCCESS;
}
- free(lpBuffer);
- }
- if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
- buf, sizeof(buf), &cbBytesNeeded)) {
- rc = GetLastError();
- goto cleanup;
- }
- lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
- SET_IFIELD_I(0007, thiz, lpStatus->dwWin32ExitCode);
- SET_IFIELD_I(0008, thiz, lpStatus->dwServiceSpecificExitCode);
- SET_IFIELD_I(0009, thiz, lpStatus->dwProcessId);
- CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
-
- no->native = hsvc;
- no->clean = svc_cleanup;
- rc = ERROR_SUCCESS;
+ } SIGHT_LOCAL_END(no);
cleanup:
if (lpServiceConfig)
free(lpServiceConfig);
@@ -268,40 +278,43 @@
DWORD rc = ERROR_SUCCESS;
SERVICE_STATUS stStatus;
DWORD sc = cmd;
+
UNREFERENCED_O;
if (!no || !no->native || cmd < 0) {
return APR_EINVAL;
}
- hsvc = no->native;
+ SIGHT_LOCAL_TRY(no) {
+ hsvc = no->native;
- switch (cmd) {
- case 1:
- sc = SERVICE_CONTROL_STOP;
- break;
- case 2:
- sc = SERVICE_CONTROL_PAUSE;
- break;
- case 3:
- sc = SERVICE_CONTROL_CONTINUE;
- break;
- case 4:
- sc = SERVICE_CONTROL_INTERROGATE;
- break;
- case 5:
- return APR_EINVAL;
- break;
- case 6:
- sc = SERVICE_CONTROL_PARAMCHANGE;
- break;
- }
- if (cmd == 0) {
- if (!StartService(hsvc, 0, NULL))
- rc = GetLastError();
- }
- else {
- if (!ControlService(hsvc, sc, &stStatus))
- rc = GetLastError();
- }
+ switch (cmd) {
+ case 1:
+ sc = SERVICE_CONTROL_STOP;
+ break;
+ case 2:
+ sc = SERVICE_CONTROL_PAUSE;
+ break;
+ case 3:
+ sc = SERVICE_CONTROL_CONTINUE;
+ break;
+ case 4:
+ sc = SERVICE_CONTROL_INTERROGATE;
+ break;
+ case 5:
+ return APR_EINVAL;
+ break;
+ case 6:
+ sc = SERVICE_CONTROL_PARAMCHANGE;
+ break;
+ }
+ if (cmd == 0) {
+ if (!StartService(hsvc, 0, NULL))
+ rc = GetLastError();
+ }
+ else {
+ if (!ControlService(hsvc, sc, &stStatus))
+ rc = GetLastError();
+ }
+ } SIGHT_LOCAL_END(no);
return APR_FROM_OS_ERROR(rc);
}
@@ -320,20 +333,21 @@
if (!no || !no->native) {
return APR_EINVAL;
}
- hsvc = no->native;
+ SIGHT_LOCAL_TRY(no) {
+ hsvc = no->native;
- if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
- buf, sizeof(buf), &cbBytesNeeded)) {
- rc = GetLastError();
- goto cleanup;
- }
- lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
- SET_IFIELD_I(0007, thiz, lpStatus->dwWin32ExitCode);
- SET_IFIELD_I(0008, thiz, lpStatus->dwServiceSpecificExitCode);
- SET_IFIELD_I(0009, thiz, lpStatus->dwProcessId);
- CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
-
-cleanup:
+ if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
+ buf, sizeof(buf), &cbBytesNeeded)) {
+ rc = GetLastError();
+ }
+ else {
+ lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
+ SET_IFIELD_I(0007, thiz, lpStatus->dwWin32ExitCode);
+ SET_IFIELD_I(0008, thiz, lpStatus->dwServiceSpecificExitCode);
+ SET_IFIELD_I(0009, thiz, lpStatus->dwProcessId);
+ CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
+ }
+ } SIGHT_LOCAL_END(no);
return APR_FROM_OS_ERROR(rc);
}
@@ -355,47 +369,50 @@
if (!no || !no->native) {
return APR_EINVAL;
}
- hsvc = no->native;
- if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
- buf, sizeof(buf), &cbBytesNeeded)) {
- rc = GetLastError();
- goto cleanup;
- }
- lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
- if (lpStatus->dwCurrentState == (DWORD)state)
- goto setup;
- if (timeout > 0) {
- timeout_value = timeout * 1000L;
- timeout_interval = timeout_value / 64;
- }
- else {
- /* Defaults to 100 ms */
- timeout_interval = 100000L;
- }
- do {
- apr_sleep(timeout_interval);
+ SIGHT_LOCAL_TRY(no) {
+ hsvc = no->native;
if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
buf, sizeof(buf), &cbBytesNeeded)) {
rc = GetLastError();
+ SIGHT_LOCAL_BRK(no);
goto cleanup;
}
lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
+ if (lpStatus->dwCurrentState == (DWORD)state)
+ goto setup;
if (timeout > 0) {
- if (timeout_interval >= timeout_value) {
- rc = APR_TO_OS_ERROR(APR_TIMEUP);
- break;
+ timeout_value = timeout * 1000L;
+ timeout_interval = timeout_value / 64;
+ }
+ else {
+ /* Defaults to 100 ms */
+ timeout_interval = 100000L;
+ }
+ do {
+ apr_sleep(timeout_interval);
+ if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
+ buf, sizeof(buf), &cbBytesNeeded)) {
+ rc = GetLastError();
+ SIGHT_LOCAL_BRK(no);
+ goto cleanup;
}
- timeout_interval *= 2;
- }
+ lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
+ if (timeout > 0) {
+ if (timeout_interval >= timeout_value) {
+ rc = APR_TO_OS_ERROR(APR_TIMEUP);
+ break;
+ }
+ timeout_interval *= 2;
+ }
- } while (lpStatus->dwCurrentState != (DWORD)state);
+ } while (lpStatus->dwCurrentState != (DWORD)state);
setup:
- lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
- SET_IFIELD_I(0007, thiz, lpStatus->dwWin32ExitCode);
- SET_IFIELD_I(0008, thiz, lpStatus->dwServiceSpecificExitCode);
- SET_IFIELD_I(0009, thiz, lpStatus->dwProcessId);
- CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
-
+ lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
+ SET_IFIELD_I(0007, thiz, lpStatus->dwWin32ExitCode);
+ SET_IFIELD_I(0008, thiz, lpStatus->dwServiceSpecificExitCode);
+ SET_IFIELD_I(0009, thiz, lpStatus->dwProcessId);
+ CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
+ } SIGHT_LOCAL_END(no);
cleanup:
return APR_FROM_OS_ERROR(rc);
}
@@ -423,73 +440,79 @@
if (!no || !no->native || !progress) {
return APR_EINVAL;
}
- hsvc = no->native;
+ SIGHT_LOCAL_TRY(no) {
+ hsvc = no->native;
- if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
- buf, sizeof(buf), &cbBytesNeeded)) {
- rc = GetLastError();
- goto cleanup;
- }
- lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
- if (lpStatus->dwCurrentState == (DWORD)state)
- goto setup;
- c = (*_E)->GetObjectClass(_E, progress);
- cb.name = "progress";
- cb.msig = "(I)I";
- cb.object = progress;
- cb.method = (*_E)->GetMethodID(_E, c, cb.name, cb.msig);
- if (!cb.method || (*_E)->ExceptionCheck(_E)) {
- rc = EINVAL;
- goto cleanup;
- }
- cres = (*_E)->CallIntMethod(_E, cb.object, cb.method, tick, NULL);
- if ((*_E)->ExceptionCheck(_E)) {
- rc = EINTR;
- goto cleanup;
- }
- if (timeout > 0) {
- timeout_value = timeout * 1000L;
- timeout_interval = timeout_value / 100;
- }
- else {
- /* Defaults to 100 ms */
- timeout_interval = 100000L;
- }
- do {
- if (cres < 0) {
- /* Broken by the callback */
- break;
- }
- else if (cres > 0) {
- timeout_interval = cres * 1000L;
- }
- apr_sleep(timeout_interval);
if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
buf, sizeof(buf), &cbBytesNeeded)) {
rc = GetLastError();
+ SIGHT_LOCAL_BRK(no);
goto cleanup;
}
lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
- if (timeout > 0) {
- if (timeout_interval >= timeout_value) {
- rc = APR_TO_OS_ERROR(APR_TIMEUP);
- break;
- }
- timeout_value -= timeout_interval;
+ if (lpStatus->dwCurrentState == (DWORD)state)
+ goto setup;
+ c = (*_E)->GetObjectClass(_E, progress);
+ cb.name = "progress";
+ cb.msig = "(I)I";
+ cb.object = progress;
+ cb.method = (*_E)->GetMethodID(_E, c, cb.name, cb.msig);
+ if (!cb.method || (*_E)->ExceptionCheck(_E)) {
+ rc = EINVAL;
+ SIGHT_LOCAL_BRK(no);
+ goto cleanup;
}
- cres = (*_E)->CallIntMethod(_E, cb.object, cb.method, tick++, NULL);
+ cres = (*_E)->CallIntMethod(_E, cb.object, cb.method, tick, NULL);
if ((*_E)->ExceptionCheck(_E)) {
rc = EINTR;
+ SIGHT_LOCAL_BRK(no);
goto cleanup;
}
- } while (lpStatus->dwCurrentState != (DWORD)state);
-setup:
- lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
- SET_IFIELD_I(0007, thiz, lpStatus->dwWin32ExitCode);
- SET_IFIELD_I(0008, thiz, lpStatus->dwServiceSpecificExitCode);
- SET_IFIELD_I(0009, thiz, lpStatus->dwProcessId);
- CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
-
+ if (timeout > 0) {
+ timeout_value = timeout * 1000L;
+ timeout_interval = timeout_value / 100;
+ }
+ else {
+ /* Defaults to 100 ms */
+ timeout_interval = 100000L;
+ }
+ do {
+ if (cres < 0) {
+ /* Broken by the callback */
+ break;
+ }
+ else if (cres > 0) {
+ timeout_interval = cres * 1000L;
+ }
+ apr_sleep(timeout_interval);
+ if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
+ buf, sizeof(buf), &cbBytesNeeded)) {
+ rc = GetLastError();
+ SIGHT_LOCAL_BRK(no);
+ goto cleanup;
+ }
+ lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
+ if (timeout > 0) {
+ if (timeout_interval >= timeout_value) {
+ rc = APR_TO_OS_ERROR(APR_TIMEUP);
+ break;
+ }
+ timeout_value -= timeout_interval;
+ }
+ cres = (*_E)->CallIntMethod(_E, cb.object, cb.method, tick++, NULL);
+ if ((*_E)->ExceptionCheck(_E)) {
+ rc = EINTR;
+ SIGHT_LOCAL_BRK(no);
+ goto cleanup;
+ }
+ } while (lpStatus->dwCurrentState != (DWORD)state);
+ setup:
+ lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
+ SET_IFIELD_I(0007, thiz, lpStatus->dwWin32ExitCode);
+ SET_IFIELD_I(0008, thiz, lpStatus->dwServiceSpecificExitCode);
+ SET_IFIELD_I(0009, thiz, lpStatus->dwProcessId);
+ CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
+ } SIGHT_LOCAL_END(no);
cleanup:
return APR_FROM_OS_ERROR(rc);
}