cvs: pecl /memcache memcache.c
| From: | Antony Dovgal | Date: | Tue, 02 Mar 2004 08:08:51 +0000 |
| Subject: | cvs: pecl /memcache memcache.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-997@lists.php.net to get a copy of this message | ||
tony2001 Tue Mar 2 03:08:51 2004 EDT
Modified files:
/pecl/memcache memcache.c
Log:
this should fix build failure with PHP_4_3 branch
persistent connections should work both with HEAD and branch
http://cvs.php.net/diff.php/pecl/memcache/memcache.c?r1=1.5&r2=1.6&ty=u
Index: pecl/memcache/memcache.c
diff -u pecl/memcache/memcache.c:1.5 pecl/memcache/memcache.c:1.6
--- pecl/memcache/memcache.c:1.5 Mon Mar 1 01:46:03 2004
+++ pecl/memcache/memcache.c Tue Mar 2 03:08:50 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: memcache.c,v 1.5 2004/03/01 06:46:03 tony2001 Exp $ */
+/* $Id: memcache.c,v 1.6 2004/03/02 08:08:50 tony2001 Exp $ */
/* TODO
* - should we add a compression support ? bzip || gzip ?
@@ -216,7 +216,7 @@
php_info_print_table_start();
php_info_print_table_header(2, "memcache support", "enabled");
php_info_print_table_row(2, "Active persistent connections", buf);
- php_info_print_table_row(2, "Revision", "$Revision: 1.5 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.6 $");
php_info_print_table_end();
}
/* }}} */
@@ -306,19 +306,42 @@
else {
mmc = emalloc( sizeof(mmc_t) );
}
+
+ mmc->stream = NULL;
+#if PHP_API_VERSION > 20020918
mmc->stream = php_stream_xport_create( hostname, hostname_len,
ENFORCE_SAFE_MODE | REPORT_ERRORS,
STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,
hash_key, &tv, NULL, &errstr, &err);
-
+#else
+ if (persistent) {
+ switch(php_stream_from_persistent_id(hash_key, &(mmc->stream) TSRMLS_CC)) {
+ case PHP_STREAM_PERSISTENT_SUCCESS:
+ if (!_php_network_is_stream_alive(mmc->stream TSRMLS_CC)) {
+ php_stream_pclose(mmc->stream);
+ mmc->stream = NULL;
+ break;
+ }
+ case PHP_STREAM_PERSISTENT_FAILURE:
+ break;
+ }
+ }
+
+ if (!mmc->stream) {
+ int socktype = SOCK_STREAM;
+ mmc->stream = php_stream_sock_open_host(host, (unsigned short)port, socktype, &tv,
hash_key);
+ }
+
+#endif
+
efree(hostname);
if (hash_key) {
efree(hash_key);
}
- if (mmc->stream == NULL) {
+ if (!mmc->stream) {
mmc_debug("mmc_open: can't open socket to host");
efree(mmc);
return NULL;
@@ -351,7 +374,12 @@
if (mmc->stream) {
mmc_sendcmd(mmc,"quit", 4);
- php_stream_close(mmc->stream);
+ if (mmc->persistent) {
+ php_stream_pclose(mmc->stream);
+ }
+ else {
+ php_stream_close(mmc->stream);
+ }
}
mmc->stream = NULL;