debug: attempt to make the simulation deterministic by not returning until connection is made and command is receieved
This commit is contained in:
parent
1d3fa07c44
commit
024cd52c44
@ -78,20 +78,23 @@ void remote_bitbang_t::accept()
|
|||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stderr,"Attempting to accept client socket\n");
|
fprintf(stderr,"Attempting to accept client socket\n");
|
||||||
|
int again = 1;
|
||||||
client_fd = ::accept(socket_fd, NULL, NULL);
|
while (again != 0) {
|
||||||
if (client_fd == -1) {
|
client_fd = ::accept(socket_fd, NULL, NULL);
|
||||||
if (errno == EAGAIN) {
|
if (client_fd == -1) {
|
||||||
// No client waiting to connect right now.
|
if (errno == EAGAIN) {
|
||||||
fprintf(stderr, "Not Accepted: Received EAGAIN error\n");
|
// No client waiting to connect right now.
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "failed to accept on socket: %s (%d)\n", strerror(errno),
|
||||||
|
errno);
|
||||||
|
again = 0;
|
||||||
|
abort();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "failed to accept on socket: %s (%d)\n", strerror(errno),
|
fcntl(client_fd, F_SETFL, O_NONBLOCK);
|
||||||
errno);
|
fprintf(stderr, "Accepted successfully.");
|
||||||
abort();
|
again = 0;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fcntl(client_fd, F_SETFL, O_NONBLOCK);
|
|
||||||
fprintf(stderr, "Accepted successfully.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,25 +133,27 @@ void remote_bitbang_t::set_pins(char _tck, char _tms, char _tdi){
|
|||||||
void remote_bitbang_t::execute_command()
|
void remote_bitbang_t::execute_command()
|
||||||
{
|
{
|
||||||
char command;
|
char command;
|
||||||
|
int again = 1;
|
||||||
ssize_t num_read = read(client_fd, &command, sizeof(command));
|
while (again) {
|
||||||
if (num_read == -1) {
|
ssize_t num_read = read(client_fd, &command, sizeof(command));
|
||||||
if (errno == EAGAIN) {
|
if (num_read == -1) {
|
||||||
// We'll try again the next call.
|
if (errno == EAGAIN) {
|
||||||
fprintf(stderr, "Received no command. Will try again on the next call\n");
|
// We'll try again the next call.
|
||||||
return;
|
fprintf(stderr, "Received no command. Will try again on the next call\n");
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "remote_bitbang failed to read on socket: %s (%d)\n",
|
||||||
|
strerror(errno), errno);
|
||||||
|
again = 0;
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
} else if (num_read == 0) {
|
||||||
|
fprintf(stderr, "No Command Received.\n");
|
||||||
|
again = 1;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "remote_bitbang failed to read on socket: %s (%d)\n",
|
again = 0;
|
||||||
strerror(errno), errno);
|
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_read == 0) {
|
|
||||||
fprintf(stderr, "No Command Received.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "Received a command %c\n", command);
|
fprintf(stderr, "Received a command %c\n", command);
|
||||||
|
|
||||||
int dosend = 0;
|
int dosend = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user