When we are waiting for new trail files we may have been disconnected and

reconnected in the meantime. Check if reset is set before opening next trail
file, as not doing so will result in sending OPEN message with the same
file name twice and this is illegal - the second OPEN is send without first
closing previous trail file.
This commit is contained in:
Pawel Jakub Dawidek 2013-02-28 01:24:24 +00:00
parent eff269ee18
commit a66ffea41d

View File

@ -394,6 +394,7 @@ read_thread_wait(void)
mtx_lock(&adist_remote_mtx); mtx_lock(&adist_remote_mtx);
if (adhost->adh_reset) { if (adhost->adh_reset) {
reset:
adhost->adh_reset = false; adhost->adh_reset = false;
if (trail_filefd(adist_trail) != -1) if (trail_filefd(adist_trail) != -1)
trail_close(adist_trail); trail_close(adist_trail);
@ -408,6 +409,14 @@ read_thread_wait(void)
while (trail_filefd(adist_trail) == -1) { while (trail_filefd(adist_trail) == -1) {
newfile = true; newfile = true;
wait_for_dir(); wait_for_dir();
/*
* We may have been disconnected and reconnected in the
* meantime, check if reset is set.
*/
mtx_lock(&adist_remote_mtx);
if (adhost->adh_reset)
goto reset;
mtx_unlock(&adist_remote_mtx);
if (trail_filefd(adist_trail) == -1) if (trail_filefd(adist_trail) == -1)
trail_next(adist_trail); trail_next(adist_trail);
} }