summaryrefslogtreecommitdiff
path: root/src/uci
diff options
context:
space:
mode:
Diffstat (limited to 'src/uci')
-rw-r--r--src/uci/response.c10
-rw-r--r--src/uci/state.c1
2 files changed, 8 insertions, 3 deletions
diff --git a/src/uci/response.c b/src/uci/response.c
index ff89f8d..81459d6 100644
--- a/src/uci/response.c
+++ b/src/uci/response.c
@@ -35,7 +35,10 @@ void handle_initial(uci_state_t *state, uci_cmd_t cmd) {
print_setting(state->option_settings[i]);
}
// ---
+ // flush around the handshake so piped GUIs see responses immediately
+ fflush(stdout);
printf("uciok\n");
+ fflush(stdout);
state->current_state = UCI_STATE_IDLE;
}
@@ -164,10 +167,11 @@ void handle_idle(uci_state_t *state, uci_cmd_t cmd) {
void handle_sync(uci_state_t *state, uci_cmd_t cmd) {
// TIMEOUT NOTICE: THE FOLLOWING BLOCK SHOULDN'T TAKE MORE THAN 5 SECONDS
-
-
+ if (cmd.empty || strcmp(cmd.root, "isready") != 0) {
+ // commands sent while a sync is pending must still be handled.
+ return handle_idle(state, cmd);
+ }
- // ---
printf("readyok\n");
state->current_state = UCI_STATE_IDLE;
}
diff --git a/src/uci/state.c b/src/uci/state.c
index 012d951..183f849 100644
--- a/src/uci/state.c
+++ b/src/uci/state.c
@@ -109,6 +109,7 @@ void print_setting(option_setting_t setting) {
void uci_state_init(uci_state_t *state) {
state->signal = UCI_SIGNAL_NONE;
+ state->current_state = UCI_STATE_INITIAL;
strncpy(state->name, "Gacrux", 32);
strncpy(state->author, "Aargh Rai <aarghrai.com>", 32);
int k = 0;