nsIChannel.Open is blocked in linux

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

nsIChannel.Open is blocked in linux

neel5481
Hi All,

Below code is getting hanged in linux and it is in blocking state.


nsIChannel *channel;
rv = ios->NewChannel(nsUri, NULL, NULL, &channel);

// Now, open the IO channel to an input stream form which we'll get the data
nsIInputStream *is;
rv = channel->Open(&is);

ios - "@mozilla.org/network/io-service;1"
nsURi -- will be path of the URL to be opened like "/home/abcd.php".

In above code Open() call is blocked and not coming out and application is in hanging state.


Is there any idea why in  Open() call is blocked ?


Thanks in Advance.
_______________________________________________
dev-tech-network mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-network
Reply | Threaded
Open this post in threaded view
|

Re: nsIChannel.Open is blocked in linux

Boris Zbarsky
On 1/7/14 6:31 AM, neel patel wrote:
> Is there any idea why in  Open() call is blocked ?

It depends on what the URI is, no?  In general, Open() will return once
there is some data to read, so if you do this on an HTTP URI to some
server that's not responding it might sit there for a while...

-Boris

_______________________________________________
dev-tech-network mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-network
Reply | Threaded
Open this post in threaded view
|

Re: nsIChannel.Open is blocked in linux

neel5481
Thanks boris for the quick reply.

You are right. I am also suspecting that there is no data so it is getting blocked. we waited for long time then also it is not coming out.

yes we are doing this on http URI.
Below is the URI

"https://localhost:8334/server/abcd.php"

Server is running and and sending the response.

But is there another way to implement open call ? or debug where exactly the problem is ?

Thanks in Advance.

On Wednesday, January 8, 2014 8:20:35 AM UTC+5:30, Boris Zbarsky wrote:

> On 1/7/14 6:31 AM, neel patel wrote:
>
> > Is there any idea why in  Open() call is blocked ?
>
>
>
> It depends on what the URI is, no?  In general, Open() will return once
>
> there is some data to read, so if you do this on an HTTP URI to some
>
> server that's not responding it might sit there for a while...
>
>
>
> -Boris

_______________________________________________
dev-tech-network mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-network
Reply | Threaded
Open this post in threaded view
|

Re: nsIChannel.Open is blocked in linux

Boris Zbarsky
On 1/8/14 1:01 AM, neel patel wrote:
> But is there another way to implement open call ?

Use AsyncOpen and not have to deal with the broken mess that is trying
to do sync reads on fundamentally async resources?

-Boris
_______________________________________________
dev-tech-network mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-network
Reply | Threaded
Open this post in threaded view
|

Re: nsIChannel.Open is blocked in linux

neel.patel
I will try with AsynOpen.
But i read somewhere that callbacks implementation is not possible in C++ and only in javascript,  we are implementing this in C++ not in javascript so while implementing AsyncOpen i think we need streamObserver and for that we need to implement the callbacks.

Correct me if i am wrong.

Thanks in Advance.


On Wednesday, January 8, 2014 11:35:26 AM UTC+5:30, Boris Zbarsky wrote:

> On 1/8/14 1:01 AM, neel patel wrote:
>
> > But is there another way to implement open call ?
>
>
>
> Use AsyncOpen and not have to deal with the broken mess that is trying
>
> to do sync reads on fundamentally async resources?
>
>
>
> -Boris

_______________________________________________
dev-tech-network mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-network
Reply | Threaded
Open this post in threaded view
|

Re: nsIChannel.Open is blocked in linux

Boris Zbarsky
On 1/8/14 1:21 AM, [hidden email] wrote:
> But i read somewhere that callbacks implementation is not possible in C++ and only in javascript

I don't know what you read, but doing AsyncOpen in C++ is quite
possible.  Firefox does it all the time. That's how it does things like
loading webpages, scripts, stylesheets, etc, after all.  ;)

-Boris
_______________________________________________
dev-tech-network mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-network
Reply | Threaded
Open this post in threaded view
|

Re: nsIChannel.Open is blocked in linux

neel5481
Thanks Boris.

I will check the firefox code and implement the AsyncOpen and will let you know the results.

Thank you.

On Wednesday, January 8, 2014 12:02:01 PM UTC+5:30, Boris Zbarsky wrote:

> On 1/8/14 1:21 AM, [hidden email] wrote:
>
> > But i read somewhere that callbacks implementation is not possible in C++ and only in javascript
>
>
>
> I don't know what you read, but doing AsyncOpen in C++ is quite
>
> possible.  Firefox does it all the time. That's how it does things like
>
> loading webpages, scripts, stylesheets, etc, after all.  ;)
>
>
>
> -Boris
_______________________________________________
dev-tech-network mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-network
Reply | Threaded
Open this post in threaded view
|

Re: nsIChannel.Open is blocked in linux

neel5481
Hi Boris,

Just wanted to update you.

As per your suggestion we have implemented AsyncOpen() call and added StreamListener to that.
In that We are able to get the data from the channel. So now it is working fine.

Thanks for your support.

On Wednesday, January 8, 2014 12:13:41 PM UTC+5:30, neel patel wrote:

> Thanks Boris.
>
>
>
> I will check the firefox code and implement the AsyncOpen and will let you know the results.
>
>
>
> Thank you.
>
>
>
> On Wednesday, January 8, 2014 12:02:01 PM UTC+5:30, Boris Zbarsky wrote:
>
> > On 1/8/14 1:21 AM, [hidden email] wrote:
>
> >
>
> > > But i read somewhere that callbacks implementation is not possible in C++ and only in javascript
>
> >
>
> >
>
> >
>
> > I don't know what you read, but doing AsyncOpen in C++ is quite
>
> >
>
> > possible.  Firefox does it all the time. That's how it does things like
>
> >
>
> > loading webpages, scripts, stylesheets, etc, after all.  ;)
>
> >
>
> >
>
> >
>
> > -Boris

_______________________________________________
dev-tech-network mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-network