php-general Digest 2 Jun 2008 14:54:14 -0000 Issue 5493
Topics (messages 274917 through 274923):
APC + PHP Problem (apc_fcntl_lock failed: Bad file descriptor)
274917 by: Scott McNaught [Synergy 8]
274919 by: Colin Guthrie
Re: PHP Extensions as Shared Objects?
274918 by: Colin Guthrie
Avoid object twice
274920 by: Yui Hiroaki
274921 by: Scott McNaught [Synergy 8]
Re: saving outside website content via php...
274922 by: Boyd, Todd M.
274923 by: Shawn McKenzie
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Hello,
I am running a production server with APC and php. We recently had a crash
where APC bombed out. When it does this, the server serves empty, white
pages.
Here is what the error_log says.
[Mon Jun 2 11:20:36 2008] [apc-error] apc_fcntl_lock failed: Bad file
descriptor
[Mon Jun 02 11:20:37 2008] [notice] child pid 6104 exit signal Segmentation
fault (11)
[Mon Jun 2 11:20:40 2008] [apc-error] apc_fcntl_lock failed: Bad file
descriptor
[Mon Jun 2 11:20:40 2008] [apc-error] apc_fcntl_lock failed: Bad file
descriptor
[Mon Jun 2 11:20:41 2008] [apc-error] apc_fcntl_lock failed: Bad file
descriptor
[Mon Jun 2 11:20:41 2008] [apc-error] apc_fcntl_lock failed: Bad file
descriptor
[Mon Jun 2 11:20:41 2008] [apc-error] apc_fcntl_lock failed: Bad file
descriptor
[Mon Jun 2 11:20:42 2008] [apc-error] apc_fcntl_lock failed: Bad file
descriptor
[Mon Jun 2 11:20:43 2008] [apc-error] apc_fcntl_lock failed: Bad file
descriptor
[Mon Jun 2 11:20:45 2008] [apc-error] apc_fcntl_lock failed: Bad file
descriptor
[Mon Jun 2 11:20:45 2008] [apc-error] apc_fcntl_lock failed: Bad file
descriptor
...
And so it goes on until apache was restarted.
I have not yet found a resolution for this. There are no calls made to
apc_store() on the server. It is solely script caching.
I have seen bug reports on this:
http://pecl.php.net/bugs/bug.php?id=4769
http://pecl.php.net/bugs/bug.php?id=9745
After looking at these, I think what is happening is the cache is filling
up, and when it expunge()s it gets in a loop, php kills the process after
the 30sec timeout, and the lock is left. Then no more subsequent requests
can be served.
Has anyone else experienced this, and does anyone know of a fix for this?
I am running PHP 5.2.5, and APC 3.0.15. This is the PHP info for APC.
APC Support enabled
Version 3.0.15
MMAP Support Enabled
MMAP File Mask no value
Locking type File Locks
Revision $Revision: 3.151 $
Build Date Oct 29 2007 19:02:05
Directive Local Value Master Value
apc.cache_by_default On On
apc.enable_cli Off Off
apc.enabled On On
apc.file_update_protection 2 2
apc.filters no value no value
apc.gc_ttl 3600 3600
apc.include_once_override Off Off
apc.localcache Off Off
apc.localcache.size 512 512
apc.max_file_size 1M 1M
apc.mmap_file_mask no value no value
apc.num_files_hint 1000 1000
apc.report_autofilter Off Off
apc.rfc1867 Off Off
apc.rfc1867_freq 0 0
apc.rfc1867_name APC_UPLOAD_PROGRESS APC_UPLOAD_PROGRESS
apc.rfc1867_prefix upload_ upload_
apc.shm_segments 1 1
apc.shm_size 30 30
apc.slam_defense 0 0
apc.stat On On
apc.stat_ctime Off Off
apc.ttl 0 0
apc.user_entries_hint 4096 4096
apc.user_ttl 0 0
apc.write_lock On On
--- End Message ---
--- Begin Message ---
Scott McNaught [Synergy 8] wrote:
Hello,
I am running a production server with APC and php. We recently had a crash
where APC bombed out. When it does this, the server serves empty, white
pages.
Here is what the error_log says.
I have not yet found a resolution for this. There are no calls made to
apc_store() on the server. It is solely script caching.
I am running PHP 5.2.5, and APC 3.0.15. This is the PHP info for APC.
I've recently deployed a similar setup, again only for script caching.
It's working great for me with PHP 5.2.6 and APC 3.0.19. I'd suggest
upgrading and seeing if that fixes it (esp the APC bit for obvious
reasons - should also be pretty painless to upgrade only that part)
I only have a fairly low cache enabled and it does fill up and expunge
data after a time out, so if I was affected by this I'd have expected to
have seen it rear it's ugly head by now.
Col
--- End Message ---
--- Begin Message ---
mike wrote:
On 5/29/08, Weston C <[EMAIL PROTECTED]> wrote:
Fortunately, I'll have full control of the hosting environment in the
context this matters. :)
dl is definitely interesting, but I'm worried that runtime invocation
might mean performance hits. Is there a way to do load/startup time
inclusion?
you could put it in your php ini file
extension = "foo.so"
then I believe the impact will be on the first instance for that php
engine. so in fastcgi mode, you'd only have the hit once every
PHP_FCGI_MAX_REQUESTS when the child restarts...
Have a look at a standard Mandriva or Fedora/CentOS PHP install. You'll
see that the various parts of the PHP engine are all very modular with
several PECL modules pre-built for your convenience.
The php.ini file is split into files in /etc/php.d/*.ini so that the
packages can put their own little config systems into the php.ini "file"
without dicking around with automated editing.
When using PHP as a module the impact is pretty low, only once per
restart. As Mike wrote the low impact is also apparent in FCGI mode too
(but it's a bit more obvious where the extra load it creates is manifested).
Personally, the convenience of modularity sells this approach for me. I
do generally roll my own RPMs to keep things up to day and patched, but
again I just use that format/deployment method as it's convenient.
Col
--- End Message ---
--- Begin Message ---
Please take a look at code.
--------a.php--------
$obj=new my("Hello");
$obj->buff();
Class my{
private $word;
function __construct($getword){
$this->word=$getword;
}
public function buff(){
echo $this->word."<br />";
}
--------------------------------------
-----b.php-----------------------
function __autoload($class_name) {
include_once $class_name . '.php';
}
$objref=new my("Good");
$objref->buff();
--------------------------------------------
I get an Echo;
Good
Hello
Hello
I do not need to get Hello twice.
When I b.php , $obj=new my("Hello") is loaded.
Do you have any adia to avoid load $obj in a.php twice?
Regards,
Yui
--- End Message ---
--- Begin Message ---
Try removing from a.php the lines:
$obj=new my("Hello");
$obj->buff();
I think this will achieve what you want.
-----Original Message-----
From: Yui Hiroaki [mailto:[EMAIL PROTECTED]
Sent: Monday, June 02, 2008 11:01 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Avoid object twice
Please take a look at code.
--------a.php--------
$obj=new my("Hello");
$obj->buff();
Class my{
private $word;
function __construct($getword){
$this->word=$getword;
}
public function buff(){
echo $this->word."<br />";
}
--------------------------------------
-----b.php-----------------------
function __autoload($class_name) {
include_once $class_name . '.php';
}
$objref=new my("Good");
$objref->buff();
--------------------------------------------
I get an Echo;
Good
Hello
Hello
I do not need to get Hello twice.
When I b.php , $obj=new my("Hello") is loaded.
Do you have any adia to avoid load $obj in a.php twice?
Regards,
Yui
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: blackwater dev [mailto:[EMAIL PROTECTED]
> Sent: Sunday, June 01, 2008 9:26 PM
> To: Shawn McKenzie
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] saving outside website content via php...
>
> Yes, but file_get_contents will get me the code which I could then
> echo back out to the browser but that wouldn't give me any external
> images, css files or js.
Use the RegEx examples for tag-grabbing that appeared in this mailing
list last week. Parse whatever text is returned from cURL and find any
*.css links, *.js links, *.jpg/gif/png/etc images, and then use cURL
once again to download them and save them.
I'm sorry if you were hoping for some "magic function" that will do all
of that for you, but there is none. There may very well be some
pre-packaged solutions to your problem, but I don't know of any
off-hand.
Seriously, though: think like a programmer! You can get the text, and
the links to the elements you want to save are in the text. Parse it!
Parse it for all you're worth!
Todd Boyd
Web Programmer
--- End Message ---
--- Begin Message ---
Boyd, Todd M. wrote:
-----Original Message-----
From: blackwater dev [mailto:[EMAIL PROTECTED]
Sent: Sunday, June 01, 2008 9:26 PM
To: Shawn McKenzie
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] saving outside website content via php...
Yes, but file_get_contents will get me the code which I could then
echo back out to the browser but that wouldn't give me any external
images, css files or js.
Use the RegEx examples for tag-grabbing that appeared in this mailing
list last week. Parse whatever text is returned from cURL and find any
*.css links, *.js links, *.jpg/gif/png/etc images, and then use cURL
once again to download them and save them.
I'm sorry if you were hoping for some "magic function" that will do all
of that for you, but there is none. There may very well be some
pre-packaged solutions to your problem, but I don't know of any
off-hand.
Seriously, though: think like a programmer! You can get the text, and
the links to the elements you want to save are in the text. Parse it!
Parse it for all you're worth!
Todd Boyd
Web Programmer
That is one way if you're using all PHP. If you have access to wget
(most linux), then you can do it in one shell command.
'wget --convert-links -r http://www.example.com/' will get all files
recursively, save them and convert the links to point to the local files.
Also look at the --mirror option. Lot's of options/possibilities with
wget. There are bound to be some PHP classes that wrap wget somewhere.
-Shawn
--- End Message ---