Skip to content

Commit d5e34e8

Browse files
committed
fix graceful
"apachctl graceful" was failing: we'd lock during restart. This extension was being unloaded, which in turn unloaded libvips (since only we referenced it), but glib was not being unloaded, since other things used by apache were still using it. As a result, on reload of this extension, libvips would try to init, and discover that parts of its previous init were still there, such as the VipsObject type. Fix: lock libvips in memory to prevent unload. See libvips/php-vips#26
1 parent 7a0df15 commit d5e34e8

File tree

7 files changed

+38
-8
lines changed

7 files changed

+38
-8
lines changed

Diff for: ChangeLog

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
vips extension changelog
22

3-
dev
4-
---
3+
Version 1.0.3 (2016-12-27)
4+
--------------------------
55
* Lower min vips version to 8.2, see #4
6+
* Lock libvips to fix graceful, see https://github.com/jcupitt/php-vips/issues/26
67

78
Version 1.0.2 (2016-12-06)
89
--------------------------

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ libvips website, or build your own.
9191
$ pear package
9292
```
9393

94-
to make `vips-1.0.2.tgz`.
94+
to make `vips-1.0.3.tgz`.
9595

9696
To install by hand:
9797

Diff for: RELEASE-1.0.2 renamed to RELEASE-1.0.3

File renamed without changes.

Diff for: package.xml

+13-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
1515
<email>[email protected]</email>
1616
<active>yes</active>
1717
</lead>
18-
<date>2016-12-06</date>
18+
<date>2016-12-27</date>
1919
<version>
20-
<release>1.0.2</release>
20+
<release>1.0.3</release>
2121
<api>1.0.0</api>
2222
</version>
2323
<stability>
@@ -34,7 +34,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
3434
<file role='doc' name='CREDITS'/>
3535
<file role='doc' name='LICENSE.txt'/>
3636
<file role='doc' name='README.md'/>
37-
<file role='doc' name='RELEASE-1.0.2'/>
37+
<file role='doc' name='RELEASE-1.0.3'/>
3838
<file role='doc' name='ChangeLog'/>
3939

4040
<file role='src' name='config.m4'/>
@@ -89,6 +89,16 @@ http://pear.php.net/dtd/package-2.0.xsd">
8989
</extsrcrelease>
9090
<changelog>
9191

92+
<release>
93+
<stability><release>stable</release><api>stable</api></stability>
94+
<version><release>1.0.3</release><api>1.0.0</api></version>
95+
<date>2016-12-27</date>
96+
<notes>
97+
* Lower min vips version to 8.2, see #4
98+
* Lock libvips to fix graceful, see https://github.com/jcupitt/php-vips/issues/26
99+
</notes>
100+
</release>
101+
92102
<release>
93103
<stability><release>stable</release><api>stable</api></stability>
94104
<version><release>1.0.2</release><api>1.0.0</api></version>

Diff for: php_vips.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
extern zend_module_entry vips_module_entry;
66
#define phpext_vips_ptr &vips_module_entry
77

8-
#define PHP_VIPS_VERSION "1.0.2"
8+
#define PHP_VIPS_VERSION "1.0.3"
99

1010
#ifdef PHP_WIN32
1111
# define PHP_VIPS_API __declspec(dllexport)

Diff for: vips-1.0.3.tgz

542 KB
Binary file not shown.

Diff for: vips.c

+20-1
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,23 @@ static void php_free_gobject(zend_resource *rsrc)
16211621
*/
16221622
PHP_MINIT_FUNCTION(vips)
16231623
{
1624+
/* "apachectl graceful" can cause us terrible problems. Within the main
1625+
* apache process, it will unload this extension, which in turn will unload
1626+
* libvips, since we are the only thing that references it, then reload
1627+
* again.
1628+
*
1629+
* Unfortunately, glib, which libvips uses, will often NOT get unloaded.
1630+
* When libvips then tries to init again, it'll find left-over types like
1631+
* VipsObject still registered in the system, and chaos will follow.
1632+
*
1633+
* A simple fix that will always work is just to lock libvips in memory and
1634+
* prevent unload.
1635+
*/
1636+
if (!dlopen("libvips.so", RTLD_LAZY | RTLD_NODELETE)) {
1637+
printf("php-vips-ext: unable to lock libvips -- "
1638+
"graceful may be unreliable\n");
1639+
}
1640+
16241641
/* If you have INI entries, uncomment these lines
16251642
REGISTER_INI_ENTRIES();
16261643
*/
@@ -1658,7 +1675,9 @@ PHP_MSHUTDOWN_FUNCTION(vips)
16581675
printf( "php-vips-ext shutdown\n" );
16591676
#endif /*VIPS_DEBUG*/
16601677

1661-
vips_shutdown();
1678+
/* We must not call vips_shutdown() since we've locked libvips in memory
1679+
* and will need to reuse it if we restart via graceful.
1680+
*/
16621681

16631682
return SUCCESS;
16641683
}

0 commit comments

Comments
 (0)