From nick.pend at gmail.com Fri Feb 22 20:31:24 2008 From: nick.pend at gmail.com (Nick P) Date: Fri, 22 Feb 2008 23:31:24 -0500 Subject: [Jslib] isAlive in sockets.js Message-ID: What is the status of the isAlive function in sockets.js? I saw this piece of documentation: // We really should call _transport.isAlive (?) but that is never reliable // (either always false or always true). // Experimentation shows that calls to available() or isAlive() will not // catch any problems with the connection until the javascript call // stack has completely unwound. and I noticed that when rajeev posted a fix for some socket behavior, it included pulling out the isAlive call. ( http://mozdev.org/pipermail/jslib/2007-December/000917.html) Should isAlive be used? I'm trying to debug some odd behavior and am wondering if it is related to this. Specifically, I have some code using sockets.js that shows this behavior: when i run it repeatedly in jsliblive in Firefox, occasionally it hits a streak where after the socket.open is called, socket.isAlive() fails. It might do this 7 times, and then I will have a streak where it works properly. When we moved it out of Firefox and into a xulrunner app, it started failing on isAlive() every time. Any insight on the use of isAlive would be appreciated - and if you have any ideas about the weird bug described above, please chime in! nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.mozdev.org/pipermail/jslib/attachments/20080222/5d4c04e7/attachment.html From pete at mozdevgroup.com Sat Feb 23 09:01:44 2008 From: pete at mozdevgroup.com (Pete Collins) Date: Sat, 23 Feb 2008 10:01:44 -0700 Subject: [Jslib] isAlive in sockets.js In-Reply-To: References: Message-ID: <47C05178.3060900@mozdevgroup.com> > Any insight on the use of isAlive would be appreciated - and if you > have any ideas about the weird bug described above, please chime in! > The problem is I didn't write the socket code and never use it so I need to rely on developers who are using the code to send in their patches. I can review/cleanup and check in ... --pete -- Pete Collins - Founder, Mozdev Group Inc. www.mozdevgroup.com Mozilla Software Development Solutions tel: 1-719-302-5811 fax: 1-719-302-5813 From nick.pend at gmail.com Sun Feb 24 11:43:28 2008 From: nick.pend at gmail.com (Nick P) Date: Sun, 24 Feb 2008 14:43:28 -0500 Subject: [Jslib] isAlive in sockets.js In-Reply-To: <47C05178.3060900@mozdevgroup.com> References: <47C05178.3060900@mozdevgroup.com> Message-ID: For what it's worth, I found out what the problem was with my sockets. I was calling socket.open() followed by a test for socket.isAlive() to see if the open worked - there is no return value from .open(). Often it would fail - so I tried to work around this by creating a loop that opens new sockets if the socket is not alive. This often caught the problem when I ran it in the browser, but it failed much more often when I ran it in a xulrunner app. Ultimately, it appears that isAlive() was getting called possibily before the work of socket.open() was completed. By adding in a setTimeout() (even for just one millisecond), the problem is solved. It appears that the .open() is working - it just doesn't complete in time if you test isAlive() immediately thereafter. I don't have much experience with JavaScript (until now) but I know that some of it is pretty asynchronous, so I guess socket.isAlive may actually be getting called before socket.open even works. So I don't have a fix to put in the code, just a note that if isAlive is called immeidately, it may not be accurate. This is tricky to debug because if you set a breakpoint , then the error might not surface. nick On Sat, Feb 23, 2008 at 12:01 PM, Pete Collins wrote: > > > Any insight on the use of isAlive would be appreciated - and if you > > have any ideas about the weird bug described above, please chime in! > > > The problem is I didn't write the socket code and never use it so I need > to rely on developers who are using the code to send in their patches. > > I can review/cleanup and check in ... > > --pete > > -- > Pete Collins - Founder, Mozdev Group Inc. > www.mozdevgroup.com > Mozilla Software Development Solutions > tel: 1-719-302-5811 > fax: 1-719-302-5813 > > _______________________________________________ > Jslib mailing list > Jslib at mozdev.org > https://www.mozdev.org/mailman/listinfo/jslib > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.mozdev.org/pipermail/jslib/attachments/20080224/7b3b8895/attachment.html