mirror of https://github.com/BOINC/boinc.git
- GUI RPC client lib: change setsockopt() for receive timeout
to work on Windows. From Fred. svn path=/trunk/boinc/; revision=24648
This commit is contained in:
parent
28c52cfd9d
commit
9279ef467e
|
@ -8660,3 +8660,13 @@ Charlie 23 Nov 2011
|
||||||
MacBitmapComboBox.cpp
|
MacBitmapComboBox.cpp
|
||||||
sg_ProjectPanel.cpp
|
sg_ProjectPanel.cpp
|
||||||
sg_TaskPanel.cpp
|
sg_TaskPanel.cpp
|
||||||
|
|
||||||
|
David 24 Nov 2011
|
||||||
|
- GUI RPC client lib: change setsockopt() for receive timeout
|
||||||
|
to work on Windows. From Fred.
|
||||||
|
|
||||||
|
lib/
|
||||||
|
gui_rpc_client.cpp
|
||||||
|
ssim/
|
||||||
|
ssim.cpp
|
||||||
|
des.h
|
||||||
|
|
|
@ -127,12 +127,19 @@ int RPC_CLIENT::init(const char* host, int port) {
|
||||||
|
|
||||||
// set up receive timeout; avoid hang if client doesn't respond
|
// set up receive timeout; avoid hang if client doesn't respond
|
||||||
//
|
//
|
||||||
|
#ifdef _WIN32
|
||||||
|
DWORD dwTime = 30000;
|
||||||
|
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&dwTime, sizeof dwTime)) {
|
||||||
|
// not fatal
|
||||||
|
}
|
||||||
|
#else
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
tv.tv_sec = 30;
|
tv.tv_sec = 30;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv)) {
|
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv)) {
|
||||||
// not fatal
|
// not fatal
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
retval = connect(sock, (const sockaddr*)(&addr), addr_len(addr));
|
retval = connect(sock, (const sockaddr*)(&addr), addr_len(addr));
|
||||||
if (retval) {
|
if (retval) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
10
ssim/des.h
10
ssim/des.h
|
@ -19,6 +19,16 @@ struct SIMULATOR {
|
||||||
events.push_back(e);
|
events.push_back(e);
|
||||||
push_heap(events.begin(), events.end(), compare);
|
push_heap(events.begin(), events.end(), compare);
|
||||||
}
|
}
|
||||||
|
void remove(EVENT* e) {
|
||||||
|
vector<EVENT*>::iterator i;
|
||||||
|
for (i=events.begin(); i!=events.end(); i++) {
|
||||||
|
if (*i == e) {
|
||||||
|
events.erase(i);
|
||||||
|
make_heap(events.begin(), events.end(), compare);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
void simulate(double dur) {
|
void simulate(double dur) {
|
||||||
while (events.size()) {
|
while (events.size()) {
|
||||||
EVENT* e = events.front();
|
EVENT* e = events.front();
|
||||||
|
|
|
@ -189,7 +189,7 @@ struct CHUNK : DATA_UNIT {
|
||||||
//
|
//
|
||||||
CHUNK_ON_HOST *c = *(hosts.begin());
|
CHUNK_ON_HOST *c = *(hosts.begin());
|
||||||
c->transfer_in_progress = true;
|
c->transfer_in_progress = true;
|
||||||
c->t = sim.now + size/UPLOAD_BYTES_SEC;
|
c->t = sim.now + (drand()+.5)*size/UPLOAD_BYTES_SEC;
|
||||||
printf("%.0f: starting upload of %s\n", sim.now, c->name);
|
printf("%.0f: starting upload of %s\n", sim.now, c->name);
|
||||||
sim.insert(c);
|
sim.insert(c);
|
||||||
}
|
}
|
||||||
|
@ -197,8 +197,9 @@ struct CHUNK : DATA_UNIT {
|
||||||
// see if we can remove chunk from server
|
// see if we can remove chunk from server
|
||||||
//
|
//
|
||||||
int n=0;
|
int n=0;
|
||||||
for (unsigned int i=0; i<hosts.size(); i++) {
|
set<CHUNK_ON_HOST*>::iterator i;
|
||||||
CHUNK_ON_HOST* c = hosts[i];
|
for (i=hosts.begin(); i!=hosts.end(); i++) {
|
||||||
|
CHUNK_ON_HOST* c = *i;
|
||||||
if (c->present_on_host) {
|
if (c->present_on_host) {
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
@ -256,6 +257,12 @@ struct META_CHUNK : DATA_UNIT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void cleanup() {
|
||||||
|
for (unsigned int i=0; i<children.size(); i++) {
|
||||||
|
children[i]->cleanup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// this is called only if we're uploading
|
// this is called only if we're uploading
|
||||||
//
|
//
|
||||||
void child_upload_complete() {
|
void child_upload_complete() {
|
||||||
|
@ -272,6 +279,11 @@ struct META_CHUNK : DATA_UNIT {
|
||||||
assign();
|
assign();
|
||||||
if (parent && parent->uploading) {
|
if (parent && parent->uploading) {
|
||||||
parent->child_upload_complete();
|
parent->child_upload_complete();
|
||||||
|
} else {
|
||||||
|
// if we're not reconstructing parent,
|
||||||
|
// delete any chunks not being downloaded
|
||||||
|
//
|
||||||
|
cleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -328,6 +340,9 @@ void HOST::handle() {
|
||||||
for (p = chunks.begin(); p != chunks.end(); p++) {
|
for (p = chunks.begin(); p != chunks.end(); p++) {
|
||||||
CHUNK_ON_HOST* c = *p;
|
CHUNK_ON_HOST* c = *p;
|
||||||
c->chunk->host_failed(c);
|
c->chunk->host_failed(c);
|
||||||
|
if (c->transfer_in_progress) {
|
||||||
|
sim.remove(c);
|
||||||
|
}
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,7 +390,7 @@ void CHUNK::assign() {
|
||||||
printf("%.0f: assigning chunk %s to host %d\n", sim.now, name, h->id);
|
printf("%.0f: assigning chunk %s to host %d\n", sim.now, name, h->id);
|
||||||
c->host = h;
|
c->host = h;
|
||||||
c->chunk = this;
|
c->chunk = this;
|
||||||
c->t = sim.now + size/DOWNLOAD_BYTES_SEC;
|
c->t = sim.now + (drand()+.5)*size/DOWNLOAD_BYTES_SEC;
|
||||||
hosts.insert(c);
|
hosts.insert(c);
|
||||||
h->chunks.insert(c);
|
h->chunks.insert(c);
|
||||||
sim.insert(c);
|
sim.insert(c);
|
||||||
|
|
Loading…
Reference in New Issue