Skip to content

Commit

Permalink
Add TSRM support
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdm committed Sep 13, 2010
1 parent dd5b7cd commit b3e8d8f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
25 changes: 24 additions & 1 deletion event.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ static void event_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
void php_event_callback_handler(int fd, short ev, void *arg)
{
php_event *event = (php_event*)arg;
#ifdef ZTS
TSRMLS_D = event->TSRMLS_C;
#endif
zval **params[3];
zval *retval = NULL;
//zval *z_stream;
Expand Down Expand Up @@ -618,7 +621,7 @@ void php_callback_handler(struct evhttp_request *req, void *arg)
zval *retval = NULL;
zval **params[1];
zval *req_resource;
cb = (zval*)arg;
cb = ((evhttp_callback_arg *)arg)->arg;
int res;
struct evbuffer *buf;
evhttp_response *response;
Expand All @@ -627,6 +630,10 @@ void php_callback_handler(struct evhttp_request *req, void *arg)
int res_id;
void *retval_res;
int retval_res_type;
#ifdef ZTS
TSRMLS_D = ((evhttp_callback_arg *) arg)->TSRMLS_C;
#endif


/* pass the request as a php resource */
MAKE_STD_ZVAL(req_resource);
Expand Down Expand Up @@ -732,6 +739,7 @@ PHP_FUNCTION(evhttp_set_gencb)
zval *res_httpd, *php_cb;
zval *cb;
char *callable = NULL;
evhttp_callback_arg *cb_arg = (evhttp_callback_arg *) emalloc(sizeof(evhttp_callback_arg));

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz", &res_httpd, &php_cb) == FAILURE)
{
Expand Down Expand Up @@ -1083,6 +1091,9 @@ PHP_FUNCTION(evbuffer_readline)
void callback_buffered_on_read(struct bufferevent *bev, void *arg)
{
php_bufferevent *event = (php_bufferevent*)arg;
#ifdef ZTS
TSRMLS_D = event->TSRMLS_C;
#endif
zval **params[1];
zval *retval = NULL;

Expand All @@ -1107,6 +1118,9 @@ void callback_buffered_on_read(struct bufferevent *bev, void *arg)
void callback_buffered_on_write(struct bufferevent *bev, void *arg)
{
php_bufferevent *event = (php_bufferevent*)arg;
#ifdef ZTS
TSRMLS_D = event->TSRMLS_C;
#endif
zval **params[1];
zval *retval = NULL;

Expand All @@ -1131,6 +1145,9 @@ void callback_buffered_on_write(struct bufferevent *bev, void *arg)
void callback_buffered_on_error(struct bufferevent *bev, short what, void *arg)
{
php_bufferevent *event = (php_bufferevent*)arg;
#ifdef ZTS
TSRMLS_D = event->TSRMLS_C;
#endif
zval **params[3];
zval *code;
zval *retval = NULL;
Expand Down Expand Up @@ -1483,6 +1500,9 @@ PHP_FUNCTION(evhttp_connection_new)
void callback_connection_on_close(struct evhttp_connection *con, void *arg)
{
php_httpcon *connection = (php_httpcon*)arg;
#ifdef ZTS
TSRMLS_D = connection->TSRMLS_C;
#endif
zval **params[1];
zval *retval = NULL;

Expand Down Expand Up @@ -1565,6 +1585,9 @@ PHP_FUNCTION(evhttp_connection_set_closecb)
void callback_request_on_complete(struct evhttp_request *req, void *arg)
{
php_httpevent *event = (php_httpevent*)arg;
#ifdef ZTS
TSRMLS_D = event->TSRMLS_C;
#endif
zval **params[1];
zval *retval = NULL;

Expand Down
23 changes: 23 additions & 0 deletions php_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ typedef struct _php_event
zval *cb;
zval *flags;
zval *event;
#ifdef ZTS
TSRMLS_D;
#endif
} php_event;

/*
Expand All @@ -202,6 +205,9 @@ typedef struct _php_bufferevent
zval *r_cb;
zval *w_cb;
zval *e_cb;
#ifdef ZTS
TSRMLS_D;
#endif
} php_bufferevent;

/*
Expand All @@ -211,6 +217,9 @@ typedef struct _php_httpevent
{
zval *res_httpevent;
zval *r_cb;
#ifdef ZTS
TSRMLS_D;
#endif
} php_httpevent;

/*
Expand All @@ -220,6 +229,9 @@ typedef struct _php_httpcon
{
zval *res_httpcon;
zval *c_cb;
#ifdef ZTS
TSRMLS_D;
#endif
} php_httpcon;

/*
Expand All @@ -233,8 +245,19 @@ typedef struct _evhttp_response
char* res_message;
char* res_body;
int res_body_len;
#ifdef ZTS
TSRMLS_D;
#endif
} evhttp_response;

typedef struct _evhttp_callback_arg
{
zval *arg;
#ifdef ZTS
TSRMLS_D;
#endif
} evhttp_callback_arg;

#endif /* PHP_EVENT_H */


Expand Down

0 comments on commit b3e8d8f

Please sign in to comment.