JBoss Native SVN: r1063 - trunk/sight/native/os/solaris.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-09-30 11:03:08 -0400 (Sun, 30 Sep 2007)
New Revision: 1063
Modified:
trunk/sight/native/os/solaris/main.c
trunk/sight/native/os/solaris/process.c
trunk/sight/native/os/solaris/volume.c
Log:
Arrange process and port volume to solaris.
Modified: trunk/sight/native/os/solaris/main.c
===================================================================
--- trunk/sight/native/os/solaris/main.c 2007-09-29 06:48:13 UTC (rev 1062)
+++ trunk/sight/native/os/solaris/main.c 2007-09-30 15:03:08 UTC (rev 1063)
@@ -78,13 +78,7 @@
int fd;
apr_status_t rc;
- /* check directory */
- sprintf(pname, "/proc/%d", pid);
- if ((rc = apr_stat(&i, pname,
- APR_FINFO_MIN | APR_FINFO_OWNER,
- pool)) != APR_SUCCESS) {
- return rc;
- }
+ /* Don't check directory on Solaris */
sprintf(pname, "/proc/%d/psinfo", pid);
/* XXX: use APR */
if ((fd = open(pname, O_RDONLY)) < 0) {
Modified: trunk/sight/native/os/solaris/process.c
===================================================================
--- trunk/sight/native/os/solaris/process.c 2007-09-29 06:48:13 UTC (rev 1062)
+++ trunk/sight/native/os/solaris/process.c 2007-09-30 15:03:08 UTC (rev 1063)
@@ -307,97 +307,6 @@
}
SET_IFIELD_S(0001, thiz, psinfo.pr_fname);
- /* to read the arguments and the environment we must read /proc/pid/as */
- sprintf(pname, "/proc/%d/as", pid);
- if ((fd = open(pname, O_RDONLY))<0)
- return apr_get_os_error();
- sa = (char **) malloc(sizeof(char *) * (psinfo.pr_argc + 1));
- if (lseek(fd, psinfo.pr_argv, SEEK_SET) == -1) {
- close(fd);
- free(sa);
- return apr_get_os_error();
- }
- if (read(fd, sa, sizeof(char *) * (psinfo.pr_argc + 1)) < 0) {
- close(fd);
- free(sa);
- return apr_get_os_error();
- }
-
- arr = sight_new_cc_array(_E, SIGHT_CC_STRING, psinfo.pr_argc);
- pname[SIGHT_STYPE_LEN] = '\0';
- for (n = 0; n < psinfo.pr_argc; n++) {
- jstring s;
- if (lseek(fd, sa[n], SEEK_SET) != -1) {
- if (read(fd, pname, SIGHT_STYPE_LEN) > 0) {
- s = (*_E)->NewStringUTF((_E), pname);
- if (s) {
- (*_E)->SetObjectArrayElement(_E, arr, n, s);
- (*_E)->DeleteLocalRef(_E, s);
- }
- continue;
- }
- }
- s = (*_E)->NewStringUTF((_E), "");
- if (s) {
- (*_E)->SetObjectArrayElement(_E, arr, n, s);
- (*_E)->DeleteLocalRef(_E, s);
- }
- }
-
- SET_IFIELD_O(0003, thiz, arr);
- free(sa);
-
- /* process environment like arguments */
- if (lseek(fd, psinfo.pr_envp, SEEK_SET) == -1) {
- close(fd);
- return apr_get_os_error();
- }
- /* count the environment variables */
- p = (char *)1;
- count = 0;
- while (p) {
- if (read(fd, &p, sizeof(char *)) < 0) {
- close(fd);
- return apr_get_os_error();
- }
- count++;
- }
- sa = (char **) malloc(sizeof(char *) * (count));
- if (lseek(fd, psinfo.pr_envp, SEEK_SET) == -1) {
- close(fd);
- free(sa);
- return apr_get_os_error();
- }
- if (read(fd, sa, sizeof(char *) * (count)) < 0) {
- close(fd);
- free(sa);
- return apr_get_os_error();
- }
- arr = sight_new_cc_array(_E, SIGHT_CC_STRING, count-1);
- pname[SIGHT_STYPE_LEN] = '\0';
- for (n = 0; n < count-1; n++) {
- jstring s;
- if (lseek(fd, sa[n], SEEK_SET) != -1) {
- if (read(fd, pname, SIGHT_STYPE_LEN) > 0) {
- s = (*_E)->NewStringUTF((_E), pname);
- if (s) {
- (*_E)->SetObjectArrayElement(_E, arr, n, s);
- (*_E)->DeleteLocalRef(_E, s);
- }
- continue;
- }
- }
- s = (*_E)->NewStringUTF((_E), "");
- if (s) {
- (*_E)->SetObjectArrayElement(_E, arr, n, s);
- (*_E)->DeleteLocalRef(_E, s);
- }
- }
-
- SET_IFIELD_O(0004, thiz, arr);
- free(sa);
- close(fd);
-
SET_IFIELD_I(0000, thiz, psinfo.pr_ppid);
SET_IFIELD_S(0002, thiz, psinfo.pr_fname); /* XXX: trucate ? */
@@ -427,6 +336,135 @@
SET_IFIELD_J(0014, thiz, psinfo.pr_time.tv_sec * 1000 + psinfo.pr_time.tv_nsec/1000);
/* XXX: SET_IFIELD_J(0015, thiz, TCK2MS(utime)); */
+ /* to read the arguments and the environment we must read /proc/pid/as */
+ sprintf(pname, "/proc/%d/as", pid);
+ if ((fd = open(pname, O_RDONLY))<0){
+ rc = apr_get_os_error();
+ if (rc != APR_EACCES)
+ return rc;
+ }
+ if ( rc == APR_SUCCESS) {
+ sa = (char **) malloc(sizeof(char *) * (psinfo.pr_argc + 1));
+ if (lseek(fd, psinfo.pr_argv, SEEK_SET) == -1) {
+ close(fd);
+ free(sa);
+ return apr_get_os_error();
+ }
+ if (read(fd, sa, sizeof(char *) * (psinfo.pr_argc + 1)) < 0) {
+ close(fd);
+ free(sa);
+ return apr_get_os_error();
+ }
+
+ arr = sight_new_cc_array(_E, SIGHT_CC_STRING, psinfo.pr_argc);
+ pname[SIGHT_STYPE_LEN] = '\0';
+ for (n = 0; n < psinfo.pr_argc; n++) {
+ jstring s;
+ if (lseek(fd, sa[n], SEEK_SET) != -1) {
+ if (read(fd, pname, SIGHT_STYPE_LEN) > 0) {
+ s = (*_E)->NewStringUTF((_E), pname);
+ if (s) {
+ (*_E)->SetObjectArrayElement(_E, arr, n, s);
+ (*_E)->DeleteLocalRef(_E, s);
+ }
+ continue;
+ }
+ }
+ s = (*_E)->NewStringUTF((_E), "");
+ if (s) {
+ (*_E)->SetObjectArrayElement(_E, arr, n, s);
+ (*_E)->DeleteLocalRef(_E, s);
+ }
+ }
+
+ SET_IFIELD_O(0003, thiz, arr);
+ free(sa);
+
+ /* process environment like arguments */
+ if (lseek(fd, psinfo.pr_envp, SEEK_SET) == -1) {
+ close(fd);
+ return apr_get_os_error();
+ }
+ /* count the environment variables */
+ p = (char *)1;
+ count = 0;
+ while (p) {
+ if (read(fd, &p, sizeof(char *)) < 0) {
+ close(fd);
+ return apr_get_os_error();
+ }
+ count++;
+ }
+ sa = (char **) malloc(sizeof(char *) * (count));
+ if (lseek(fd, psinfo.pr_envp, SEEK_SET) == -1) {
+ close(fd);
+ free(sa);
+ return apr_get_os_error();
+ }
+ if (read(fd, sa, sizeof(char *) * (count)) < 0) {
+ close(fd);
+ free(sa);
+ return apr_get_os_error();
+ }
+ arr = sight_new_cc_array(_E, SIGHT_CC_STRING, count-1);
+ pname[SIGHT_STYPE_LEN] = '\0';
+ for (n = 0; n < count-1; n++) {
+ jstring s;
+ if (lseek(fd, sa[n], SEEK_SET) != -1) {
+ if (read(fd, pname, SIGHT_STYPE_LEN) > 0) {
+ s = (*_E)->NewStringUTF((_E), pname);
+ if (s) {
+ (*_E)->SetObjectArrayElement(_E, arr, n, s);
+ (*_E)->DeleteLocalRef(_E, s);
+ }
+ continue;
+ }
+ }
+ s = (*_E)->NewStringUTF((_E), "");
+ if (s) {
+ (*_E)->SetObjectArrayElement(_E, arr, n, s);
+ (*_E)->DeleteLocalRef(_E, s);
+ }
+ }
+
+ SET_IFIELD_O(0004, thiz, arr);
+ free(sa);
+ close(fd);
+ } else {
+ /* Use the psinfo */
+ char pr_name[PRARGSZ];
+ int k = 0;
+ int j = 0;
+ count = 0;
+ int l = 0;
+ while (k<PRARGSZ && psinfo.pr_psargs[k] != '\0') {
+ if (psinfo.pr_psargs[k] == ' ')
+ count++;
+ k++;
+ }
+
+ arr = sight_new_cc_array(_E, SIGHT_CC_STRING, count + 1);
+ for (k=0; k<count+1;k++) {
+ jstring s;
+ while (j<PRARGSZ && psinfo.pr_psargs[j] != '\0') {
+ if (psinfo.pr_psargs[j] == ' ')
+ break;
+ j++;
+ }
+ memset(pr_name, '\0', sizeof(pr_name));
+ memcpy(pr_name, &psinfo.pr_psargs[l], j-l);
+ j++;
+ l = j;
+ s = (*_E)->NewStringUTF((_E), pr_name);
+ if (s) {
+ (*_E)->SetObjectArrayElement(_E, arr, k, s);
+ (*_E)->DeleteLocalRef(_E, s);
+ }
+
+ }
+ SET_IFIELD_O(0003, thiz, arr);
+ }
+
/* get user, group and creation time (pr_start?) */
sprintf(pname, "/proc/%d", pid);
if ((rc = apr_stat(&i, pname,
Modified: trunk/sight/native/os/solaris/volume.c
===================================================================
--- trunk/sight/native/os/solaris/volume.c 2007-09-29 06:48:13 UTC (rev 1062)
+++ trunk/sight/native/os/solaris/volume.c 2007-09-30 15:03:08 UTC (rev 1063)
@@ -32,10 +32,13 @@
#define SIGHT_WANT_LATE_DLL
#include "sight_private.h"
-#include <mntent.h>
+#include <sys/mnttab.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
+#include <sys/stat.h>
+#include <sys/swap.h>
+
/*
* Network adapter implementation
*/
@@ -144,21 +147,34 @@
sight_unload_class(_E, &_clazzn);
}
-#define PROC_SWAPS_FS "/proc/swaps"
+extern apr_pool_t *sight_temp_pool;
typedef struct volume_enum_t {
+ apr_pool_t *pool;
+ int mounts_idx;
int num_mounts;
- FILE *fp;
- sight_arr_t *swaps;
+ struct sight_mnttab *ent;
int swap_idx;
+ int num_swap;
+ swaptbl_t * swap_table;
} volume_enum_t;
+#define MAXSTRSIZE 80
+#define MNTOPT_RW "write"
+#define MNTOPT_RO "read only"
+#define MNTOPT_SUID "setuid"
+
+struct sight_mnttab {
+ struct mnttab ent;
+ struct sight_mnttab *next;
+};
+
/* Initialize volume enumeration */
SIGHT_EXPORT_DECLARE(jlong, Volume, enum0)(SIGHT_STDARGS,
jlong pool)
{
volume_enum_t *e;
- char buf[SIGHT_MBUFFER_SIZ];
+ apr_status_t rc;
UNREFERENCED_O;
if (!(e = (volume_enum_t *)sight_calloc(_E,
@@ -166,46 +182,82 @@
THROW_FMARK))) {
return 0;
}
+ if ((rc = sight_create_pool(&e->pool, sight_temp_pool)) != APR_SUCCESS) {
+ throwAprMemoryException(_E, THROW_FMARK, rc);
+ return 0;
+ }
return P2J(e);
}
SIGHT_EXPORT_DECLARE(jint, Volume, enum1)(SIGHT_STDARGS,
jlong handle)
{
- struct mntent ent;
- char buf[SIGHT_MBUFFER_SIZ];
+ struct sight_mnttab *ent;
+ struct sight_mnttab *previous;
+ char *buf;
+ int i;
+ apr_status_t rc;
+ struct mnttab mp;
volume_enum_t *e = J2P(handle, volume_enum_t *);
+ FILE *fp = fopen(MNTTAB, "r");
UNREFERENCED_O;
if (!e)
return 0;
- if (!(e->fp = setmntent(MOUNTED, "r"))) {
+ if (fp == NULL) {
throwAprException(_E, apr_get_os_error());
return 0;
- } else {
- e->num_mounts = 0;
- while (getmntent_r(e->fp, &ent, buf, SIGHT_MBUFFER_LEN)) {
- e->num_mounts++;
- }
- endmntent(e->fp);
- e->fp = setmntent(MOUNTED, "r");
- /* Now read the swaps */
- if ((e->swaps = sight_arr_rload(PROC_SWAPS_FS))) {
- if (e->swaps->siz) {
- e->num_mounts += (e->swaps->siz - 1);
- e->swap_idx = 1;
- }
- }
- return e->num_mounts;
}
+ e->num_mounts = 0;
+ ent = (struct sight_mnttab *) apr_palloc(e->pool, sizeof(struct sight_mnttab));
+ ent->next = NULL;
+ e->ent = ent;
+ previous = ent;
+ while (getmntent(fp, &mp) == 0) {
+ ent->ent.mnt_special = apr_pstrdup(e->pool, mp.mnt_special);
+ ent->ent.mnt_mountp = apr_pstrdup(e->pool, mp.mnt_mountp);
+ ent->ent.mnt_fstype = apr_pstrdup(e->pool, mp.mnt_fstype);
+ ent->ent.mnt_mntopts = apr_pstrdup(e->pool, mp.mnt_mntopts);
+ ent->ent.mnt_time = apr_pstrdup(e->pool, mp.mnt_time);
+
+ e->num_mounts++;
+ previous = ent;
+ ent->next = (struct sight_mnttab *) apr_palloc(e->pool, sizeof(struct sight_mnttab));
+ ent = ent->next;
+ ent->next = NULL;
+ }
+ fclose(fp);
+ free(previous->next);
+ previous->next = NULL;
+
+ ent = e->ent;
+ while (ent != NULL) {
+ ent = ent->next;
+ }
+
+ /* process swap */
+ e->num_swap = swapctl(SC_GETNSWP, 0);
+ e->num_mounts = e->num_mounts + e->num_swap;
+ e->swap_table = malloc(sizeof(swapent_t) * e->num_swap + sizeof(int));
+ buf = malloc(MAXSTRSIZE * e->num_swap);
+ for (i = 0; i < e->num_swap; i++) {
+ e->swap_table->swt_ent[i].ste_path = buf + (i * MAXSTRSIZE);
+ }
+ e->swap_table->swt_n = e->num_swap;
+ swapctl(SC_LIST, e->swap_table);
+
+ e->swap_idx = 0;
+ e->mounts_idx = 0;
+
+ return e->num_mounts;
}
SIGHT_EXPORT_DECLARE(void, Volume, enum2)(SIGHT_STDARGS,
jobject thiz,
jlong handle)
{
- struct mntent ent;
+ struct mnttab ent;
struct statvfs sv;
char buf[SIGHT_MBUFFER_SIZ];
volume_enum_t *e = J2P(handle, volume_enum_t *);
@@ -214,46 +266,48 @@
if (!e || !thiz)
return;
- if (e->swaps && e->swap_idx < e->swaps->siz) {
- char path[256];
- char type[32];
- unsigned long size, used;
- int priority;
+ if (e->swap_idx < e->num_swap) {
+ int size = getpagesize();
- if (sscanf(e->swaps->arr[e->swap_idx],
- "%250s %30s %lu %lu %d",
- path, type, &size, &used, &priority) == 5) {
- SET_IFIELD_S(0000, thiz, path);
- SET_IFIELD_S(0001, thiz, type);
- SET_IFIELD_S(0002, thiz, "swap");
- CALL_METHOD1(0000, thiz, SIGHT_FS_SWAP);
- CALL_METHOD1(0001, thiz, SIGHT_READ_WRITE_VOLUME);
- CALL_METHOD1(0002, thiz, SIGHT_DRIVE_SWAP);
- SET_IFIELD_J(0005, thiz, size - used);
- SET_IFIELD_J(0006, thiz, size);
- SET_IFIELD_J(0007, thiz, size - used);
- }
+ SET_IFIELD_S(0000, thiz, e->swap_table->swt_ent[e->swap_idx].ste_path);
+ SET_IFIELD_S(0001, thiz, "partition");
+ SET_IFIELD_S(0002, thiz, "swap");
+ CALL_METHOD1(0000, thiz, SIGHT_FS_SWAP);
+ CALL_METHOD1(0001, thiz, SIGHT_READ_WRITE_VOLUME);
+ CALL_METHOD1(0002, thiz, SIGHT_DRIVE_SWAP);
+ SET_IFIELD_J(0005, thiz, (jlong) e->swap_table->swt_ent[e->swap_idx].ste_pages * (jlong) size);
+ SET_IFIELD_J(0006, thiz, (jlong) e->swap_table->swt_ent[e->swap_idx].ste_length * (jlong) size);
+ SET_IFIELD_J(0007, thiz, (jlong) e->swap_table->swt_ent[e->swap_idx].ste_free * (jlong) size);
e->swap_idx++;
return;
}
- if (getmntent_r(e->fp, &ent, buf, SIGHT_MBUFFER_LEN)) {
+ if (e->mounts_idx < e->num_mounts) {
+ struct sight_mnttab *ent;
+ int i;
int flags = 0;
- int dtype = sight_get_fs_type(ent.mnt_type);
- SET_IFIELD_S(0000, thiz, ent.mnt_fsname);
- SET_IFIELD_S(0002, thiz, ent.mnt_dir);
+ int dtype;
+ ent = e->ent;
+ for (i=1; i<e->mounts_idx; i++) {
+ ent = ent->next;
+ }
+ e->mounts_idx++;
+ dtype = sight_get_fs_type(ent->ent.mnt_fstype);
+ SET_IFIELD_S(0000, thiz, ent->ent.mnt_special);
+ SET_IFIELD_S(0001, thiz, ent->ent.mnt_fstype);
+ SET_IFIELD_S(0002, thiz, ent->ent.mnt_mountp);
CALL_METHOD1(0000, thiz, dtype);
- if (!statvfs(ent.mnt_dir, &sv)) {
+ if (!statvfs(ent->ent.mnt_mountp, &sv)) {
SET_IFIELD_I(0004, thiz, sv.f_bsize);
- SET_IFIELD_J(0005, thiz, sv.f_frsize * sv.f_bavail);
- SET_IFIELD_J(0006, thiz, sv.f_frsize * sv.f_blocks);
- SET_IFIELD_J(0007, thiz, sv.f_frsize * sv.f_bfree);
+ SET_IFIELD_J(0005, thiz, (jlong) sv.f_frsize * (jlong) sv.f_bavail);
+ SET_IFIELD_J(0006, thiz, (jlong) sv.f_frsize * (jlong) sv.f_blocks);
+ SET_IFIELD_J(0007, thiz, (jlong) sv.f_frsize * (jlong) sv.f_bfree);
}
- if (hasmntopt(&ent, MNTOPT_RW))
+ if (hasmntopt(&ent->ent, MNTOPT_RW))
flags |= SIGHT_READ_WRITE_VOLUME;
- if (hasmntopt(&ent, MNTOPT_RO))
+ if (hasmntopt(&ent->ent, MNTOPT_RO))
flags |= SIGHT_READ_ONLY_VOLUME;
- if (hasmntopt(&ent, MNTOPT_SUID))
+ if (hasmntopt(&ent->ent, MNTOPT_SUID))
flags |= SIGHT_SUID_VOLUME;
CALL_METHOD1(0001, thiz, flags);
switch (dtype) {
@@ -304,10 +358,7 @@
UNREFERENCED_STDARGS;
if (e) {
- if (e->fp)
- endmntent(e->fp);
- if (e->swaps)
- sight_arr_free(e->swaps);
+ apr_pool_destroy(e->pool);
free(e);
}
}
17 years, 2 months
JBoss Native SVN: r1062 - in trunk/sight: native/include and 2 other directories.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-29 02:48:13 -0400 (Sat, 29 Sep 2007)
New Revision: 1062
Modified:
trunk/sight/java/org/jboss/sight/NativeObject.java
trunk/sight/java/org/jboss/sight/Process.java
trunk/sight/native/include/sight_types.h
trunk/sight/native/os/windows/service.c
trunk/sight/native/share/dir.c
trunk/sight/native/share/no.c
trunk/sight/native/share/proc.c
Log:
I cannot belive I did that. Use Java locks instead APR atomics
Modified: trunk/sight/java/org/jboss/sight/NativeObject.java
===================================================================
--- trunk/sight/java/org/jboss/sight/NativeObject.java 2007-09-28 16:05:33 UTC (rev 1061)
+++ trunk/sight/java/org/jboss/sight/NativeObject.java 2007-09-29 06:48:13 UTC (rev 1062)
@@ -24,6 +24,7 @@
*/
package org.jboss.sight;
+import java.util.concurrent.locks.ReentrantLock;
/**
* Native Object abstract class
*
@@ -48,16 +49,30 @@
private static native void cbset0(long instance, Object cb)
throws OutOfMemoryError;
+ private ReentrantLock jniMutex;
+
+
/**
* Create new NativeObject without APR pool
*/
public NativeObject()
throws OutOfMemoryError
{
+ jniMutex = new ReentrantLock();
POOL = 0;
INSTANCE = alloc();
}
+ protected void nativeLock()
+ {
+ jniMutex.lock();
+ }
+
+ protected void nativeUnlock()
+ {
+ jniMutex.unlock();
+ }
+
/**
* Create new NativeObject
* @param parent The parent pool. If this is 0, the new pool is a root
@@ -68,6 +83,7 @@
protected NativeObject(long parent)
throws OutOfMemoryError
{
+ jniMutex = new ReentrantLock();
POOL = 0;
INSTANCE = alloc();
init0(this, INSTANCE, parent);
@@ -78,9 +94,15 @@
*/
public void destroy()
{
- free0(INSTANCE);
- INSTANCE = 0;
- POOL = 0;
+ jniMutex.lock();
+ try {
+ free0(INSTANCE);
+ }
+ finally {
+ INSTANCE = 0;
+ POOL = 0;
+ jniMutex.unlock();
+ }
}
/**
Modified: trunk/sight/java/org/jboss/sight/Process.java
===================================================================
--- trunk/sight/java/org/jboss/sight/Process.java 2007-09-28 16:05:33 UTC (rev 1061)
+++ trunk/sight/java/org/jboss/sight/Process.java 2007-09-29 06:48:13 UTC (rev 1062)
@@ -436,7 +436,13 @@
*/
public int wait(WaitHow waithow)
{
- return wait0(INSTANCE, waithow.valueOf());
+ nativeLock();
+ try {
+ return wait0(INSTANCE, waithow.valueOf());
+ }
+ finally {
+ nativeUnlock();
+ }
}
/**
@@ -457,7 +463,13 @@
*/
public int waitFor()
{
- return wait0(INSTANCE, 0);
+ nativeLock();
+ try {
+ return wait0(INSTANCE, 0);
+ }
+ finally {
+ nativeUnlock();
+ }
}
/**
@@ -482,7 +494,13 @@
*/
public int waitFor(long timeout)
{
- return wait1(INSTANCE, 0, timeout);
+ nativeLock();
+ try {
+ return wait1(INSTANCE, 0, timeout);
+ }
+ finally {
+ nativeUnlock();
+ }
}
/**
@@ -507,7 +525,13 @@
*/
public int waitFor(IProgressNotificationCallback progress, long timeout)
{
- return wait2(INSTANCE, progress, timeout);
+ nativeLock();
+ try {
+ return wait2(INSTANCE, progress, timeout);
+ }
+ finally {
+ nativeUnlock();
+ }
}
/**
@@ -530,7 +554,13 @@
*/
public int waitFor(IProgressNotificationCallback progress)
{
- return wait2(INSTANCE, progress, 0);
+ nativeLock();
+ try {
+ return wait2(INSTANCE, progress, 0);
+ }
+ finally {
+ nativeUnlock();
+ }
}
@@ -601,15 +631,20 @@
public int exec(String progname, String [] args, String [] env)
throws NullPointerException, OperatingSystemException
{
-
- int rv = exec0(INSTANCE, progname, args, env);
- if (rv == Error.APR_SUCCESS) {
- Id = pid0(INSTANCE);
- redirIs = new File(POOL, getios0(INSTANCE, 0));
- redirOs = new File(POOL, getios0(INSTANCE, 1));
- redirEs = new File(POOL, getios0(INSTANCE, 2));
+ nativeLock();
+ try {
+ int rv = exec0(INSTANCE, progname, args, env);
+ if (rv == Error.APR_SUCCESS) {
+ Id = pid0(INSTANCE);
+ redirIs = new File(POOL, getios0(INSTANCE, 0));
+ redirOs = new File(POOL, getios0(INSTANCE, 1));
+ redirEs = new File(POOL, getios0(INSTANCE, 2));
+ }
+ return rv;
}
- return rv;
+ finally {
+ nativeUnlock();
+ }
}
/**
Modified: trunk/sight/native/include/sight_types.h
===================================================================
--- trunk/sight/native/include/sight_types.h 2007-09-28 16:05:33 UTC (rev 1061)
+++ trunk/sight/native/include/sight_types.h 2007-09-29 06:48:13 UTC (rev 1062)
@@ -110,7 +110,6 @@
/* org.jboss.sight.NativeObject instance */
struct sight_object_t {
- volatile apr_uint32_t references;
apr_pool_t *pool;
void *native;
void *opaque;
@@ -120,9 +119,6 @@
void (*clean)(int, sight_object_t *);
};
-#define SIGHT_NO_IREF(N) apr_atomic_inc32(&((N)->references))
-#define SIGHT_NO_DREF(N) apr_atomic_dec32(&((N)->references))
-
#define CACHE_HASH_MASK 255
#define CACHE_HASH_SIZE 256
Modified: trunk/sight/native/os/windows/service.c
===================================================================
--- trunk/sight/native/os/windows/service.c 2007-09-28 16:05:33 UTC (rev 1061)
+++ trunk/sight/native/os/windows/service.c 2007-09-29 06:48:13 UTC (rev 1062)
@@ -356,7 +356,6 @@
return APR_EINVAL;
}
hsvc = no->native;
- SIGHT_NO_IREF(no);
if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
buf, sizeof(buf), &cbBytesNeeded)) {
rc = GetLastError();
@@ -398,7 +397,6 @@
CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
cleanup:
- SIGHT_NO_DREF(no);
return APR_FROM_OS_ERROR(rc);
}
@@ -426,7 +424,6 @@
return APR_EINVAL;
}
hsvc = no->native;
- SIGHT_NO_IREF(no);
if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
buf, sizeof(buf), &cbBytesNeeded)) {
@@ -494,6 +491,5 @@
CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
cleanup:
- SIGHT_NO_DREF(no);
return APR_FROM_OS_ERROR(rc);
}
Modified: trunk/sight/native/share/dir.c
===================================================================
--- trunk/sight/native/share/dir.c 2007-09-28 16:05:33 UTC (rev 1061)
+++ trunk/sight/native/share/dir.c 2007-09-29 06:48:13 UTC (rev 1062)
@@ -35,7 +35,7 @@
static void dir_cleanup(int mode, sight_object_t *no)
{
/*
- * In case this is a pool callback do not
+ * In case this is a pool callback do not
* close the directory. It will be closed
* by the original apr pool callback
*/
@@ -279,12 +279,10 @@
}
else
d = (apr_dir_t *)no->native;
- SIGHT_NO_IREF(no);
if (recursive)
len = calc_size_r((apr_dir_t *)no->native, J2S(path), no->pool);
else
len = calc_size_d((apr_dir_t *)no->native);
- SIGHT_NO_DREF(no);
cleanup:
SIGHT_FREE_CSTRING(path);
SIGHT_GLOBAL_CLEANUP();
Modified: trunk/sight/native/share/no.c
===================================================================
--- trunk/sight/native/share/no.c 2007-09-28 16:05:33 UTC (rev 1061)
+++ trunk/sight/native/share/no.c 2007-09-29 06:48:13 UTC (rev 1062)
@@ -207,8 +207,7 @@
{
sight_object_t *no = J2P(instance, sight_object_t *);
jobject object = NULL;
- apr_uint32_t ref_count;
- int valid_global = 0;
+
UNREFERENCED_O;
#ifdef SIGHT_DO_STATS
@@ -216,20 +215,13 @@
#endif
if (!no)
return;
- if (SIGHT_IS_VALID_GLOBAL())
- valid_global = 1;
- ref_count = apr_atomic_read32(&no->references);
- while (ref_count) {
- apr_thread_yield();
- ref_count = apr_atomic_read32(&no->references);
- }
if (no->object) {
object = (*_E)->NewLocalRef(_E, no->object);
(*_E)->DeleteWeakGlobalRef(_E, no->object);
no->object = object;
}
- if (valid_global) {
+ if (SIGHT_IS_VALID_GLOBAL()) {
if (no->pool)
apr_pool_cleanup_kill(no->pool, no, native_object_cleanup);
if (no->object) {
Modified: trunk/sight/native/share/proc.c
===================================================================
--- trunk/sight/native/share/proc.c 2007-09-28 16:05:33 UTC (rev 1061)
+++ trunk/sight/native/share/proc.c 2007-09-29 06:48:13 UTC (rev 1062)
@@ -59,25 +59,36 @@
apr_status_t rv;
UNREFERENCED_O;
+ if (!SIGHT_IS_VALID_GLOBAL()) {
+ throwAprMemoryException(_E, THROW_FMARK, APR_ENOPOOL);
+ rv = APR_ENOPOOL;
+ goto cleanup;
+ }
+
if (!no || !no->pool) {
throwNullPointerException(_E, THROW_FMARK,
sight_strerror(SIGHT_ENOPOOL));
- return APR_ENOPOOL;
+ rv = APR_ENOPOOL;
+ goto cleanup;
}
p = (sight_runproc_t *)sight_pcalloc(_E, no->pool, sizeof(sight_runproc_t),
THROW_FMARK);
- if (p == NULL)
- return APR_ENOMEM;
+ if (p == NULL) {
+ rv = APR_ENOMEM;
+ goto cleanup;
+ }
if ((rv = apr_procattr_create(&p->attr, no->pool)) != APR_SUCCESS) {
- return rv;
+ goto cleanup;
}
p->exitval = -1;
#ifdef SIGHT_DO_STATS
no->clean = proc_cleanup;
#endif
no->native = p;
-
- return APR_SUCCESS;
+ rv = APR_SUCCESS;
+cleanup:
+ SIGHT_GLOBAL_CLEANUP();
+ return rv;
}
SIGHT_EXPORT_DECLARE(jint, Process, ioset0)(SIGHT_STDARGS,
@@ -299,11 +310,9 @@
UNREFERENCED_STDARGS;
if (!no || !no->native)
return APR_EINVAL;
- SIGHT_NO_IREF(no);
p = (sight_runproc_t *)no->native;
rv = apr_proc_wait(&p->p, &p->exitval, &p->exitwhy,
(apr_wait_how_e)waithow);
- SIGHT_NO_DREF(no);
return rv;
}
@@ -322,7 +331,7 @@
UNREFERENCED_STDARGS;
if (!no || !no->native)
return APR_EINVAL;
- SIGHT_NO_IREF(no);
+
p = (sight_runproc_t *)no->native;
if (timeout < 0)
how = APR_WAIT;
@@ -330,9 +339,9 @@
how = APR_NOWAIT;
if ((rc = apr_proc_wait(&p->p, &p->exitval, &p->exitwhy,
how)) != APR_CHILD_NOTDONE)
- goto done;
+ return rc;
if (timeout < 1)
- goto done;
+ return APR_EINVAL;
timeout_value = timeout * 1000L;
timeout_interval = timeout_value / 64;
do {
@@ -343,8 +352,6 @@
timeout_interval *= 2;
} while (rc == APR_CHILD_NOTDONE);
-done:
- SIGHT_NO_DREF(no);
return rc;
}
@@ -365,11 +372,10 @@
UNREFERENCED_O;
if (!no || !no->native || !progress)
return APR_EINVAL;
- SIGHT_NO_IREF(no);
p = (sight_runproc_t *)no->native;
if ((rc = apr_proc_wait(&p->p, &p->exitval, &p->exitwhy,
APR_NOWAIT)) != APR_CHILD_NOTDONE)
- goto done;
+ return rc;
c = (*_E)->GetObjectClass(_E, progress);
cb.name = "progress";
@@ -377,13 +383,11 @@
cb.object = progress;
cb.method = (*_E)->GetMethodID(_E, c, cb.name, cb.msig);
if (!cb.method || (*_E)->ExceptionCheck(_E)) {
- rc = APR_EINVAL;
- goto done;
+ return APR_EINVAL;
}
cres = (*_E)->CallIntMethod(_E, cb.object, cb.method, tick, NULL);
if ((*_E)->ExceptionCheck(_E)) {
- rc = APR_FROM_OS_ERROR(EINTR);
- goto done;
+ return APR_FROM_OS_ERROR(EINTR);
}
if (timeout > 0) {
@@ -411,14 +415,11 @@
}
cres = (*_E)->CallIntMethod(_E, cb.object, cb.method, tick++, NULL);
if ((*_E)->ExceptionCheck(_E)) {
- rc = APR_FROM_OS_ERROR(EINTR);
- goto done;
+ return APR_FROM_OS_ERROR(EINTR);
}
} while (rc == APR_CHILD_NOTDONE);
-done:
- SIGHT_NO_DREF(no);
return rc;
}
@@ -469,6 +470,12 @@
UNREFERENCED_O;
+ if (!SIGHT_IS_VALID_GLOBAL()) {
+ throwAprMemoryException(_E, THROW_FMARK, APR_ENOPOOL);
+ rv = APR_ENOPOOL;
+ goto cleanup;
+ }
+
if (!no || !no->native) {
throwNullPointerException(_E, THROW_FMARK,
sight_strerror(SIGHT_ENOPROC));
@@ -517,6 +524,7 @@
}
cleanup:
SIGHT_FREE_CSTRING(progname);
+ SIGHT_GLOBAL_CLEANUP();
return rv;
}
17 years, 2 months
JBoss Native SVN: r1061 - trunk/sight/native/os/solaris.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-09-28 12:05:33 -0400 (Fri, 28 Sep 2007)
New Revision: 1061
Modified:
trunk/sight/native/os/solaris/volume.c
Log:
Start using the linux one.
Modified: trunk/sight/native/os/solaris/volume.c
===================================================================
--- trunk/sight/native/os/solaris/volume.c 2007-09-28 14:03:06 UTC (rev 1060)
+++ trunk/sight/native/os/solaris/volume.c 2007-09-28 16:05:33 UTC (rev 1061)
@@ -32,6 +32,10 @@
#define SIGHT_WANT_LATE_DLL
#include "sight_private.h"
+#include <mntent.h>
+#include <sys/statfs.h>
+#include <sys/statvfs.h>
+
/*
* Network adapter implementation
*/
@@ -140,23 +144,149 @@
sight_unload_class(_E, &_clazzn);
}
+#define PROC_SWAPS_FS "/proc/swaps"
+
+typedef struct volume_enum_t {
+ int num_mounts;
+ FILE *fp;
+ sight_arr_t *swaps;
+ int swap_idx;
+} volume_enum_t;
+
/* Initialize volume enumeration */
SIGHT_EXPORT_DECLARE(jlong, Volume, enum0)(SIGHT_STDARGS,
jlong pool)
{
- return 0;
+ volume_enum_t *e;
+ char buf[SIGHT_MBUFFER_SIZ];
+
+ UNREFERENCED_O;
+ if (!(e = (volume_enum_t *)sight_calloc(_E,
+ sizeof(volume_enum_t),
+ THROW_FMARK))) {
+ return 0;
+ }
+ return P2J(e);
}
SIGHT_EXPORT_DECLARE(jint, Volume, enum1)(SIGHT_STDARGS,
jlong handle)
{
- return 0;
+ struct mntent ent;
+ char buf[SIGHT_MBUFFER_SIZ];
+ volume_enum_t *e = J2P(handle, volume_enum_t *);
+
+ UNREFERENCED_O;
+
+ if (!e)
+ return 0;
+ if (!(e->fp = setmntent(MOUNTED, "r"))) {
+ throwAprException(_E, apr_get_os_error());
+ return 0;
+ } else {
+ e->num_mounts = 0;
+ while (getmntent_r(e->fp, &ent, buf, SIGHT_MBUFFER_LEN)) {
+ e->num_mounts++;
+ }
+ endmntent(e->fp);
+ e->fp = setmntent(MOUNTED, "r");
+ /* Now read the swaps */
+ if ((e->swaps = sight_arr_rload(PROC_SWAPS_FS))) {
+ if (e->swaps->siz) {
+ e->num_mounts += (e->swaps->siz - 1);
+ e->swap_idx = 1;
+ }
+ }
+ return e->num_mounts;
+ }
}
SIGHT_EXPORT_DECLARE(void, Volume, enum2)(SIGHT_STDARGS,
jobject thiz,
jlong handle)
{
+ struct mntent ent;
+ struct statvfs sv;
+ char buf[SIGHT_MBUFFER_SIZ];
+ volume_enum_t *e = J2P(handle, volume_enum_t *);
+
+ UNREFERENCED_O;
+
+ if (!e || !thiz)
+ return;
+ if (e->swaps && e->swap_idx < e->swaps->siz) {
+ char path[256];
+ char type[32];
+ unsigned long size, used;
+ int priority;
+
+ if (sscanf(e->swaps->arr[e->swap_idx],
+ "%250s %30s %lu %lu %d",
+ path, type, &size, &used, &priority) == 5) {
+ SET_IFIELD_S(0000, thiz, path);
+ SET_IFIELD_S(0001, thiz, type);
+ SET_IFIELD_S(0002, thiz, "swap");
+ CALL_METHOD1(0000, thiz, SIGHT_FS_SWAP);
+ CALL_METHOD1(0001, thiz, SIGHT_READ_WRITE_VOLUME);
+ CALL_METHOD1(0002, thiz, SIGHT_DRIVE_SWAP);
+ SET_IFIELD_J(0005, thiz, size - used);
+ SET_IFIELD_J(0006, thiz, size);
+ SET_IFIELD_J(0007, thiz, size - used);
+ }
+ e->swap_idx++;
+ return;
+ }
+ if (getmntent_r(e->fp, &ent, buf, SIGHT_MBUFFER_LEN)) {
+ int flags = 0;
+ int dtype = sight_get_fs_type(ent.mnt_type);
+ SET_IFIELD_S(0000, thiz, ent.mnt_fsname);
+ SET_IFIELD_S(0002, thiz, ent.mnt_dir);
+ CALL_METHOD1(0000, thiz, dtype);
+
+ if (!statvfs(ent.mnt_dir, &sv)) {
+ SET_IFIELD_I(0004, thiz, sv.f_bsize);
+ SET_IFIELD_J(0005, thiz, sv.f_frsize * sv.f_bavail);
+ SET_IFIELD_J(0006, thiz, sv.f_frsize * sv.f_blocks);
+ SET_IFIELD_J(0007, thiz, sv.f_frsize * sv.f_bfree);
+ }
+ if (hasmntopt(&ent, MNTOPT_RW))
+ flags |= SIGHT_READ_WRITE_VOLUME;
+ if (hasmntopt(&ent, MNTOPT_RO))
+ flags |= SIGHT_READ_ONLY_VOLUME;
+ if (hasmntopt(&ent, MNTOPT_SUID))
+ flags |= SIGHT_SUID_VOLUME;
+ CALL_METHOD1(0001, thiz, flags);
+ switch (dtype) {
+ case SIGHT_FS_UNKNOWN:
+ CALL_METHOD1(0002, thiz, SIGHT_DRIVE_UNKNOWN);
+ break;
+ case SIGHT_FS_ISO9660:
+ CALL_METHOD1(0002, thiz, SIGHT_DRIVE_CDROM);
+ break;
+ case SIGHT_FS_DEV:
+ case SIGHT_FS_PROC:
+ case SIGHT_FS_SYSFS:
+ case SIGHT_FS_TMPFS:
+ case SIGHT_FS_RAMFS:
+ CALL_METHOD1(0002, thiz, SIGHT_DRIVE_RAMDISK);
+ break;
+ case SIGHT_FS_NFS:
+ case SIGHT_FS_RPC:
+ case SIGHT_FS_VMBLOCK:
+ CALL_METHOD1(0002, thiz, SIGHT_DRIVE_REMOTE);
+ break;
+ case SIGHT_FS_USBFS:
+ CALL_METHOD1(0002, thiz, SIGHT_DRIVE_REMOVABLE);
+ break;
+ case SIGHT_FS_SWAP:
+ CALL_METHOD1(0002, thiz, SIGHT_DRIVE_SWAP);
+ break;
+ default:
+ CALL_METHOD1(0002, thiz, SIGHT_DRIVE_FIXED);
+ break;
+ }
+
+ }
}
SIGHT_EXPORT_DECLARE(jint, Volume, enum3)(SIGHT_STDARGS,
@@ -170,4 +300,14 @@
SIGHT_EXPORT_DECLARE(void, Volume, enum4)(SIGHT_STDARGS,
jlong handle)
{
+ volume_enum_t *e = J2P(handle, volume_enum_t *);
+
+ UNREFERENCED_STDARGS;
+ if (e) {
+ if (e->fp)
+ endmntent(e->fp);
+ if (e->swaps)
+ sight_arr_free(e->swaps);
+ free(e);
+ }
}
17 years, 2 months
JBoss Native SVN: r1060 - in trunk/sight: native/share and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-28 10:03:06 -0400 (Fri, 28 Sep 2007)
New Revision: 1060
Modified:
trunk/sight/examples/org/jboss/sight/RunProcess.java
trunk/sight/native/share/no.c
Log:
Fix JBNATIVE-38
Modified: trunk/sight/examples/org/jboss/sight/RunProcess.java
===================================================================
--- trunk/sight/examples/org/jboss/sight/RunProcess.java 2007-09-28 13:02:51 UTC (rev 1059)
+++ trunk/sight/examples/org/jboss/sight/RunProcess.java 2007-09-28 14:03:06 UTC (rev 1060)
@@ -37,6 +37,39 @@
public class RunProcess {
+ private class ProcessWorker extends Thread
+ {
+
+ private Process proc;
+
+ public ProcessWorker(Process proc)
+ {
+ this.proc = proc;
+ }
+
+ public void run() {
+ try {
+ Thread.sleep(1000);
+ } catch (Exception e) {
+ // Skip
+ } finally {
+ try {
+ System.out.println("Destroying proc");
+ proc.destroy();
+ System.out.println("Destroyed proc");
+
+ } catch (Exception x) {
+ // Skip
+ x.printStackTrace();
+ }
+ }
+
+ }
+
+
+ }
+
+
private class Progress implements IProgressNotificationCallback
{
public Progress()
@@ -90,6 +123,8 @@
}
System.out.println();
System.out.println("Waiting for process to die ...");
+ ProcessWorker pw = new ProcessWorker(p);
+ pw.start();
Progress pc = new Progress();
int w = p.waitFor(pc, 3000);
System.out.println();
Modified: trunk/sight/native/share/no.c
===================================================================
--- trunk/sight/native/share/no.c 2007-09-28 13:02:51 UTC (rev 1059)
+++ trunk/sight/native/share/no.c 2007-09-28 14:03:06 UTC (rev 1060)
@@ -208,7 +208,7 @@
sight_object_t *no = J2P(instance, sight_object_t *);
jobject object = NULL;
apr_uint32_t ref_count;
-
+ int valid_global = 0;
UNREFERENCED_O;
#ifdef SIGHT_DO_STATS
@@ -216,6 +216,8 @@
#endif
if (!no)
return;
+ if (SIGHT_IS_VALID_GLOBAL())
+ valid_global = 1;
ref_count = apr_atomic_read32(&no->references);
while (ref_count) {
apr_thread_yield();
@@ -227,7 +229,7 @@
(*_E)->DeleteWeakGlobalRef(_E, no->object);
no->object = object;
}
- if (SIGHT_IS_VALID_GLOBAL()) {
+ if (valid_global) {
if (no->pool)
apr_pool_cleanup_kill(no->pool, no, native_object_cleanup);
if (no->object) {
17 years, 2 months
JBoss Native SVN: r1059 - trunk/sight/examples/org/jboss/sight.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-09-28 09:02:51 -0400 (Fri, 28 Sep 2007)
New Revision: 1059
Modified:
trunk/sight/examples/org/jboss/sight/ListProcesses.java
Log:
Print argument only if they exist (no argument for kernel threads in Linux).
Modified: trunk/sight/examples/org/jboss/sight/ListProcesses.java
===================================================================
--- trunk/sight/examples/org/jboss/sight/ListProcesses.java 2007-09-28 12:57:13 UTC (rev 1058)
+++ trunk/sight/examples/org/jboss/sight/ListProcesses.java 2007-09-28 13:02:51 UTC (rev 1059)
@@ -42,11 +42,18 @@
for (Process p : Process.getProcesses()) {
User u = new User(p.UserId);
Group g = new Group(p.GroupId);
- System.out.println("Process\t[" + p.Id + "] \t" +
+ if (p.Arguments==null)
+ System.out.println("Process\t[" + p.Id + "] \t" +
p.State + " : " + p.BaseName +
" User(" + u.Name + ") Group(" +
g.Name +")" + "\t " +
- p.CurrentWorkingDirectory + "\t" +
+ p.CurrentWorkingDirectory);
+ else
+ System.out.println("Process\t[" + p.Id + "] \t" +
+ p.State + " : " + p.BaseName +
+ " User(" + u.Name + ") Group(" +
+ g.Name +")" + "\t " +
+ p.CurrentWorkingDirectory + "\t " +
p.Arguments[0]);
}
} catch (Exception e) {
17 years, 2 months
JBoss Native SVN: r1058 - in trunk/sight: test/org/jboss/sight and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-28 08:57:13 -0400 (Fri, 28 Sep 2007)
New Revision: 1058
Modified:
trunk/sight/java/org/jboss/sight/LibraryLoader.java
trunk/sight/test/org/jboss/sight/ProcessTest.java
Log:
Fix JBNATIVE-48
Modified: trunk/sight/java/org/jboss/sight/LibraryLoader.java
===================================================================
--- trunk/sight/java/org/jboss/sight/LibraryLoader.java 2007-09-28 12:12:16 UTC (rev 1057)
+++ trunk/sight/java/org/jboss/sight/LibraryLoader.java 2007-09-28 12:57:13 UTC (rev 1058)
@@ -101,7 +101,7 @@
protected static void load(String rootPath)
throws SecurityException, IOException, UnsatisfiedLinkError
{
- int count = new Integer(0);
+ int count = 0;
String name = getDefaultPlatformName();
String path = getDefaultLibraryPath();
Properties props = new Properties();
@@ -119,7 +119,6 @@
count = Integer.parseInt(props.getProperty(name + ".count"));
}
catch (Throwable t) {
- t.printStackTrace(System.err);
throw new UnsatisfiedLinkError("Can't use Library.properties");
}
for (int i = 0; i < count; i++) {
Modified: trunk/sight/test/org/jboss/sight/ProcessTest.java
===================================================================
--- trunk/sight/test/org/jboss/sight/ProcessTest.java 2007-09-28 12:12:16 UTC (rev 1057)
+++ trunk/sight/test/org/jboss/sight/ProcessTest.java 2007-09-28 12:57:13 UTC (rev 1058)
@@ -43,7 +43,7 @@
protected void setUp()
throws Exception
{
- Library.initialize(null);
+ Library.initialize("");
}
protected void tearDown()
17 years, 2 months
JBoss Native SVN: r1057 - trunk/sight/examples/org/jboss/sight.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-09-28 08:12:16 -0400 (Fri, 28 Sep 2007)
New Revision: 1057
Modified:
trunk/sight/examples/org/jboss/sight/ListProcesses.java
Log:
Print the first argument too.
Modified: trunk/sight/examples/org/jboss/sight/ListProcesses.java
===================================================================
--- trunk/sight/examples/org/jboss/sight/ListProcesses.java 2007-09-28 09:03:39 UTC (rev 1056)
+++ trunk/sight/examples/org/jboss/sight/ListProcesses.java 2007-09-28 12:12:16 UTC (rev 1057)
@@ -46,7 +46,8 @@
p.State + " : " + p.BaseName +
" User(" + u.Name + ") Group(" +
g.Name +")" + "\t " +
- p.CurrentWorkingDirectory);
+ p.CurrentWorkingDirectory + "\t" +
+ p.Arguments[0]);
}
} catch (Exception e) {
e.printStackTrace();
17 years, 2 months
JBoss Native SVN: r1056 - in trunk/sight/native: share and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-28 05:03:39 -0400 (Fri, 28 Sep 2007)
New Revision: 1056
Modified:
trunk/sight/native/os/windows/service.c
trunk/sight/native/share/dir.c
Log:
Add more refcounts
Modified: trunk/sight/native/os/windows/service.c
===================================================================
--- trunk/sight/native/os/windows/service.c 2007-09-28 08:26:55 UTC (rev 1055)
+++ trunk/sight/native/os/windows/service.c 2007-09-28 09:03:39 UTC (rev 1056)
@@ -356,7 +356,7 @@
return APR_EINVAL;
}
hsvc = no->native;
-
+ SIGHT_NO_IREF(no);
if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
buf, sizeof(buf), &cbBytesNeeded)) {
rc = GetLastError();
@@ -398,6 +398,7 @@
CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
cleanup:
+ SIGHT_NO_DREF(no);
return APR_FROM_OS_ERROR(rc);
}
@@ -425,6 +426,7 @@
return APR_EINVAL;
}
hsvc = no->native;
+ SIGHT_NO_IREF(no);
if (!QueryServiceStatusEx(hsvc, SC_STATUS_PROCESS_INFO,
buf, sizeof(buf), &cbBytesNeeded)) {
@@ -439,12 +441,14 @@
cb.msig = "(I)I";
cb.object = progress;
cb.method = (*_E)->GetMethodID(_E, c, cb.name, cb.msig);
- if (!cb.method || (*_E)->ExceptionCheck(_E)) {
- return APR_EINVAL;
+ if (!cb.method || (*_E)->ExceptionCheck(_E)) {
+ rc = EINVAL;
+ goto cleanup;
}
cres = (*_E)->CallIntMethod(_E, cb.object, cb.method, tick, NULL);
if ((*_E)->ExceptionCheck(_E)) {
- return APR_FROM_OS_ERROR(EINTR);
+ rc = EINTR;
+ goto cleanup;
}
if (timeout > 0) {
timeout_value = timeout * 1000L;
@@ -490,5 +494,6 @@
CALL_METHOD1(0000, thiz, lpStatus->dwCurrentState);
cleanup:
+ SIGHT_NO_DREF(no);
return APR_FROM_OS_ERROR(rc);
}
Modified: trunk/sight/native/share/dir.c
===================================================================
--- trunk/sight/native/share/dir.c 2007-09-28 08:26:55 UTC (rev 1055)
+++ trunk/sight/native/share/dir.c 2007-09-28 09:03:39 UTC (rev 1056)
@@ -279,10 +279,12 @@
}
else
d = (apr_dir_t *)no->native;
+ SIGHT_NO_IREF(no);
if (recursive)
len = calc_size_r((apr_dir_t *)no->native, J2S(path), no->pool);
else
len = calc_size_d((apr_dir_t *)no->native);
+ SIGHT_NO_DREF(no);
cleanup:
SIGHT_FREE_CSTRING(path);
SIGHT_GLOBAL_CLEANUP();
17 years, 2 months
JBoss Native SVN: r1055 - trunk/sight/native/os/windows.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-28 04:26:55 -0400 (Fri, 28 Sep 2007)
New Revision: 1055
Modified:
trunk/sight/native/os/windows/process.c
Log:
Opps. Rollback
Modified: trunk/sight/native/os/windows/process.c
===================================================================
--- trunk/sight/native/os/windows/process.c 2007-09-28 08:26:03 UTC (rev 1054)
+++ trunk/sight/native/os/windows/process.c 2007-09-28 08:26:55 UTC (rev 1055)
@@ -482,7 +482,7 @@
LPWSTR cmdl;
int pargc;
LPWSTR *pargs;
- printf("Process SELF!!!\n");
+
if ((env = GetEnvironmentStringsW())) {
SET_IFIELD_O(0004, thiz, sight_mw_to_sa(_E, env));
FreeEnvironmentStrings(env);
17 years, 2 months
JBoss Native SVN: r1054 - in trunk/sight/native: os/windows and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-28 04:26:03 -0400 (Fri, 28 Sep 2007)
New Revision: 1054
Modified:
trunk/sight/native/include/sight_types.h
trunk/sight/native/os/windows/process.c
Log:
Fix JBNATIVE-38 by adding reference counter for long running native ops.
Modified: trunk/sight/native/include/sight_types.h
===================================================================
--- trunk/sight/native/include/sight_types.h 2007-09-28 08:25:49 UTC (rev 1053)
+++ trunk/sight/native/include/sight_types.h 2007-09-28 08:26:03 UTC (rev 1054)
@@ -110,6 +110,7 @@
/* org.jboss.sight.NativeObject instance */
struct sight_object_t {
+ volatile apr_uint32_t references;
apr_pool_t *pool;
void *native;
void *opaque;
@@ -119,6 +120,9 @@
void (*clean)(int, sight_object_t *);
};
+#define SIGHT_NO_IREF(N) apr_atomic_inc32(&((N)->references))
+#define SIGHT_NO_DREF(N) apr_atomic_dec32(&((N)->references))
+
#define CACHE_HASH_MASK 255
#define CACHE_HASH_SIZE 256
Modified: trunk/sight/native/os/windows/process.c
===================================================================
--- trunk/sight/native/os/windows/process.c 2007-09-28 08:25:49 UTC (rev 1053)
+++ trunk/sight/native/os/windows/process.c 2007-09-28 08:26:03 UTC (rev 1054)
@@ -482,6 +482,7 @@
LPWSTR cmdl;
int pargc;
LPWSTR *pargs;
+ printf("Process SELF!!!\n");
if ((env = GetEnvironmentStringsW())) {
SET_IFIELD_O(0004, thiz, sight_mw_to_sa(_E, env));
FreeEnvironmentStrings(env);
17 years, 2 months