change rpc_ping to return the status code
This commit is contained in:
1 parent
8342b063de
commit
f0cdd946c5
4 files changed
+28
-27
No files matched your search
@@ -410,7 +410,7 @@ JNIEXPORT jobjectArray SIGAR_JNI(Sigar_getFileSystemListNative)
|
||||
return fsarray;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean SIGAR_JNI(RPC_ping)
|
||||
JNIEXPORT jint SIGAR_JNI(RPC_ping)
|
||||
(JNIEnv *env, jclass cls_obj, jstring jhostname,
|
||||
jint protocol, jlong program, jlong version)
|
||||
{
|
||||
@@ -419,23 +419,23 @@ JNIEXPORT jboolean SIGAR_JNI(RPC_ping)
|
||||
#else
|
||||
jboolean is_copy;
|
||||
const char *hostname;
|
||||
jboolean retval;
|
||||
int status;
|
||||
|
||||
if (!jhostname) {
|
||||
return JNI_FALSE;
|
||||
return 13; /* RPC_UNKNOWNHOST */
|
||||
}
|
||||
|
||||
hostname = JENV->GetStringUTFChars(env, jhostname, &is_copy);
|
||||
|
||||
retval =
|
||||
(sigar_rpc_ping((char *)hostname,
|
||||
protocol, program, version) == SIGAR_OK);
|
||||
status =
|
||||
sigar_rpc_ping((char *)hostname,
|
||||
protocol, program, version);
|
||||
|
||||
if (is_copy) {
|
||||
JENV->ReleaseStringUTFChars(env, jhostname, hostname);
|
||||
}
|
||||
|
||||
return retval;
|
||||
return status;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class NfsFileSystem extends FileSystem {
|
||||
}
|
||||
|
||||
public boolean ping() {
|
||||
return RPC.ping(getHostname(), NFS_PROGRAM);
|
||||
return RPC.ping(getHostname(), NFS_PROGRAM) == 0;
|
||||
}
|
||||
|
||||
public String getUnreachableMessage() {
|
||||
|
||||
@@ -11,26 +11,26 @@ public class RPC {
|
||||
public static final int UDP = NetFlags.CONN_UDP;
|
||||
public static final int TCP = NetFlags.CONN_TCP;
|
||||
|
||||
public static native boolean ping(String hostname,
|
||||
int protocol,
|
||||
long program,
|
||||
long version);
|
||||
public static native int ping(String hostname,
|
||||
int protocol,
|
||||
long program,
|
||||
long version);
|
||||
|
||||
public static boolean ping(String hostname,
|
||||
int protocol,
|
||||
String program,
|
||||
long version) {
|
||||
public static int ping(String hostname,
|
||||
int protocol,
|
||||
String program,
|
||||
long version) {
|
||||
return ping(hostname,
|
||||
protocol,
|
||||
getProgram(program),
|
||||
version);
|
||||
}
|
||||
|
||||
public static boolean ping(String hostname, long program) {
|
||||
public static int ping(String hostname, long program) {
|
||||
return ping(hostname, UDP, program, 2);
|
||||
}
|
||||
|
||||
public static boolean ping(String hostname, String program) {
|
||||
public static int ping(String hostname, String program) {
|
||||
return ping(hostname, UDP, program, 2);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user