Author: mladen.turk(a)jboss.com
Date: 2007-10-12 05:27:59 -0400 (Fri, 12 Oct 2007)
New Revision: 1103
Modified:
trunk/sight/native/os/linux/service.c
trunk/sight/native/os/solaris/service.c
trunk/sight/native/os/windows/service.c
Log:
Refcount JNI calls for services
Modified: trunk/sight/native/os/linux/service.c
===================================================================
--- trunk/sight/native/os/linux/service.c 2007-10-12 05:11:54 UTC (rev 1102)
+++ trunk/sight/native/os/linux/service.c 2007-10-12 09:27:59 UTC (rev 1103)
@@ -159,36 +159,41 @@
SIGHT_FREE_CSTRING(name);
return APR_EINVAL;
}
- si = (scm_instance_t *)ns->native;
- sprintf(rlpath, si->rlpath, si->what);
- if ((rd = opendir(rlpath))) {
- struct dirent *sent, sbuf;
- int state = SIGHT_SS_DISABLED;
- while (!readdir_r(rd, &sbuf, &sent)) {
- char sname[PATH_MAX];
- char smatch[PATH_MAX];
- struct stat sb;
- if (!sent)
- break;
- strcpy(sname, rlpath);
- strcat(sname, sent->d_name);
- strcpy(smatch, "*/S??");
- strcat(smatch, J2S(name));
- /* Match the SnnName */
- if (!sight_wmatch(sname, smatch)) {
- SET_IFIELD_S(0001, thiz, sname);
- SET_IFIELD_S(0004, thiz, sent->d_name);
+ SIGHT_LOCAL_TRY(ns) {
+ SIGHT_LOCAL_TRY(no) {
+ si = (scm_instance_t *)ns->native;
+ sprintf(rlpath, si->rlpath, si->what);
- /* TODO: Launch script with status param
- * to figure out the state.
- */
- state = SIGHT_SS_UNKNOWN;
- break;
+ if ((rd = opendir(rlpath))) {
+ struct dirent *sent, sbuf;
+ int state = SIGHT_SS_DISABLED;
+ while (!readdir_r(rd, &sbuf, &sent)) {
+ char sname[PATH_MAX];
+ char smatch[PATH_MAX];
+ struct stat sb;
+ if (!sent)
+ break;
+ strcpy(sname, rlpath);
+ strcat(sname, sent->d_name);
+ strcpy(smatch, "*/S??");
+ strcat(smatch, J2S(name));
+ /* Match the SnnName */
+ if (!sight_wmatch(sname, smatch)) {
+ SET_IFIELD_S(0001, thiz, sname);
+ SET_IFIELD_S(0004, thiz, sent->d_name);
+
+ /* TODO: Launch script with status param
+ * to figure out the state.
+ */
+ state = SIGHT_SS_UNKNOWN;
+ break;
+ }
}
+ closedir(rd);
+ CALL_METHOD1(0000, thiz, state);
}
- closedir(rd);
- CALL_METHOD1(0000, thiz, state);
- }
+ } SIGHT_LOCAL_END(no);
+ } SIGHT_LOCAL_END(ns);
SIGHT_FREE_CSTRING(name);
return APR_FROM_OS_ERROR(rc);
}
Modified: trunk/sight/native/os/solaris/service.c
===================================================================
--- trunk/sight/native/os/solaris/service.c 2007-10-12 05:11:54 UTC (rev 1102)
+++ trunk/sight/native/os/solaris/service.c 2007-10-12 09:27:59 UTC (rev 1103)
@@ -162,43 +162,47 @@
SIGHT_FREE_CSTRING(name);
return APR_EINVAL;
}
- si = (scm_instance_t *)ns->native;
- sprintf(rlpath, si->rlpath, si->what);
+ SIGHT_LOCAL_TRY(ns) {
+ SIGHT_LOCAL_TRY(no) {
+ si = (scm_instance_t *)ns->native;
+ sprintf(rlpath, si->rlpath, si->what);
sretry:
- if ((rd = opendir(rlpath))) {
- struct dirent *sent;
- char sbuf[PATH_MAX + sizeof(struct dirent)];;
- while (!readdir_r(rd, (struct dirent *)sbuf, &sent)) {
- char sname[PATH_MAX];
- char smatch[PATH_MAX];
- struct stat sb;
- if (!sent)
- break;
- strcpy(sname, rlpath);
- strcat(sname, sent->d_name);
- strcpy(smatch, "*/S??");
- strcat(smatch, J2S(name));
- /* Match the SnnName */
- if (!sight_wmatch(sname, smatch)) {
- SET_IFIELD_S(0001, thiz, sname);
- SET_IFIELD_S(0004, thiz, sent->d_name);
-
- /* TODO: Launch script with status param
- * to figure out the state.
- */
- state = SIGHT_SS_UNKNOWN;
- break;
+ if ((rd = opendir(rlpath))) {
+ struct dirent *sent;
+ char sbuf[PATH_MAX + sizeof(struct dirent)];;
+ while (!readdir_r(rd, (struct dirent *)sbuf, &sent)) {
+ char sname[PATH_MAX];
+ char smatch[PATH_MAX];
+ struct stat sb;
+ if (!sent)
+ break;
+ strcpy(sname, rlpath);
+ strcat(sname, sent->d_name);
+ strcpy(smatch, "*/S??");
+ strcat(smatch, J2S(name));
+ /* Match the SnnName */
+ if (!sight_wmatch(sname, smatch)) {
+ SET_IFIELD_S(0001, thiz, sname);
+ SET_IFIELD_S(0004, thiz, sent->d_name);
+
+ /* TODO: Launch script with status param
+ * to figure out the state.
+ */
+ state = SIGHT_SS_UNKNOWN;
+ break;
+ }
}
+ closedir(rd);
+ CALL_METHOD1(0000, thiz, state);
}
- closedir(rd);
- CALL_METHOD1(0000, thiz, state);
- }
- if (state == SIGHT_SS_DISABLED &&
- strcmp(rlpath, "/etc/rcS.d/")) {
- strcpy(rlpath, "/etc/rcS.d/");
- goto sretry;
- }
+ if (state == SIGHT_SS_DISABLED &&
+ strcmp(rlpath, "/etc/rcS.d/")) {
+ strcpy(rlpath, "/etc/rcS.d/");
+ goto sretry;
+ }
+ } SIGHT_LOCAL_END(no);
+ } SIGHT_LOCAL_END(ns);
SIGHT_FREE_CSTRING(name);
return APR_FROM_OS_ERROR(rc);
}
Modified: trunk/sight/native/os/windows/service.c
===================================================================
--- trunk/sight/native/os/windows/service.c 2007-10-12 05:11:54 UTC (rev 1102)
+++ trunk/sight/native/os/windows/service.c 2007-10-12 09:27:59 UTC (rev 1103)
@@ -173,6 +173,7 @@
SIGHT_FREE_CSTRING(name);
return APR_EINVAL;
}
+ SIGHT_LOCAL_TRY(ns) {
SIGHT_LOCAL_TRY(no) {
hscm = ns->native;
if (no->native) {
@@ -183,6 +184,7 @@
if (IS_INVALID_HANDLE(hsvc)) {
rc = GetLastError();
SIGHT_LOCAL_BRK(no);
+ SIGHT_LOCAL_BRK(ns);
goto cleanup;
}
@@ -197,17 +199,20 @@
throwAprMemoryException(_E, THROW_FMARK,
apr_get_os_error());
SIGHT_LOCAL_BRK(no);
+ SIGHT_LOCAL_BRK(ns);
goto cleanup;
}
if (!QueryServiceConfigW(hsvc, lpServiceConfig,
cbBufSize, &cbBytesNeeded)) {
rc = GetLastError();
SIGHT_LOCAL_BRK(no);
+ SIGHT_LOCAL_BRK(ns);
goto cleanup;
}
}
else {
SIGHT_LOCAL_BRK(no);
+ SIGHT_LOCAL_BRK(ns);
goto cleanup;
}
}
@@ -222,6 +227,7 @@
BYTE *lpBuffer;
if (rc != ERROR_INSUFFICIENT_BUFFER) {
SIGHT_LOCAL_BRK(no);
+ SIGHT_LOCAL_BRK(ns);
goto cleanup;
}
cbBufSize = cbBytesNeeded;
@@ -231,6 +237,7 @@
throwAprMemoryException(_E, THROW_FMARK,
apr_get_os_error());
SIGHT_LOCAL_BRK(no);
+ SIGHT_LOCAL_BRK(ns);
goto cleanup;
}
if (!QueryServiceConfig2W(hsvc, SERVICE_CONFIG_DESCRIPTION,
@@ -238,6 +245,7 @@
rc = GetLastError();
free(lpBuffer);
SIGHT_LOCAL_BRK(no);
+ SIGHT_LOCAL_BRK(ns);
goto cleanup;
}
else {
@@ -262,6 +270,7 @@
rc = ERROR_SUCCESS;
}
} SIGHT_LOCAL_END(no);
+ } SIGHT_LOCAL_END(ns);
cleanup:
if (lpServiceConfig)
free(lpServiceConfig);
@@ -389,6 +398,10 @@
timeout_interval = 100000L;
}
do {
+ if (SIGHT_LOCAL_IRQ(no)) {
+ rc = APR_TO_OS_ERROR(APR_TIMEUP);
+ break;
+ }
apr_sleep(timeout_interval);
if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
buf, sizeof(buf), &cbBytesNeeded)) {
@@ -484,6 +497,10 @@
else if (cres > 0) {
timeout_interval = cres * 1000L;
}
+ if (SIGHT_LOCAL_IRQ(no)) {
+ rc = APR_TO_OS_ERROR(APR_TIMEUP);
+ break;
+ }
apr_sleep(timeout_interval);
if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
buf, sizeof(buf), &cbBytesNeeded)) {