views:

382

answers:

2

This question is a followup to my previous one: Previous Questions.

So I setup my page to initiate an ajax call to initiate processing some records. And after each record it updates a row in another table to keep track of the status of this process. After that first ajax call is made, I have another start up. It's a Ajax.PeriodicalUpdater and it's set to hit a file which simply queries that row in the db and returns the status of the original process.

So this works perfectly fine... as long as the file that provides the status updates is outside my current app. If I put the file inside of my app, then it doesn't work right. If I watch firebug, the PeriodicalUpdater call doesn't get anything back until the original ajax call finishes, it just hangs out so it's as if the file is hung and not returning anything.

This whole app is running inside just a basic framework we are using. Nothing crazy, just handles routing, and basic template aspects etc... So all of these functions/files are inside this app and all these ajax calls are being routed through this.

What could be causing something like this?

+1  A: 

Can this be due to the limit of concurrent connections supported by a browser to a particular domain?

Kirtan
Hmmm maybe. I'm going to read through that right now. But the instance where it worked, when I moved the file out of my app, it was still on the same server and same domain.
threendib
That doesn't seem to be what's causing the problem. As I said, when I move the file out of the app, which for this is just down a directory it works fine. And I was able to open up 3 ajax connections to the file when it's outside my app and it works fine. Seems to be something to do with php and our app somehow, but I'm not sure what would cause the server to hang like that.
threendib
A: 

This is caused by PHP session serialization. The session data is locked until the PHP process for each request has finished writing to it, so further requests in the same session will queue until the lock is released.

If your AJAX requests need access to session state, read out the information you need and then use session_write_close() as early in your code as possible to release those locks.

Terry Johnson