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");
|
||||
|
||||
int again = 1;
|
||||
while (again != 0) {
|
||||
client_fd = ::accept(socket_fd, NULL, NULL);
|
||||
if (client_fd == -1) {
|
||||
if (errno == EAGAIN) {
|
||||
// No client waiting to connect right now.
|
||||
fprintf(stderr, "Not Accepted: Received EAGAIN error\n");
|
||||
} else {
|
||||
fprintf(stderr, "failed to accept on socket: %s (%d)\n", strerror(errno),
|
||||
errno);
|
||||
again = 0;
|
||||
abort();
|
||||
}
|
||||
} else {
|
||||
fcntl(client_fd, F_SETFL, O_NONBLOCK);
|
||||
fprintf(stderr, "Accepted successfully.");
|
||||
again = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,23 +133,25 @@ void remote_bitbang_t::set_pins(char _tck, char _tms, char _tdi){
|
||||
void remote_bitbang_t::execute_command()
|
||||
{
|
||||
char command;
|
||||
|
||||
int again = 1;
|
||||
while (again) {
|
||||
ssize_t num_read = read(client_fd, &command, sizeof(command));
|
||||
if (num_read == -1) {
|
||||
if (errno == EAGAIN) {
|
||||
// We'll try again the next call.
|
||||
fprintf(stderr, "Received no command. Will try again on the next call\n");
|
||||
return;
|
||||
} else {
|
||||
fprintf(stderr, "remote_bitbang failed to read on socket: %s (%d)\n",
|
||||
strerror(errno), errno);
|
||||
again = 0;
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
if (num_read == 0) {
|
||||
} else if (num_read == 0) {
|
||||
fprintf(stderr, "No Command Received.\n");
|
||||
return;
|
||||
again = 1;
|
||||
} else {
|
||||
again = 0;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "Received a command %c\n", command);
|
||||
|
Loading…
Reference in New Issue
Block a user