remove resource_limit.ulimited, switch to ResourceLimit.INFINITY

This commit is contained in:
Doug MacEachern 2005-07-21 23:34:36 +00:00
parent 76260ce6f3
commit 56aa4553f5
5 changed files with 26 additions and 19 deletions

View File

@ -803,9 +803,6 @@ my %classes = (
}, },
], ],
ResourceLimit => [ ResourceLimit => [
{
name => 'unlimited',
},
{ {
name => 'cpu_cur', name => 'cpu_cur',
}, },
@ -1143,6 +1140,9 @@ EOF
(this.free / 1024) + "K free, " + (this.free / 1024) + "K free, " +
(this.shared / 1024) + "K shrd"; (this.shared / 1024) + "K shrd";
} }
EOF
ResourceLimit => <<'EOF',
public static native long INFINITY();
EOF EOF
Swap => <<'EOF', Swap => <<'EOF',
public String toString() { public String toString() {

View File

@ -1248,3 +1248,14 @@ JNIEXPORT jlong SIGAR_JNI(Sigar_getServicePid)
return 0; return 0;
#endif #endif
} }
JNIEXPORT jlong SIGAR_JNI(ResourceLimit_INFINITY)
(JNIEnv *env, jclass cls)
{
#ifdef WIN32
return 0x7fffffff;
#else
#include <sys/resource.h>
return RLIM_INFINITY;
#endif
}

View File

@ -20,8 +20,8 @@ public class Ulimit extends SigarCommandBase {
return "Display system resource limits"; return "Display system resource limits";
} }
private static String format(ResourceLimit rlimit, long val) { private static String format(long val) {
if (val == rlimit.getUnlimited()) { if (val == ResourceLimit.INFINITY()) {
return "unlimited"; return "unlimited";
} }
else { else {
@ -33,23 +33,23 @@ public class Ulimit extends SigarCommandBase {
ResourceLimit rlimit = this.sigar.getResourceLimit(); ResourceLimit rlimit = this.sigar.getResourceLimit();
println("core file size......." + println("core file size......." +
format(rlimit, rlimit.getCoreCur())); format(rlimit.getCoreCur()));
println("data seg size........" + println("data seg size........" +
format(rlimit, rlimit.getDataCur())); format(rlimit.getDataCur()));
println("file size............" + println("file size............" +
format(rlimit, rlimit.getFileSizeCur())); format(rlimit.getFileSizeCur()));
println("max memory size......" + println("max memory size......" +
format(rlimit, rlimit.getMemoryCur())); format(rlimit.getMemoryCur()));
println("open files..........." + println("open files..........." +
format(rlimit, rlimit.getOpenFilesCur())); format(rlimit.getOpenFilesCur()));
println("stack size..........." + println("stack size..........." +
format(rlimit, rlimit.getStackCur())); format(rlimit.getStackCur()));
println("cpu time............." + println("cpu time............." +
format(rlimit, rlimit.getCpuCur())); format(rlimit.getCpuCur()));
println("max user processes..." + println("max user processes..." +
format(rlimit, rlimit.getProcessesCur())); format(rlimit.getProcessesCur()));
println("virual memory........" + println("virual memory........" +
format(rlimit, rlimit.getVirtualMemoryCur())); format(rlimit.getVirtualMemoryCur()));
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -182,8 +182,6 @@ typedef struct {
sigar_uint64_t open_files_cur, open_files_max; sigar_uint64_t open_files_cur, open_files_max;
/* RLIMIT_AS */ /* RLIMIT_AS */
sigar_uint64_t virtual_memory_cur, virtual_memory_max; sigar_uint64_t virtual_memory_cur, virtual_memory_max;
/* RLIM_INFINITY */
sigar_uint64_t unlimited;
} sigar_resource_limit_t; } sigar_resource_limit_t;
SIGAR_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar, SIGAR_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar,

View File

@ -754,7 +754,7 @@ SIGAR_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar,
sigar_resource_limit_t *rlimit) sigar_resource_limit_t *rlimit)
{ {
MEMORY_BASIC_INFORMATION meminfo; MEMORY_BASIC_INFORMATION meminfo;
memset(rlimit, -1, sizeof(*rlimit)); memset(rlimit, 0x7fffffff, sizeof(*rlimit));
if (VirtualQuery((LPCVOID)&meminfo, &meminfo, sizeof(meminfo))) { if (VirtualQuery((LPCVOID)&meminfo, &meminfo, sizeof(meminfo))) {
rlimit->stack_cur = rlimit->stack_cur =
@ -971,8 +971,6 @@ int sigar_resource_limit_get(sigar_t *sigar,
{ {
int i; int i;
rlimit->unlimited = RLIM_INFINITY;
for (i=0; sigar_rlimits[i].resource != -1; i++) { for (i=0; sigar_rlimits[i].resource != -1; i++) {
struct rlimit rl; struct rlimit rl;
rlimit_field_t *r = &sigar_rlimits[i]; rlimit_field_t *r = &sigar_rlimits[i];