[Xastir-dev] TNC Stop script

Erik Burrows erik at erikburrows.com
Tue Feb 10 02:38:18 EST 2004


> Way back I did some optimization, trying to get rid of unnecessary
> delays in the interface part of the code.  People were complaining
> about slow writes to the TNC.  I probably got a bit too aggressive
> while making the changes, or perhaps the code had a race condition
> there to begin with, but I made it worse.

How about something like this:

diff -r1.154 interface.c
5554d5553
<                     usleep(2000000);    // 2secs
5591d5589
<                     usleep(2000000);    // 2secs
5609d5606
<                     usleep(2000000);    // 2secs
5614a5612,5621
> 
> 
>           /* Let the write queue empty. */
>           while ( (port_data[port].write_in_pos !=
port_data[port].write_out_pos)
>                   && port_data[port].status == DEVICE_UP) {
> 
>             sched_yield();
>             usleep(100000);    // 100ms
>           }
> 

It works for me, in that the stop script gets fully output, but of
course the program seems to freeze until it completes. Anyway, it shuts
me up.

PS: Thanks to Chris Bell for helping me with this. I was trying this
kind of fix for several hours until he reminded me of the various device
locks. Moved to before the point where the locks are aquired, and before
serial_detach() is called in del_device(), everything works perfectly.

Thanks,
-Erik

> > Xastir seems to write out only the first few bytes (echo on\n autolf o) of my 20
> > line stop script to my TNC when shutting down the device.
> >
> > I've uncommented some debugging output and it seems to me that the write
> > thread is being killed before it's done flushing the write buffer.
> >
> > I've tried the current CVS version and -r STABLE, same problem.
> >
> > Any ideas?
> 
> Yea, my first idea is that you're probably 100% correct.  I think
> you hit it right on the head.  We probably need to verify we hit
> end-of-file before we allow the thread to be killed.
> 
> Way back I did some optimization, trying to get rid of unnecessary
> delays in the interface part of the code.  People were complaining
> about slow writes to the TNC.  I probably got a bit too aggressive
> while making the changes, or perhaps the code had a race condition
> there to begin with, but I made it worse.
> 
> Please file a bug report on SourceForge about it.  The text you have
> above would be fine and would point us right to the problem.  Filing
> a report means that it won't be forgotten.  One of the developers
> will get to it when they have a few free minutes/hours to play.
> 
> -- 
> Curt, WE7U.				archer at eskimo dot com
> http://www.eskimo.com/~archer
>   Lotto:  A tax on people who are bad at math. - unknown
> Windows:  Microsoft's tax on computer illiterates. - WE7U.
> The world DOES revolve around me:  I picked the coordinate system!"
-- 
Erik G. Burrows - KG6HEA                   www.erikburrows.com
PGP Key: http://www.erikburrows.com/egb@erikburrows.com.pgpkey



More information about the Xastir-dev mailing list