Re: g_file_read block

Thanks Yan and Shaun,
I'll give the async method a try - seems a little less work to do than
port to libsoup! Even though libsoup does seem quite appealing.

I figured since g_file_read accepts a pointer to a cancellable, it
must be asynchronous - thanks for pointing me in the right direction.


On Fri, May 20, 2011 at 2:36 PM, Shaun McCance <shaunm gnome org> wrote:
> On Wed, 2011-05-18 at 18:11 -0600, Jim George wrote:
>> Hello list,
>> In my application, I'm trying to connect to a remote webserver and
>> grab an image file (output of a CGI program), and I'm trying to use
>> GIO for this. I call g_file_new_for_uri with the URL, and then call
>> g_file_read to get the input stream. It works for the most part, but
>> I'm seeing that if the application ends up sending a larger number of
>> consecutive requests (user requests refreshes very often), the program
>> locks up. Running under gdb, I can do a ^C and backtrace, it fails on
>> the call to g_file_read. Somewhere deep inside g_file_read, the
>> program is waiting in a call to "poll".
>> Am I calling things in the wrong order? I do have a cancellable and a
>> GError passed to g_file_read, if that makes a difference.
> g_file_read is synchronous. Unless you've tucked this stuff into
> a separate thread, you shouldn't use the synchronous API in a GUI
> application. Use async functions like g_file_read_async instead.
> --
> Shaun

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]