Browse Source

copy md5 digest correctly in notmemcpy mode

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@840 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 10 years ago
parent
commit
2ccf0e5dbf
  1. 4
      processor/dispatch.m4
  2. 8
      xcache.c
  3. 4
      xcache.h

4
processor/dispatch.m4

@ -23,7 +23,7 @@ define(`DISPATCH', `
, `$1', `zval_data_type', `PROC_INT(`$2', `u', `$1')'
, `$1', `xc_entry_type_t', `PROC_INT(`$2', `d', `$1')'
, `$1', `xc_hash_value_t', `PROC_INT(`$2', `lu', `$1')'
, `$1', `xc_md5sum_t', `/* is copying enough? */COPY(`$2')'
, `$1', `xc_md5sum_t', `COPY(`$2')'
, `', `', `m4_errprint(`Unknown type "$1"')'
)
')
@ -38,7 +38,7 @@ define(`DISPATCH_ARRAY', `
for (i = 0; i < src->$1; i ++) {
ifelse(
`$2', `zend_bool', `add_assoc_bool_ex(arr, ZEND_STRS("$3"), src->$3[i] ? 1 : 0);'
, `', `', `add_assoc_long_ex(arr, ZEND_STRS("$3"), src->$3[i]);')
, `', `', `add_next_index_long(arr, src->$3[i]);')
}
add_assoc_zval_ex(dst, ZEND_STRS("$3"), arr);
', `

8
xcache.c

@ -145,7 +145,7 @@ static xc_entry_data_php_t *xc_php_find_dmz(xc_entry_data_php_t *php TSRMLS_DC)
{
xc_entry_data_php_t *p;
for (p = php->cache->phps[php->hvalue]; p; p = p->next) {
if (memcmp(php->md5, p->md5, sizeof(php->md5)) == 0) {
if (memcmp(&php->md5, &p->md5, sizeof(php->md5)) == 0) {
p->hits ++;
return p;
}
@ -169,7 +169,7 @@ static void xc_php_release_dmz(xc_entry_data_php_t *php) /* {{{ */
xc_entry_data_php_t **pp = &(php->cache->phps[php->hvalue]);
xc_entry_data_php_t *p;
for (p = *pp; p; pp = &(p->next), p = p->next) {
if (memcmp(php->md5, p->md5, sizeof(php->md5)) == 0) {
if (memcmp(&php->md5, &p->md5, sizeof(php->md5)) == 0) {
/* unlink */
*pp = p->next;
xc_php_free_dmz(php);
@ -1087,7 +1087,7 @@ stat_done:
/* }}} */
static inline xc_hash_value_t xc_php_hash_md5(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */
{
return HASH_STR_S(php->md5, sizeof(php->md5));
return HASH_STR_S(&php->md5, sizeof(php->md5));
}
/* }}} */
static int xc_entry_init_key_php_md5(xc_entry_data_php_t *php, xc_entry_t *xce TSRMLS_DC) /* {{{ */
@ -1108,7 +1108,7 @@ static int xc_entry_init_key_php_md5(xc_entry_data_php_t *php, xc_entry_t *xce T
while ((n = php_stream_read(stream, (char *) buf, sizeof(buf))) > 0) {
PHP_MD5Update(&context, buf, n);
}
PHP_MD5Final((unsigned char *) php->md5, &context);
PHP_MD5Final((unsigned char *) php->md5.digest, &context);
php_stream_close(stream);
if (EG(regular_list).nNextFreeElement == old_rsid + 1) {

4
xcache.h

@ -342,7 +342,9 @@ typedef struct {
/* }}} */
#endif
typedef enum { XC_TYPE_PHP, XC_TYPE_VAR } xc_entry_type_t;
typedef char xc_md5sum_t[16];
typedef struct {
char digest[16];
} xc_md5sum_t;
/* {{{ xc_compilererror_t */
typedef struct {
int type;

Loading…
Cancel
Save