Skip to content

Commit

Permalink
Add pauses to efactor operations to fix tests repeatability
Browse files Browse the repository at this point in the history
  • Loading branch information
dagargo committed Nov 20, 2022
1 parent 24f02a3 commit 80fc414
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/connectors/efactor.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ efactor_download (struct backend *backend, const gchar * src_path,
err = -ECANCELED;
}

sleep (1);

return err;
}

Expand Down Expand Up @@ -353,6 +355,8 @@ efactor_upload (struct backend *backend, const gchar * path,
}

end:
sleep (1);

return err;
}

Expand Down Expand Up @@ -408,6 +412,9 @@ efactor_rename (struct backend *backend, const gchar * src, const gchar * dst)
err = -EIO;
free_msg (rx_msg);
}

sleep (1);

return err;
}

Expand Down Expand Up @@ -474,7 +481,7 @@ efactor_destroy_data (struct backend *backend)
backend_destroy_data (backend);
}

//We are replicanting the functionality in backend because the request is standard but the response is not.
//We are replicanting the functionality in the backend because the request is standard but the response is not.
gint
efactor_handshake (struct backend *backend)
{
Expand All @@ -484,8 +491,12 @@ efactor_handshake (struct backend *backend)
GByteArray *tx_msg;
GByteArray *rx_msg;

//Sometimes it takes a lot of time to receive the response to the MIDI identity request.
//As the backend is already asking for it, we need to ensure that the input buffer is empty before continuing.
//With these two calls, the total timeout including the backend handshake is 2.5 s, which is empirically enough.
g_mutex_lock (&backend->mutex);
backend_rx_drain (backend);
backend_rx_drain (backend);
g_mutex_unlock (&backend->mutex);

tx_msg = g_byte_array_sized_new (sizeof (MIDI_IDENTITY_REQUEST));
Expand Down

0 comments on commit 80fc414

Please sign in to comment.