mirror of https://github.com/BOINC/boinc.git
Merge branch 'master' of ssh://isaac.ssl.berkeley.edu/boinc-v2
This commit is contained in:
commit
289adcf6d8
|
@ -69,9 +69,9 @@
|
|||
<integer name="tasks_transistion_timeout_number_monitor_loops">15</integer>
|
||||
<!-- shutdown -->
|
||||
<integer name="shutdown_graceful_rpc_check_rate_ms">1000</integer>
|
||||
<integer name="shutdown_graceful_rpc_check_attempts">10</integer>
|
||||
<integer name="shutdown_graceful_rpc_check_attempts">5</integer>
|
||||
<integer name="shutdown_graceful_os_check_rate_ms">1000</integer>
|
||||
<integer name="shutdown_graceful_os_check_attempts">30</integer>
|
||||
<integer name="shutdown_graceful_os_check_attempts">5</integer>
|
||||
<!-- eventlog -->
|
||||
<integer name="eventlog_gui_messages">100</integer>
|
||||
<!-- preferences -->
|
||||
|
|
|
@ -31,15 +31,6 @@ public class ClientInterfaceImplementation extends RpcClient{
|
|||
private final Integer maxRetryDuration = 3000;
|
||||
// interval between polling retries in ms
|
||||
private final Integer minRetryInterval = 500;
|
||||
|
||||
/**
|
||||
* Establishes socket connection to BOINC client.
|
||||
* Requirement for information exchange via RPC
|
||||
* @return success
|
||||
*/
|
||||
public Boolean connect() {
|
||||
return open("127.0.0.1", 31416);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads authentication key from specified file path and authenticates GUI for advanced RPCs with the client
|
||||
|
|
|
@ -603,10 +603,11 @@ public class Monitor extends Service {
|
|||
private Boolean runClient() {
|
||||
Boolean success = false;
|
||||
try {
|
||||
String[] cmd = new String[2];
|
||||
String[] cmd = new String[3];
|
||||
|
||||
cmd[0] = boincWorkingDir + fileNameClient;
|
||||
cmd[1] = "--daemon";
|
||||
cmd[2] = "--gui_rpc_unix_domain";
|
||||
|
||||
Runtime.getRuntime().exec(cmd, null, new File(boincWorkingDir));
|
||||
success = true;
|
||||
|
@ -624,7 +625,7 @@ public class Monitor extends Service {
|
|||
private Boolean connectClient() {
|
||||
Boolean success = false;
|
||||
|
||||
success = clientInterface.connect();
|
||||
success = clientInterface.open();
|
||||
if(!success) {
|
||||
if(Logging.DEBUG) Log.d(Logging.TAG, "connection failed!");
|
||||
return success;
|
||||
|
|
|
@ -24,14 +24,14 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.StringReader;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import android.net.LocalSocket;
|
||||
import android.net.LocalSocketAddress;
|
||||
import android.util.Log;
|
||||
import android.util.Xml;
|
||||
import edu.berkeley.boinc.utils.BOINCDefs;
|
||||
|
@ -47,7 +47,6 @@ import edu.berkeley.boinc.utils.Logging;
|
|||
* get_cc_status() becomes getCcStatus() etc.
|
||||
*/
|
||||
public class RpcClient {
|
||||
private static final int CONNECT_TIMEOUT = 30000; // 30s
|
||||
private static final int READ_TIMEOUT = 15000; // 15s
|
||||
private static final int READ_BUF_SIZE = 2048;
|
||||
private static final int RESULT_BUILDER_INIT_SIZE = 131072; // Yes, 128K
|
||||
|
@ -75,7 +74,7 @@ public class RpcClient {
|
|||
public static final int MGR_DETACH = 30;
|
||||
public static final int MGR_SYNC = 31;
|
||||
|
||||
private Socket mSocket;
|
||||
private LocalSocket mSocket;
|
||||
private OutputStreamWriter mOutput;
|
||||
private InputStream mInput;
|
||||
private byte[] mReadBuffer = new byte[READ_BUF_SIZE];
|
||||
|
@ -159,12 +158,10 @@ public class RpcClient {
|
|||
*/
|
||||
|
||||
/**
|
||||
* Connect to BOINC core client
|
||||
* @param address Internet address of client (hostname or IP-address)
|
||||
* @param port Port of BOINC client (default port is 31416)
|
||||
* Connect to BOINC core client via Unix Domain Socket (abstract, "boinc_socket")
|
||||
* @return true for success, false for failure
|
||||
*/
|
||||
public boolean open(String address, int port) {
|
||||
public boolean open() {
|
||||
if (isConnected()) {
|
||||
// Already connected
|
||||
if(edu.berkeley.boinc.utils.Logging.LOGLEVEL <= 4) Log.e(Logging.TAG, "Attempt to connect when already connected");
|
||||
|
@ -172,17 +169,12 @@ public class RpcClient {
|
|||
close();
|
||||
}
|
||||
try {
|
||||
mSocket = new Socket();
|
||||
mSocket.connect(new InetSocketAddress(address, port), CONNECT_TIMEOUT);
|
||||
mSocket = new LocalSocket();
|
||||
mSocket.connect(new LocalSocketAddress("boinc_socket"));
|
||||
mSocket.setSoTimeout(READ_TIMEOUT);
|
||||
mInput = mSocket.getInputStream();
|
||||
mOutput = new OutputStreamWriter(mSocket.getOutputStream(), "ISO8859_1");
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
if(Logging.WARNING) Log.w(Logging.TAG, "connect failure: unknown host \"" + address + "\"", e);
|
||||
mSocket = null;
|
||||
return false;
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
if(edu.berkeley.boinc.utils.Logging.LOGLEVEL <= 4) Log.e(Logging.TAG, "connect failure: illegal argument", e);
|
||||
mSocket = null;
|
||||
|
@ -193,7 +185,12 @@ public class RpcClient {
|
|||
mSocket = null;
|
||||
return false;
|
||||
}
|
||||
if(Logging.DEBUG) Log.d(Logging.TAG, "open(" + address + ", " + port + ") - Connected successfully");
|
||||
catch (Exception e) {
|
||||
if(Logging.WARNING) Log.w(Logging.TAG, "connect failure", e);
|
||||
mSocket = null;
|
||||
return false;
|
||||
}
|
||||
if(Logging.DEBUG) Log.d(Logging.TAG, "Connected successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,9 +35,7 @@
|
|||
#if HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#if HAVE_SYS_UN_H
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#if HAVE_NETINET_IN_H
|
||||
|
@ -236,9 +234,16 @@ int GUI_RPC_CONN_SET::init_unix_domain() {
|
|||
return retval;
|
||||
}
|
||||
addr.sun_family = AF_UNIX;
|
||||
#ifdef ANDROID
|
||||
// bind socket in abstract address space, i.e. start with 0 byte
|
||||
addr.sun_path[0] = '\0';
|
||||
strcpy(&addr.sun_path[1], GUI_RPC_FILE);
|
||||
socklen_t len = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&addr.sun_path[1]);
|
||||
#else
|
||||
strcpy(addr.sun_path, GUI_RPC_FILE);
|
||||
unlink(GUI_RPC_FILE);
|
||||
int len = strlen(GUI_RPC_FILE) + sizeof(addr.sun_family);
|
||||
#endif
|
||||
unlink(GUI_RPC_FILE);
|
||||
if (bind(lsock, (struct sockaddr*)&addr, len) < 0) {
|
||||
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
||||
"Failed to bind Unix domain socket"
|
||||
|
|
Loading…
Reference in New Issue