JBoss Native SVN: r1130 - trunk/sight/native/os/solaris.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-10-17 16:30:12 -0400 (Wed, 17 Oct 2007)
New Revision: 1130
Modified:
trunk/sight/native/os/solaris/process.c
Log:
Arrange handling of special process (argc=0 and envn=0).
Modified: trunk/sight/native/os/solaris/process.c
===================================================================
--- trunk/sight/native/os/solaris/process.c 2007-10-17 16:27:07 UTC (rev 1129)
+++ trunk/sight/native/os/solaris/process.c 2007-10-17 20:30:12 UTC (rev 1130)
@@ -345,90 +345,99 @@
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();
- }
+ if (psinfo.pr_argc !=0) {
+ 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, (off_t) sa[n], SEEK_SET) != -1) {
- if (read(fd, pname, SIGHT_STYPE_LEN) > 0) {
- s = CSTR_TO_JSTRING(pname);
- if (s) {
- (*_E)->SetObjectArrayElement(_E, arr, n, s);
- (*_E)->DeleteLocalRef(_E, s);
+ 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, (off_t) sa[n], SEEK_SET) != -1) {
+ if (read(fd, pname, SIGHT_STYPE_LEN) > 0) {
+ s = CSTR_TO_JSTRING(pname);
+ if (s) {
+ (*_E)->SetObjectArrayElement(_E, arr, n, s);
+ (*_E)->DeleteLocalRef(_E, s);
+ }
+ continue;
}
- continue;
}
+ s = CSTR_TO_JSTRING("");
+ if (s) {
+ (*_E)->SetObjectArrayElement(_E, arr, n, s);
+ (*_E)->DeleteLocalRef(_E, s);
+ }
}
- s = CSTR_TO_JSTRING("");
- if (s) {
- (*_E)->SetObjectArrayElement(_E, arr, n, s);
- (*_E)->DeleteLocalRef(_E, s);
- }
+
+ SET_IFIELD_O(0003, thiz, arr);
+ free(sa);
}
-
- 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) {
+ if (psinfo.pr_envp !=0) {
+ if (lseek(fd, psinfo.pr_envp, SEEK_SET) == -1) {
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, (off_t) sa[n], SEEK_SET) != -1) {
- if (read(fd, pname, SIGHT_STYPE_LEN) > 0) {
- s = CSTR_TO_JSTRING(pname);
- if (s) {
- (*_E)->SetObjectArrayElement(_E, arr, n, s);
- (*_E)->DeleteLocalRef(_E, s);
+ /* 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();
+ }
+ } else
+ count = 1; /* no argumentts */
+
+ /* The last argument is NULL */
+ if (count-1 != 0) {
+ 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, (off_t) sa[n], SEEK_SET) != -1) {
+ if (read(fd, pname, SIGHT_STYPE_LEN) > 0) {
+ s = CSTR_TO_JSTRING(pname);
+ if (s) {
+ (*_E)->SetObjectArrayElement(_E, arr, n, s);
+ (*_E)->DeleteLocalRef(_E, s);
+ }
+ continue;
}
- continue;
}
+ s = CSTR_TO_JSTRING("");
+ if (s) {
+ (*_E)->SetObjectArrayElement(_E, arr, n, s);
+ (*_E)->DeleteLocalRef(_E, s);
+ }
}
- s = CSTR_TO_JSTRING("");
- if (s) {
- (*_E)->SetObjectArrayElement(_E, arr, n, s);
- (*_E)->DeleteLocalRef(_E, s);
- }
- }
- SET_IFIELD_O(0004, thiz, arr);
+ SET_IFIELD_O(0004, thiz, arr);
+ }
free(sa);
close(fd);
} else {
17 years, 2 months
JBoss Native SVN: r1129 - trunk/sight/native/os/solaris.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-10-17 12:27:07 -0400 (Wed, 17 Oct 2007)
New Revision: 1129
Modified:
trunk/sight/native/os/solaris/process.c
Log:
Arrange warning.
Modified: trunk/sight/native/os/solaris/process.c
===================================================================
--- trunk/sight/native/os/solaris/process.c 2007-10-17 16:04:59 UTC (rev 1128)
+++ trunk/sight/native/os/solaris/process.c 2007-10-17 16:27:07 UTC (rev 1129)
@@ -34,6 +34,7 @@
#include "sight_local.h"
#include "sight_types.h"
+#include <unistd.h>
#include <procfs.h>
/*
@@ -251,7 +252,7 @@
UNREFERENCED_O;
- if ((rc = sight_create_pool(&pool, sight_temp_pool)) != APR_SUCCESS) {
+ if ((rc = sight_pool_create(&pool, NULL, sight_temp_pool, 0)) != APR_SUCCESS) {
throwAprMemoryException(_E, THROW_FMARK, rc);
return NULL;
@@ -360,7 +361,7 @@
pname[SIGHT_STYPE_LEN] = '\0';
for (n = 0; n < psinfo.pr_argc; n++) {
jstring s;
- if (lseek(fd, sa[n], SEEK_SET) != -1) {
+ if (lseek(fd, (off_t) sa[n], SEEK_SET) != -1) {
if (read(fd, pname, SIGHT_STYPE_LEN) > 0) {
s = CSTR_TO_JSTRING(pname);
if (s) {
@@ -410,7 +411,7 @@
pname[SIGHT_STYPE_LEN] = '\0';
for (n = 0; n < count-1; n++) {
jstring s;
- if (lseek(fd, sa[n], SEEK_SET) != -1) {
+ if (lseek(fd, (off_t) sa[n], SEEK_SET) != -1) {
if (read(fd, pname, SIGHT_STYPE_LEN) > 0) {
s = CSTR_TO_JSTRING(pname);
if (s) {
17 years, 2 months
JBoss Native SVN: r1128 - trunk/sight/native/os/solaris.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-10-17 12:04:59 -0400 (Wed, 17 Oct 2007)
New Revision: 1128
Modified:
trunk/sight/native/os/solaris/volume.c
Log:
Use the pool instead malloc.
Modified: trunk/sight/native/os/solaris/volume.c
===================================================================
--- trunk/sight/native/os/solaris/volume.c 2007-10-17 15:11:46 UTC (rev 1127)
+++ trunk/sight/native/os/solaris/volume.c 2007-10-17 16:04:59 UTC (rev 1128)
@@ -32,6 +32,8 @@
#define SIGHT_WANT_LATE_DLL
#include "sight_private.h"
+#include <unistd.h>
+
#include <sys/mnttab.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
@@ -182,7 +184,7 @@
THROW_FMARK))) {
return 0;
}
- if ((rc = sight_create_pool(&e->pool, sight_temp_pool)) != APR_SUCCESS) {
+ if ((rc = sight_pool_create(&e->pool, NULL, sight_temp_pool, 0)) != APR_SUCCESS) {
throwAprMemoryException(_E, THROW_FMARK, rc);
return 0;
}
@@ -239,8 +241,8 @@
/* 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);
+ e->swap_table = apr_palloc(e->pool, sizeof(swapent_t) * e->num_swap + sizeof(int));
+ buf = apr_palloc(e->pool, MAXSTRSIZE * e->num_swap);
for (i = 0; i < e->num_swap; i++) {
e->swap_table->swt_ent[i].ste_path = buf + (i * MAXSTRSIZE);
}
17 years, 2 months
JBoss Native SVN: r1127 - trunk/sight/native/os/solaris.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-10-17 11:11:46 -0400 (Wed, 17 Oct 2007)
New Revision: 1127
Modified:
trunk/sight/native/os/solaris/tcpstat.c
Log:
Fix warnings.
Modified: trunk/sight/native/os/solaris/tcpstat.c
===================================================================
--- trunk/sight/native/os/solaris/tcpstat.c 2007-10-17 15:08:17 UTC (rev 1126)
+++ trunk/sight/native/os/solaris/tcpstat.c 2007-10-17 15:11:46 UTC (rev 1127)
@@ -32,6 +32,13 @@
#define SIGHT_WANT_LATE_DLL
#include "sight_private.h"
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
#include <stropts.h>
#include <sys/tihdr.h>
@@ -292,7 +299,7 @@
return;
}
e->type = iftype;
- read_mib2(_E, e, pool);
+ read_mib2(_E, e, lpool);
if (e->stat != NULL) {
mib2_tcp_t *tcp = (mib2_tcp_t *)e->stat;
17 years, 2 months
JBoss Native SVN: r1126 - trunk/sight/native/os/solaris.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-10-17 11:08:17 -0400 (Wed, 17 Oct 2007)
New Revision: 1126
Modified:
trunk/sight/native/os/solaris/udpstat.c
Log:
Use pool instead malloc add cleanup.
Modified: trunk/sight/native/os/solaris/udpstat.c
===================================================================
--- trunk/sight/native/os/solaris/udpstat.c 2007-10-17 15:07:37 UTC (rev 1125)
+++ trunk/sight/native/os/solaris/udpstat.c 2007-10-17 15:08:17 UTC (rev 1126)
@@ -32,6 +32,13 @@
#define SIGHT_WANT_LATE_DLL
#include "sight_private.h"
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
#include <stropts.h>
#include <sys/tihdr.h>
@@ -119,7 +126,7 @@
} tcpconn_enum_t;
/* Read the mib2 object and fill the structures */
-static void read_mib2(JNIEnv *_E, tcpconn_enum_t *e)
+static void read_mib2(JNIEnv *_E, tcpconn_enum_t *e, apr_pool_t* pool)
{
apr_status_t rc = APR_ENOTIMPL;
int sd;
@@ -180,7 +187,7 @@
/* read the data */
databuf.maxlen = req->len;
- databuf.buf = malloc((int)req->len);
+ databuf.buf = apr_palloc(pool, (int)req->len);
databuf.len = 0;
flags = 0;
if (getmsg(sd, (struct strbuf *)0, &databuf, &flags) == -1) {
@@ -231,13 +238,14 @@
jlong pool)
{
tcpconn_enum_t *e;
+ apr_pool_t* lpool = (apr_pool_t *) pool;
if (!(e = (tcpconn_enum_t *)sight_calloc(_E,
sizeof(tcpconn_enum_t),
THROW_FMARK))) {
return;
}
e->type = iftype;
- read_mib2(_E, e);
+ read_mib2(_E, e, lpool);
if (e->stat != NULL) {
mib2_udp_t *udp = (mib2_udp_t *)e->stat;
@@ -274,7 +282,7 @@
return 0;
}
e->type = iftype;
- read_mib2(_E, e);
+ read_mib2(_E, e, e->pool);
return P2J(e);
}
@@ -356,5 +364,11 @@
SIGHT_EXPORT_DECLARE(void, UdpStatistics, enum3)(SIGHT_STDARGS,
jlong handle)
{
+ tcpconn_enum_t *e = J2P(handle, tcpconn_enum_t *);
+
UNREFERENCED_STDARGS;
+ if (e) {
+ apr_pool_destroy(e->pool);
+ free(e);
+ }
}
17 years, 2 months
JBoss Native SVN: r1125 - trunk/sight/native/os/solaris.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-10-17 11:07:37 -0400 (Wed, 17 Oct 2007)
New Revision: 1125
Modified:
trunk/sight/native/os/solaris/tcpstat.c
Log:
Use pool instead malloc add cleanup.
Modified: trunk/sight/native/os/solaris/tcpstat.c
===================================================================
--- trunk/sight/native/os/solaris/tcpstat.c 2007-10-17 14:39:40 UTC (rev 1124)
+++ trunk/sight/native/os/solaris/tcpstat.c 2007-10-17 15:07:37 UTC (rev 1125)
@@ -173,7 +173,7 @@
} tcpconn_enum_t;
/* Read the mib2 object and fill the structures */
-static void read_mib2(JNIEnv *_E, tcpconn_enum_t *e)
+static void read_mib2(JNIEnv *_E, tcpconn_enum_t *e, apr_pool_t* pool)
{
apr_status_t rc = APR_ENOTIMPL;
int sd;
@@ -234,7 +234,7 @@
/* read the data */
databuf.maxlen = req->len;
- databuf.buf = malloc((int)req->len);
+ databuf.buf = apr_palloc(pool, (int)req->len);
databuf.len = 0;
flags = 0;
if (getmsg(sd, (struct strbuf *)0, &databuf, &flags) == -1) {
@@ -285,13 +285,14 @@
jlong pool)
{
tcpconn_enum_t *e;
+ apr_pool_t* lpool = (apr_pool_t *) pool;
if (!(e = (tcpconn_enum_t *)sight_calloc(_E,
sizeof(tcpconn_enum_t),
THROW_FMARK))) {
return;
}
e->type = iftype;
- read_mib2(_E, e);
+ read_mib2(_E, e, pool);
if (e->stat != NULL) {
mib2_tcp_t *tcp = (mib2_tcp_t *)e->stat;
@@ -338,7 +339,7 @@
return 0;
}
e->type = iftype;
- read_mib2(_E, e);
+ read_mib2(_E, e, e->pool);
return P2J(e);
}
@@ -420,5 +421,11 @@
SIGHT_EXPORT_DECLARE(void, TcpStatistics, enum3)(SIGHT_STDARGS,
jlong handle)
{
- /* XXX: Add cleanup */
+ tcpconn_enum_t *e = J2P(handle, tcpconn_enum_t *);
+
+ UNREFERENCED_STDARGS;
+ if (e) {
+ apr_pool_destroy(e->pool);
+ free(e);
+ }
}
17 years, 2 months
JBoss Native SVN: r1124 - trunk/sight/native/os/solaris.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-10-17 10:39:40 -0400 (Wed, 17 Oct 2007)
New Revision: 1124
Modified:
trunk/sight/native/os/solaris/udpstat.c
Log:
Typos.
Modified: trunk/sight/native/os/solaris/udpstat.c
===================================================================
--- trunk/sight/native/os/solaris/udpstat.c 2007-10-17 14:17:14 UTC (rev 1123)
+++ trunk/sight/native/os/solaris/udpstat.c 2007-10-17 14:39:40 UTC (rev 1124)
@@ -195,7 +195,7 @@
e->stat = (void *) databuf.buf;
} else if (req->level == MIB2_UDP && req->name == MIB2_UDP_ENTRY && e->type == 1) {
/* Process the UDP statics */
- mib2_udpEntry *tcp = (mib2_udpEntry *)databuf.buf;
+ mib2_udpEntry_t *tcp = (mib2_udpEntry_t *)databuf.buf;
char *end;
int numcons = 0;
end = (char*) tcp + databuf.len;
@@ -207,7 +207,7 @@
e->numcons = numcons;
} else if (req->level == MIB2_UDP6 && req->name == MIB2_UDP6_ENTRY && e->type == 2) {
/* Process the UDP6 statics */
- mib2_udp6Entry *tcp = (mib2_udp6Entry *)databuf.buf;
+ mib2_udp6Entry_t *tcp = (mib2_udp6Entry_t *)databuf.buf;
char *end;
int numcons = 0;
end = (char*) tcp + databuf.len;
@@ -311,7 +311,7 @@
return;
}
if (e->type == 1) {
- mib2_udpEntry *tcp = (mib2_udpEntry *) e->conn;
+ mib2_udpEntry_t *tcp = (mib2_udpEntry_t *) e->conn;
int i;
for (i=1; i<e->idx; i++)
tcp++;
17 years, 2 months
JBoss Native SVN: r1123 - trunk/sight/native/os/solaris.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2007-10-17 10:17:14 -0400 (Wed, 17 Oct 2007)
New Revision: 1123
Modified:
trunk/sight/native/os/solaris/udpstat.c
Log:
Add the logic for udp entries.
Modified: trunk/sight/native/os/solaris/udpstat.c
===================================================================
--- trunk/sight/native/os/solaris/udpstat.c 2007-10-17 14:08:40 UTC (rev 1122)
+++ trunk/sight/native/os/solaris/udpstat.c 2007-10-17 14:17:14 UTC (rev 1123)
@@ -107,11 +107,19 @@
static const char *eiftype = "Unsupported NetworkAddressFamily type";
-/* Initialize volume enumeration */
-SIGHT_EXPORT_DECLARE(void, UdpStatistics, info0)(SIGHT_STDARGS,
- jobject thiz,
- jint iftype,
- jlong pool)
+extern apr_pool_t *sight_temp_pool;
+
+typedef struct tcpconn_enum_t {
+ int type;
+ int idx;
+ int numcons;
+ void *conn; /* mib2_tcp6ConnEntry_t / mib2_tcpConnEntry_t */
+ void *stat; /* mib2_tcp_t */
+ apr_pool_t *pool;
+} tcpconn_enum_t;
+
+/* Read the mib2 object and fill the structures */
+static void read_mib2(JNIEnv *_E, tcpconn_enum_t *e)
{
apr_status_t rc = APR_ENOTIMPL;
int sd;
@@ -119,17 +127,23 @@
int flags;
int i, j, getcode;
struct strbuf ctlbuf, databuf;
+
struct T_optmgmt_req *tor = (struct T_optmgmt_req *)buf;
struct T_optmgmt_ack *toa = (struct T_optmgmt_ack *)buf;
struct T_error_ack *tea = (struct T_error_ack *)buf;
+
struct opthdr *req;
- mib_item_t *last_item = NULL;
+ int numcons = 0;
- UNREFERENCED_O;
-
- if ((sd = open("/dev/udp", O_RDWR)) < 0) {
+ if ((sd = open("/dev/arp", O_RDWR)) < 0) {
throwAprException(_E, apr_get_os_error());
+ return;
}
+ if (ioctl(sd, I_PUSH, "udp") <0) {
+ close(sd);
+ throwAprException(_E, apr_get_os_error());
+ return;
+ }
tor->PRIM_type = T_SVR4_OPTMGMT_REQ;
tor->OPT_offset = sizeof (struct T_optmgmt_req);
@@ -146,76 +160,137 @@
if (putmsg(sd, &ctlbuf, (struct strbuf *)0, flags) == -1) {
close(sd);
throwAprException(_E, apr_get_os_error());
+ return;
}
- req = (struct opthdr *)&toa[1];
- ctlbuf.maxlen = sizeof (buf);
- flags = 0;
- if (getmsg(sd, &ctlbuf, (struct strbuf *)0, &flags) == -1) {
- close(sd);
- throwAprException(_E, apr_get_os_error());
- }
+ for(;;) {
+ req = (struct opthdr *)&toa[1];
+ ctlbuf.buf = (char *) buf;
+ ctlbuf.maxlen = sizeof (buf);
+ flags = 0;
+ if (getmsg(sd, &ctlbuf, (struct strbuf *)0, &flags) == -1) {
+ close(sd);
+ throwAprException(_E, apr_get_os_error());
+ return;
+ }
+ if (toa->PRIM_type == T_OPTMGMT_ACK &&
+ toa->MGMT_flags == T_SUCCESS &&
+ req->len == 0)
+ break; /* done */
- last_item = (mib_item_t *)malloc(sizeof (mib_item_t));;
- last_item->next_item = NULL;
- last_item->group = req->level;
- last_item->mib_id = req->name;
- last_item->length = req->len;
- last_item->valp = malloc((int)req->len);
+ /* read the data */
+ databuf.maxlen = req->len;
+ databuf.buf = malloc((int)req->len);
+ databuf.len = 0;
+ flags = 0;
+ if (getmsg(sd, (struct strbuf *)0, &databuf, &flags) == -1) {
+ close(sd);
+ throwAprException(_E, apr_get_os_error());
+ return;
+ }
- databuf.maxlen = last_item->length;
- databuf.buf = (char *)last_item->valp;
- databuf.len = 0;
- flags = 0;
- if (getmsg(sd, (struct strbuf *)0, &databuf, &flags) == -1) {
- close(sd);
- throwAprException(_E, apr_get_os_error());
+ /* Process the TPC statics */
+ if ((req->level == MIB2_UDP && req->name == 0 && e->type == 1) ||
+ (req->level == MIB2_UDP6 && req->name == 0 && e->type == 2)) {
+ e->stat = (void *) databuf.buf;
+ } else if (req->level == MIB2_UDP && req->name == MIB2_UDP_ENTRY && e->type == 1) {
+ /* Process the UDP statics */
+ mib2_udpEntry *tcp = (mib2_udpEntry *)databuf.buf;
+ char *end;
+ int numcons = 0;
+ end = (char*) tcp + databuf.len;
+ while ((char*) tcp < end) {
+ numcons++;
+ tcp++;
+ }
+ e->conn = (void *) databuf.buf;
+ e->numcons = numcons;
+ } else if (req->level == MIB2_UDP6 && req->name == MIB2_UDP6_ENTRY && e->type == 2) {
+ /* Process the UDP6 statics */
+ mib2_udp6Entry *tcp = (mib2_udp6Entry *)databuf.buf;
+ char *end;
+ int numcons = 0;
+ end = (char*) tcp + databuf.len;
+ while ((char*) tcp < end) {
+ numcons++;
+ tcp++;
+ }
+ e->conn = (void *) databuf.buf;
+ e->numcons = numcons;
+ } /* else {
+ printf("Missing logic info0: level %d name %d\n", req->level, req->name);
+ } */
}
close(sd);
+}
- for (; last_item; last_item = last_item->next_item) {
- if (last_item->group == MIB2_UDP) {
- mib2_udp_t *udp = (mib2_udp_t *)last_item->valp;
- SET_IFIELD_I(0000, thiz, udp->udpInDatagrams);
- /* XXX: SET_IFIELD_I(0001, thiz, NoPorts); */
- SET_IFIELD_I(0002, thiz, udp->udpInErrors);
- SET_IFIELD_I(0003, thiz, udp->udpOutDatagrams);
- /* XXX: SET_IFIELD_I(0004, thiz, s.dwNumAddrs); */
+/* Initialize volume enumeration */
+SIGHT_EXPORT_DECLARE(void, UdpStatistics, info0)(SIGHT_STDARGS,
+ jobject thiz,
+ jint iftype,
+ jlong pool)
+{
+ tcpconn_enum_t *e;
+ if (!(e = (tcpconn_enum_t *)sight_calloc(_E,
+ sizeof(tcpconn_enum_t),
+ THROW_FMARK))) {
+ return;
+ }
+ e->type = iftype;
+ read_mib2(_E, e);
- }
+ if (e->stat != NULL) {
+ mib2_udp_t *udp = (mib2_udp_t *)e->stat;
+ SET_IFIELD_I(0000, thiz, udp->udpInDatagrams);
+ /* XXX: SET_IFIELD_I(0001, thiz, NoPorts); */
+ SET_IFIELD_I(0002, thiz, udp->udpInErrors);
+ SET_IFIELD_I(0003, thiz, udp->udpOutDatagrams);
+
}
+ SET_IFIELD_I(0004, thiz, e->numcons);
}
SIGHT_EXPORT_DECLARE(jlong, UdpStatistics, enum0)(SIGHT_STDARGS,
jint iftype,
jlong pool)
{
- apr_status_t rc = APR_ENOTIMPL;
+ tcpconn_enum_t *e;
+ apr_status_t rc;
+
UNREFERENCED_O;
- if (iftype == 1) {
- /* AF_INET */
- rc = 0;
+ if (iftype < 1 || iftype > 2) {
+ throwOSException(_E, eiftype);
+ return 0;
}
- else if (iftype == 2) {
- /* AF_INET6 */
- rc = 0;
+ if (!(e = (tcpconn_enum_t *)sight_calloc(_E,
+ sizeof(tcpconn_enum_t),
+ THROW_FMARK))) {
+ return 0;
}
- else {
- throwOSException(_E, eiftype);
+
+ if ((rc = sight_pool_create(&e->pool, NULL, sight_temp_pool, 0)) != APR_SUCCESS) {
+ throwAprMemoryException(_E, THROW_FMARK, rc);
+ return 0;
}
- if (rc) {
- throwAprException(_E, APR_FROM_OS_ERROR(rc));
- return;
- }
+ e->type = iftype;
+ read_mib2(_E, e);
+
+ return P2J(e);
}
/* Get the number of entries */
SIGHT_EXPORT_DECLARE(jint, UdpStatistics, enum1)(SIGHT_STDARGS,
jlong handle)
{
+ tcpconn_enum_t *e = J2P(handle, tcpconn_enum_t *);
UNREFERENCED_STDARGS;
- return 0;
+ if (e) {
+ e->idx = 1;
+ return e->numcons;
+ } else {
+ return 0;
+ }
}
SIGHT_EXPORT_DECLARE(void, UdpStatistics, enum2)(SIGHT_STDARGS,
@@ -223,7 +298,58 @@
jint index,
jlong handle)
{
+ tcpconn_enum_t *e = J2P(handle, tcpconn_enum_t *);
+ char las[128] = "";
+ char ras[128] = "";
+ jobject la, ra;
+ jint lp = 0, rp = 0;
+ jint st;
+ if (!e)
+ return;
+ if (e->idx > e->numcons) {
+ return;
+ }
+ if (e->type == 1) {
+ mib2_udpEntry *tcp = (mib2_udpEntry *) e->conn;
+ int i;
+ for (i=1; i<e->idx; i++)
+ tcp++;
+ inet_ntop(AF_INET, &tcp->udpLocalAddress, las, 64);
+ inet_ntop(AF_INET, &tcp->udpEntryInfo.ue_RemoteAddress, ras, 64);
+ lp = tcp->udpLocalPort;
+ rp = tcp->udpEntryInfo.ue_RemotePort;
+ st = tcp->udpEntryInfo.ue_state;
+ } else {
+ mib2_udp6Entry_t *tcp = (mib2_udp6Entry_t *) e->conn;
+ int i;
+ for (i=1; i<e->idx; i++)
+ tcp++;
+ sight_inet_ntop6(tcp->udp6LocalAddress.s6_addr, las, 64);
+ sight_inet_ntop6(tcp->udp6EntryInfo.ue_RemoteAddress.s6_addr, ras, 64);
+ lp = tcp->udp6LocalPort;
+ rp = tcp->udp6EntryInfo.ue_RemotePort;
+ st = tcp->udp6EntryInfo.ue_state;
+ }
+ sight_tcpconn_set_tmo(_E, conn, 0);
+ sight_tcpconn_set_cts(_E, conn, 0);
+ sight_tcpconn_set_pid(_E, conn, 0);
+
+ sight_tcpconn_set_state(_E, conn, st);
+
+ la = sight_new_netaddr_class(_E, _O);
+ sight_netaddr_set_addr(_E, la, las);
+ sight_netaddr_set_port(_E, la, lp);
+ sight_tcpconn_set_local(_E, conn, la);
+ (*_E)->DeleteLocalRef(_E, la);
+
+ ra = sight_new_netaddr_class(_E, _O);
+ sight_netaddr_set_addr(_E, ra, ras);
+ sight_netaddr_set_port(_E, ra, rp);
+ sight_tcpconn_set_remote(_E, conn, ra);
+ (*_E)->DeleteLocalRef(_E, ra);
+
+ e->idx++;
}
/* Close TCP conn enumeration */
17 years, 2 months
JBoss Native SVN: r1122 - trunk/sight/native/os/windows.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-17 10:08:40 -0400 (Wed, 17 Oct 2007)
New Revision: 1122
Modified:
trunk/sight/native/os/windows/service.c
Log:
Fix invalid params object lock
Modified: trunk/sight/native/os/windows/service.c
===================================================================
--- trunk/sight/native/os/windows/service.c 2007-10-17 13:56:00 UTC (rev 1121)
+++ trunk/sight/native/os/windows/service.c 2007-10-17 14:08:40 UTC (rev 1122)
@@ -316,6 +316,7 @@
sc = SERVICE_CONTROL_INTERROGATE;
break;
case 5:
+ SIGHT_LOCAL_BRK(no);
return APR_EINVAL;
break;
case 6:
@@ -530,7 +531,7 @@
goto cleanup;
}
} while (lpStatus->dwCurrentState != (DWORD)state);
- setup:
+setup:
lpStatus = (LPSERVICE_STATUS_PROCESS)&buf[0];
SET_IFIELD_I(0007, thiz, lpStatus->dwWin32ExitCode);
SET_IFIELD_I(0008, thiz, lpStatus->dwServiceSpecificExitCode);
17 years, 2 months
JBoss Native SVN: r1121 - trunk/sight/native/os/windows.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-17 09:56:00 -0400 (Wed, 17 Oct 2007)
New Revision: 1121
Modified:
trunk/sight/native/os/windows/main.c
Log:
Make sure we call sight_main only once
Modified: trunk/sight/native/os/windows/main.c
===================================================================
--- trunk/sight/native/os/windows/main.c 2007-10-17 13:49:36 UTC (rev 1120)
+++ trunk/sight/native/os/windows/main.c 2007-10-17 13:56:00 UTC (rev 1121)
@@ -84,7 +84,8 @@
"jvm.dll"
};
-static HMODULE late_dll_handles[SYSDLL_defined] = { NULL, NULL, NULL, NULL };
+static HMODULE late_dll_handles[SYSDLL_defined] = { NULL, NULL, NULL,
+ NULL, NULL };
FARPROC sight_load_dll_func(sight_dlltoken_e fnLib, const char* fnName, int ordinal)
{
@@ -337,10 +338,16 @@
SIGHT_FREE_WSTRING(msg);
}
+static int main_called = 0;
+
apr_status_t sight_main(apr_pool_t *pool)
{
DWORD rc;
+ /* sight_main should be called only once per process */
+ if (main_called++)
+ return APR_SUCCESS;
+
GetSystemInfo(sight_osinf);
sight_osver->dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
GetVersionExA((LPOSVERSIONINFOA)sight_osver);
17 years, 2 months