Windows XP Apache PHP output problem
Posted by Felix Geisendörfer, on Nov 03, 2006 - in Everything else
... those were (some of) the google keywords I used to search for a solution to the Heisenbug that recently killed my productivity. Big thanks to meek, who has found the bug in Windows XP (no SP) that caused the problem:
Q317949: Socket Sharing Creates Data Loss When Listen and Accept Occur on Different Processes
I'm doing this post because I hope that Google will index it, and the next person hitting the issue will find my blog this way, so he doesn't have to go through the same issues that had to deal with.
So in case your system has the following SYMPTOMS, please have a look at the steps below that helped me fixing the issue.
- A bind of a listen socket is completed in a parent process.
- An accept is completed in a child process.
- Fast sends are happening.
Or with other words: Files served via php's output functions like fread, fpassthrough, readfile, imagejpg and so on will not completly be recieved by the browser causing incomplete & often disturbed display of the data.
The solution is quite simple, one can either update to the latest Service pack, or if that is problematic (because the SP is incompatible with one's hardware like in my case), one can simply replace the \Windows\system32\drivers\afd.sys with a newer version. So if you want to use the second option, here is what you have to do:
- Backup your existing \Windows\system32\drivers\afd.sys. In case something goes wrong you sure want to be able to fix it.
- Disable Windows automatic System restore functionality. Go to Start->Run->[type in 'control', then hit enter]->System. Select the System Recovery tab and check the box to deactive the functionality. Then hit Ok.
- Download a SP2 version of the afd.sys. (Thanks to my friend Robert H. for sending me his copy!)
- Copy this file to \Windows\system32\drivers and \Windows\system32\dllcache and overwrite the existing versions of the file. If Windows starts to bug you to insert the Windows XP CD, ignore it as you usually do with useless error messages ; ).
- Restart your System
- Check that the afd.sys in \Windows\system32\drivers is the one you downloaded and has not been replaced with the old one (you can use modified date, file size, md5 hash, version, or whatever suits you best to do this).
- Check if the problem still exists. If no, donate all your money to "Felix Geisendörfer" via Paypal ; ). (Just kidding)
Oh boy, this has been a true nightmare and I really want to thank all the people who have thrown in their suggestions in the Google Group post and the blog post I made. Now I can finally go back to being productive!
And for those of you wondering why I'm on Windows and don't switch to some *Nix system like all the cool kids: I like Windows. Don't get me wrong, there is an endless list of things I truly hate about it, and an even more endless list of reasons why I don't like Microsoft, but in reality it's the OS that runs all the Apps I love, that I know the best and that has the best GUI (to me). There are a lot of things I like about Mac OS X & Linux, and I will eventually start using one of them as a second OS at some point, but there are just too many drawbacks for me right now. Robert Nyman has a nice post highlighting some things about OS X that suck and I got quite a couple others in my head as well. But again, the truth simply is that me using Windows is a marriage of convenience. Nothing more and nothing less ; ).
--Felix Geisendörfer aka the_undefined