Skip to content

Commit

Permalink
Merge 3f6bc8a into ea30463
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpbloch committed Feb 12, 2021
2 parents ea30463 + 3f6bc8a commit 23af849
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
@@ -1,18 +1,20 @@
language: php
php:
- 8.0
- 7.3
- 7.2
- 7.1
- 7.0

env:
- LIBZOOKEEPER_VERSION=3.5.5
- LIBZOOKEEPER_VERSION=3.5.9
- LIBZOOKEEPER_VERSION=3.4.14

addons:
apt:
packages:
- lcov
- ant

sudo: false

Expand Down
13 changes: 8 additions & 5 deletions .travis/install_libzookeeper.sh
Expand Up @@ -5,14 +5,15 @@ LIBZOOKEEPER_MAJOR_VERSION=`echo ${LIBZOOKEEPER_VERSION} | awk -F'.' '{print $1}
LIBZOOKEEPER_MINOR_VERSION=`echo ${LIBZOOKEEPER_VERSION} | awk -F'.' '{print $2}'`
LIBZOOKEEPER_PATCH_VERSION=`echo ${LIBZOOKEEPER_VERSION} | awk -F'.' '{print $3}'`

if [ ${LIBZOOKEEPER_MAJOR_VERSION} -ge 3 -a ${LIBZOOKEEPER_MINOR_VERSION} -ge 5 -a ${LIBZOOKEEPER_PATCH_VERSION} -ge 5 ]; then
if [ ${LIBZOOKEEPER_MAJOR_VERSION} -ge 3 -a ${LIBZOOKEEPER_MINOR_VERSION} -ge 5 -a ${LIBZOOKEEPER_PATCH_VERSION} -ge 9 ]; then
PACKAGE_NAME=apache-zookeeper-${LIBZOOKEEPER_VERSION}
URL_PREFIX=http://apache.mirrors.lucidnetworks.net/zookeeper
else
PACKAGE_NAME=zookeeper-${LIBZOOKEEPER_VERSION}
URL_PREFIX=http://archive.apache.org/dist/zookeeper
fi
URL_DIR_NAME=zookeeper-${LIBZOOKEEPER_VERSION}
LIBZOOKEEPER_PREFIX=${HOME}/lib${URL_DIR_NAME}
URL_PREFIX=http://apache.mirrors.lucidnetworks.net/zookeeper

TRAVIS_SCRIPT_DIR=$(cd $(dirname $0); pwd)

Expand All @@ -35,11 +36,13 @@ else
${PACKAGE_NAME}/bin/zkServer.sh start
fi

if [ ${LIBZOOKEEPER_MAJOR_VERSION} -ge 3 -a ${LIBZOOKEEPER_MINOR_VERSION} -ge 5 -a ${LIBZOOKEEPER_PATCH_VERSION} -ge 5 ]; then
cd ${PACKAGE_NAME}/zookeeper-client/zookeeper-client-c
if [ ${LIBZOOKEEPER_MAJOR_VERSION} -ge 3 -a ${LIBZOOKEEPER_MINOR_VERSION} -ge 5 -a ${LIBZOOKEEPER_PATCH_VERSION} -ge 9 ]; then
cd ${PACKAGE_NAME}
ant compile_jute
cd zookeeper-client/zookeeper-client-c
autoreconf -if
else
cd ${PACKAGE_NAME}/src/c
cd ${PACKAGE_NAME}/zookeeper-client/zookeeper-client-c
fi
./configure --prefix=${LIBZOOKEEPER_PREFIX} || exit 1
make || exit 1
Expand Down
18 changes: 11 additions & 7 deletions php_zookeeper.c
Expand Up @@ -76,7 +76,9 @@ static zend_class_entry *zookeeper_ce = NULL;

static zend_object_handlers zookeeper_obj_handlers;

#if HAVE_PTHREAD
static pthread_mutex_t cb_lock = PTHREAD_MUTEX_INITIALIZER;
#endif

#ifdef HAVE_ZOOKEEPER_SESSION
static int le_zookeeper_connection;
Expand Down Expand Up @@ -105,7 +107,7 @@ static void php_zk_close(php_zk_t *i_obj TSRMLS_DC);
Async
****************************************/

#if PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1
#if PHP_VERSION_ID >= 70100
static void (*orig_interrupt_function)(zend_execute_data *execute_data);
static void php_zk_interrupt_function(zend_execute_data *execute_data)
{
Expand Down Expand Up @@ -852,7 +854,7 @@ zend_object* php_zk_new(zend_class_entry *ce TSRMLS_DC)
object_properties_init(&i_obj->zo, ce);
i_obj->zo.handlers = &zookeeper_obj_handlers;

zend_hash_init_ex(&i_obj->callbacks, 5, NULL, (dtor_func_t)php_cb_data_zv_destroy, 0, 0);
zend_hash_init(&i_obj->callbacks, 5, NULL, (dtor_func_t)php_cb_data_zv_destroy, 0);

return &i_obj->zo;
}
Expand Down Expand Up @@ -1003,7 +1005,7 @@ void php_zk_watcher_marshal(zhandle_t *zk, int type, int state, const char *path
ZK_G(tail) = p;
ZK_G(pending_marshals) = 1;

#if PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1
#if PHP_VERSION_ID >= 70100
EG(vm_interrupt) = 1;
#endif

Expand Down Expand Up @@ -1047,7 +1049,7 @@ static void php_zk_completion_marshal(int rc, const void *context)
ZK_G(tail) = p;
ZK_G(pending_marshals) = 1;

#if PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1
#if PHP_VERSION_ID >= 70100
EG(vm_interrupt) = 1;
#endif

Expand Down Expand Up @@ -1154,7 +1156,7 @@ zend_class_entry *php_zk_get_ce(void)
/* }}} */

/* {{{ methods arginfo */
ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, 0, 0, 1)
ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, 0, 0, 0)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, watcher_cb)
ZEND_ARG_INFO(0, recv_timeout)
Expand Down Expand Up @@ -1187,6 +1189,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_get, 0, 0, 1)
ZEND_ARG_INFO(0, path)
ZEND_ARG_INFO(0, watcher_cb)
ZEND_ARG_INFO(1, stat_info)
ZEND_ARG_INFO(0, max_size)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_exists, 0, 0, 1)
Expand All @@ -1205,6 +1208,7 @@ ZEND_BEGIN_ARG_INFO(arginfo_getClientId, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_getAcl, 0)
ZEND_ARG_INFO(0, path)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_setAcl, 0)
Expand Down Expand Up @@ -1302,7 +1306,7 @@ static zend_function_entry zookeeper_class_methods[] = {

/* {{{ zookeeper_function_entry */
static const zend_function_entry zookeeper_functions[] = {
PHP_FE(zookeeper_dispatch, NULL)
PHP_FE(zookeeper_dispatch, arginfo_dispatch)
PHP_FE_END
};
/* }}} */
Expand Down Expand Up @@ -1467,7 +1471,7 @@ PHP_MINIT_FUNCTION(zookeeper)
php_zk_config_register(TSRMLS_C);
#endif

#if PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1
#if PHP_VERSION_ID >= 70100
orig_interrupt_function = zend_interrupt_function;
zend_interrupt_function = php_zk_interrupt_function;
#else
Expand Down
8 changes: 8 additions & 0 deletions php_zookeeper.h
Expand Up @@ -34,6 +34,14 @@ extern zend_module_entry zookeeper_module_entry;
#define PHP_ZOOKEEPER_API
#endif

#ifndef TSRMLS_D
#define TSRMLS_D void
#define TSRMLS_DC
#define TSRMLS_C
#define TSRMLS_CC
#define TSRMLS_FETCH()
#endif

struct php_zk_pending_marshal {
struct php_zk_pending_marshal *next;
struct _php_cb_data_t *cb_data;
Expand Down
8 changes: 8 additions & 0 deletions php_zookeeper_callback.h
Expand Up @@ -20,6 +20,14 @@
#include <zookeeper.h>
#include <php.h>

#ifndef TSRMLS_D
#define TSRMLS_D void
#define TSRMLS_DC
#define TSRMLS_C
#define TSRMLS_CC
#define TSRMLS_FETCH()
#endif

typedef struct _php_cb_data_t {
zend_fcall_info fci;
zend_fcall_info_cache fcc;
Expand Down
2 changes: 1 addition & 1 deletion tests/retrieve_node_with_watcher_callback.phpt
Expand Up @@ -13,7 +13,7 @@ class Test extends Zookeeper

public function watcher($i, $type, $key)
{
$this->get($this->path, array($this, 'watcher'));
$this->exists($this->path, array($this, 'watcher'));
}

public function setPath(string $path): void
Expand Down
5 changes: 5 additions & 0 deletions tests/set_null_value_and_stats_in_node.phpt
Expand Up @@ -8,6 +8,11 @@ if (!extension_loaded('zookeeper'))
--FILE--
<?php
$client = new Zookeeper('localhost:2181');

if ($client->exists('/tes')) {
$client->delete('/tes');
}

$client->create('/tes', null, array(
array(
'perms' => Zookeeper::PERM_ALL,
Expand Down
5 changes: 5 additions & 0 deletions tests/should_set_acl.phpt
Expand Up @@ -8,6 +8,11 @@ if (!extension_loaded('zookeeper'))
--FILE--
<?php
$client = new Zookeeper('localhost:2181');

if ($client->exists('/tes')) {
$client->delete('/tes');
}

$client->create('/tes', null, array(
array(
'perms' => Zookeeper::PERM_ALL,
Expand Down

0 comments on commit 23af849

Please sign in to comment.