Skip to content

Commit 5735f7f

Browse files
committed
Added more server stuff, added examples of server
1 parent 36608f3 commit 5735f7f

7 files changed

+394
-83
lines changed

Diff for: config.m4

+1
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ if test "$PHP_MEMCACHED" != "no"; then
346346
fi
347347

348348
PHP_ADD_LIBRARY_WITH_PATH(memcachedprotocol, $PHP_LIBMEMCACHED_DIR/$PHP_LIBDIR, MEMCACHED_SHARED_LIBADD)
349+
PHP_ADD_LIBRARY_WITH_PATH(event, $PHP_LIBMEMCACHED_DIR/$PHP_LIBDIR, MEMCACHED_SHARED_LIBADD)
349350

350351
PHP_NEW_EXTENSION(memcached, $PHP_MEMCACHED_FILES, $ext_shared,,$SESSION_INCLUDES $IGBINARY_INCLUDES)
351352
PHP_ADD_BUILD_DIR($ext_builddir/fastlz, 1)

Diff for: php_memcached.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -3418,10 +3418,16 @@ static int php_memc_do_result_callback(zval *zmemc_obj, zend_fcall_info *fci,
34183418
static
34193419
PHP_METHOD(MemcachedServer, run)
34203420
{
3421+
char *address;
3422+
int address_len;
3423+
34213424
php_memc_server_t *intern;
34223425
intern = (php_memc_server_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
34233426

3424-
php_memc_proto_handler_run (intern->handler);
3427+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &address, &address_len) == FAILURE) {
3428+
return;
3429+
}
3430+
php_memc_proto_handler_run (intern->handler, address);
34253431
}
34263432

34273433

@@ -3446,8 +3452,8 @@ PHP_METHOD(MemcachedServer, on)
34463452
}
34473453

34483454
if (fci.size > 0) {
3449-
MEMC_G(server_callbacks) [event].fci = fci;
3450-
MEMC_G(server_callbacks) [event].fci_cache = fci_cache;
3455+
MEMC_G(server.callbacks) [event].fci = fci;
3456+
MEMC_G(server.callbacks) [event].fci_cache = fci_cache;
34513457

34523458
Z_ADDREF_P (fci.function_name);
34533459
if (fci.object_ptr) {
@@ -4042,6 +4048,7 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
40424048
/*
40434049
* Server callbacks
40444050
*/
4051+
REGISTER_MEMC_CLASS_CONST_LONG(ON_CONNECT, MEMC_SERVER_ON_CONNECT);
40454052
REGISTER_MEMC_CLASS_CONST_LONG(ON_ADD, MEMC_SERVER_ON_ADD);
40464053
REGISTER_MEMC_CLASS_CONST_LONG(ON_APPEND, MEMC_SERVER_ON_APPEND);
40474054
REGISTER_MEMC_CLASS_CONST_LONG(ON_DECREMENT, MEMC_SERVER_ON_DECREMENT);

Diff for: php_memcached.h

+18-15
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,21 @@ enum memcached_serializer {
6060

6161
typedef enum {
6262
MEMC_SERVER_ON_MIN = -1,
63-
MEMC_SERVER_ON_ADD = 0,
64-
MEMC_SERVER_ON_APPEND = 1,
65-
MEMC_SERVER_ON_DECREMENT = 2,
66-
MEMC_SERVER_ON_DELETE = 3,
67-
MEMC_SERVER_ON_FLUSH = 4,
68-
MEMC_SERVER_ON_GET = 5,
69-
MEMC_SERVER_ON_INCREMENT = 6,
70-
MEMC_SERVER_ON_NOOP = 7,
71-
MEMC_SERVER_ON_PREPEND = 8,
72-
MEMC_SERVER_ON_QUIT = 9,
73-
MEMC_SERVER_ON_REPLACE = 10,
74-
MEMC_SERVER_ON_SET = 11,
75-
MEMC_SERVER_ON_STAT = 12,
76-
MEMC_SERVER_ON_VERSION = 13,
63+
MEMC_SERVER_ON_CONNECT = 0,
64+
MEMC_SERVER_ON_ADD = 1,
65+
MEMC_SERVER_ON_APPEND = 2,
66+
MEMC_SERVER_ON_DECREMENT = 3,
67+
MEMC_SERVER_ON_DELETE = 4,
68+
MEMC_SERVER_ON_FLUSH = 5,
69+
MEMC_SERVER_ON_GET = 6,
70+
MEMC_SERVER_ON_INCREMENT = 7,
71+
MEMC_SERVER_ON_NOOP = 8,
72+
MEMC_SERVER_ON_PREPEND = 9,
73+
MEMC_SERVER_ON_QUIT = 10,
74+
MEMC_SERVER_ON_REPLACE = 11,
75+
MEMC_SERVER_ON_SET = 12,
76+
MEMC_SERVER_ON_STAT = 13,
77+
MEMC_SERVER_ON_VERSION = 14,
7778
MEMC_SERVER_ON_MAX
7879
} php_memc_event_t;
7980

@@ -119,7 +120,9 @@ ZEND_BEGIN_MODULE_GLOBALS(php_memcached)
119120
bool use_sasl;
120121
#endif
121122

122-
php_memc_server_cb_t server_callbacks [14];
123+
struct {
124+
php_memc_server_cb_t callbacks [14];
125+
} server;
123126
ZEND_END_MODULE_GLOBALS(php_memcached)
124127

125128
PHP_MEMCACHED_API zend_class_entry *php_memc_get_ce(void);

0 commit comments

Comments
 (0)