jobserver: exit completely when socket ops fail
When socket(2), setsockopt(2), bind(2), listen(2), or accept(2) return an unexpected error status, it is usually not a good idea to let the campaign continue. This is especially a problem as the perror(3) message gets lost in normal campaign output and may be missed by the user. Change-Id: I92747174e0706a613bedd8c6664cc8d888e07533
This commit is contained in:
committed by
Bjoern Doebel
parent
f775c92d72
commit
dbff3ab236
@ -125,7 +125,7 @@ void JobServer::run()
|
|||||||
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||||
perror("socket");
|
perror("socket");
|
||||||
// TODO: Log-level?
|
// TODO: Log-level?
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable address reuse */
|
/* Enable address reuse */
|
||||||
@ -133,7 +133,7 @@ void JobServer::run()
|
|||||||
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) {
|
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) {
|
||||||
perror("setsockopt");
|
perror("setsockopt");
|
||||||
// TODO: Log-level?
|
// TODO: Log-level?
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IPv4, bind to all interfaces */
|
/* IPv4, bind to all interfaces */
|
||||||
@ -146,14 +146,14 @@ void JobServer::run()
|
|||||||
if (::bind(s, (struct sockaddr*) &saddr, sizeof(saddr)) == -1) {
|
if (::bind(s, (struct sockaddr*) &saddr, sizeof(saddr)) == -1) {
|
||||||
perror("bind");
|
perror("bind");
|
||||||
// TODO: Log-level?
|
// TODO: Log-level?
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Listen with a backlog of maxThreads */
|
/* Listen with a backlog of maxThreads */
|
||||||
if (listen(s, m_maxThreads) == -1) {
|
if (listen(s, m_maxThreads) == -1) {
|
||||||
perror("listen");
|
perror("listen");
|
||||||
// TODO: Log-level?
|
// TODO: Log-level?
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
cout << "JobServer listening ..." << endl;
|
cout << "JobServer listening ..." << endl;
|
||||||
// TODO: Log-level?
|
// TODO: Log-level?
|
||||||
@ -166,7 +166,7 @@ void JobServer::run()
|
|||||||
if (errno != EWOULDBLOCK) {
|
if (errno != EWOULDBLOCK) {
|
||||||
perror("poll/accept");
|
perror("poll/accept");
|
||||||
// TODO: Log-level?
|
// TODO: Log-level?
|
||||||
return;
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user