Submitted by: kautism

patch #9893: [PATCH] Reader reads ftdi handle after main thread close it
* ft245r.c: Wait until reader thread has been stopped before closing FTDI



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1434 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2020-03-11 12:39:57 +00:00
parent ae24d7a284
commit c34fb88844
3 changed files with 17 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2020-03-11 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by: kautism
patch #9893: [PATCH] Reader reads ftdi handle after main thread close it
* ft245r.c: Wait until reader thread has been stopped before closing FTDI
2020-03-11 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Fix compiler warnings

1
NEWS
View File

@ -68,6 +68,7 @@ Current:
patch #8444: Proposal for modifications in -B and -U command options managment (partially)
patch #9735: spelling error fix: psuedo -> pseudo
patch #9728: Fix UsbTiny programmer
patch #9893: [PATCH] Reader reads ftdi handle after main thread close it
* Internals:
- New avrdude.conf keyword "family_id", used to verify SIB attributes

View File

@ -681,14 +681,22 @@ cleanup_no_usb:
static void ft245r_close(PROGRAMMER * pgm) {
int retry_times = 0;
if (handle) {
// I think the switch to BB mode and back flushes the buffer.
ftdi_set_bitmode(handle, 0, BITMODE_SYNCBB); // set Synchronous BitBang, all in puts
ftdi_set_bitmode(handle, 0, BITMODE_RESET); // disable Synchronous BitBang
ftdi_usb_close(handle);
ftdi_deinit (handle);
pthread_cancel(readerthread);
while(pthread_cancel(readerthread) && retry_times < 100) {
retry_times++;
usleep(100);
}
if (retry_times >= 100) {
avrdude_message(MSG_INFO, "Too many retry to close reader thread\n");
}
pthread_join(readerthread, NULL);
ftdi_deinit (handle);
free(handle);
handle = NULL;
}