Browse Source

move open_files out of sandbox, it's not needed

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@131 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
1.1
Xuefer 15 years ago
parent
commit
76174b4273
  1. 11
      utils.c
  2. 2
      utils.h
  3. 8
      xcache.c

11
utils.c

@ -370,7 +370,6 @@ xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /
}
memcpy(&OG(included_files), &EG(included_files), sizeof(EG(included_files)));
memcpy(&OG(open_files), &CG(open_files), sizeof(CG(open_files)));
#ifdef HAVE_XCACHE_CONSTANT
OG(zend_constants) = EG(zend_constants);
@ -387,9 +386,7 @@ xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /
EG(class_table) = CG(class_table);
TG(included_files) = &EG(included_files);
TG(open_files) = &CG(open_files);
zend_llist_init(TG(open_files), sizeof(zend_file_handle), (void (*)(void *)) zend_file_handle_dtor, 0);
zend_hash_init_ex(TG(included_files), 5, NULL, NULL, 0, 1);
#ifdef HAVE_XCACHE_CONSTANT
zend_hash_init_ex(&TG(zend_constants), 20, NULL, ZEND_CONSTANT_DTOR, 1, 0);
@ -439,11 +436,6 @@ static void xc_sandbox_install(xc_sandbox_t *sandbox TSRMLS_DC) /* {{{ */
i = 1;
zend_hash_add(&OG(included_files), sandbox->filename, strlen(sandbox->filename) + 1, (void *)&i, sizeof(int), NULL);
for (handle = zend_llist_get_first_ex(TG(open_files), &lpos);
handle;
handle = zend_llist_get_next_ex(TG(open_files), &lpos)) {
zend_llist_add_element(&OG(open_files), handle);
}
}
/* }}} */
void xc_sandbox_free(xc_sandbox_t *sandbox, int install TSRMLS_DC) /* {{{ */
@ -465,7 +457,6 @@ void xc_sandbox_free(xc_sandbox_t *sandbox, int install TSRMLS_DC) /* {{{ */
#endif
TG(function_table).pDestructor = NULL;
TG(class_table).pDestructor = NULL;
TG(open_files)->dtor = NULL;
}
/* destroy all the tmp */
@ -475,11 +466,9 @@ void xc_sandbox_free(xc_sandbox_t *sandbox, int install TSRMLS_DC) /* {{{ */
zend_hash_destroy(&TG(function_table));
zend_hash_destroy(&TG(class_table));
zend_hash_destroy(TG(included_files));
zend_llist_destroy(TG(open_files));
/* restore orig here, as EG/CG holded tmp before */
memcpy(&EG(included_files), &OG(included_files), sizeof(EG(included_files)));
memcpy(&CG(open_files), &OG(open_files), sizeof(CG(open_files)));
if (sandbox->alloc) {
efree(sandbox);

2
utils.h

@ -37,9 +37,7 @@ typedef struct {
char *filename;
HashTable orig_included_files;
zend_llist orig_open_files;
HashTable *tmp_included_files;
zend_llist *tmp_open_files;
#ifdef HAVE_XCACHE_CONSTANT
HashTable *orig_zend_constants;

8
xcache.c

@ -558,7 +558,9 @@ static zend_op_array *xc_entry_install(xc_entry_t *xce, zend_file_handle *h TSRM
i = 1;
zend_hash_add(&EG(included_files), xce->name.str.val, xce->name.str.len+1, (void *)&i, sizeof(int), NULL);
zend_llist_add_element(&CG(open_files), h);
if (h) {
zend_llist_add_element(&CG(open_files), h);
}
#ifndef ZEND_ENGINE_2
free_alloca(new_cest_ptrs);
@ -938,9 +940,8 @@ err_oparray:
err_bailout:
if (xc_test && stored_xce) {
/* no install, keep open_files too for h */
/* free it, no install. restore now */
xc_sandbox_free(&sandbox, 0 TSRMLS_CC);
sandbox.tmp_open_files->dtor = NULL;
}
else {
xc_sandbox_free(&sandbox, 1 TSRMLS_CC);
@ -955,6 +956,7 @@ err_bailout:
if (xc_test && stored_xce) {
destroy_op_array(op_array TSRMLS_CC);
efree(op_array);
h = NULL;
goto restore;
}
return op_array;

Loading…
Cancel
Save