Re: gtk-timeout-add function stalling

Paul Emsley <[email protected]> Fri, 15 Jan 2010 12:47:11 +0000
Newsgroups gmane.lisp.guile.gtk
Message-ID <[email protected]>
Andy Wingo wrote:
>
> On Sun 10 Jan 2010 15:52, Paul Emsley <[email protected]> writes:
>
>   
>> I am trying to update a progress bar that is downloading a file using
>> libcurl in a thread.  I am doing that by adding a timeout function that
>> every fraction of a second or so queries the status of the download
>> (curl-progress-info).  However, after a number of rounds (somewhere
>> between 100 or 250) the timeout function seems to hang - even partway
>> through writing a debugging text. (The thread downloading the file
>> continues.)  Why does the timeout function stalling?
>>     
>
> Can you attach to the process in GDB and post a backtrace?
>
> $ gdb /path/to/guile PID-OF-PROCESS
>
> Then at the prompt:
>
> thread apply all bt
>   

OK, did that and corresponded with Andy off-list. It turns out that the 
long-lived sub-thread (downloading a binary) was still in guile-mode.  
What I had to do was leave guile-mode for that thread - that is the case 
for guile-1.8.x.


Andy Wingo writes:

> The main
> thread goes to GC, tries to wait for the other thread to reach some kind
> of Guile synchronization point so it will go to sleep, but the other
> thread isn't letting up.

To fix, I moved the long-running part of that thread into scm_without_guile.  I used GINT_TO_POINTER and GPOINTER_TO_INT to get the libcurl function return value that I wanted.

It would have helped if I'd read the manual,  Section 5.17.6 Blocking in 
Guile Mode.

http://www.gnu.org/software/guile/manual/guile.html#Blocking

Andy suggest that this (using scm_without_guile) may not be necessary in 
guile-1.9 series.

Thanks Andy Wingo,

Paul.