Skip to content

Commit e5f0ab9

Browse files
author
Andrei Zmievski
committed
Session lock wait is initialized to max execution time.
1 parent 1c2e014 commit e5f0ab9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

php_memcached.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,22 +2358,29 @@ static int php_memc_do_result_callback(zval *memc_obj, zend_fcall_info *fci,
23582358
/* {{{ session support */
23592359
#if HAVE_MEMCACHED_SESSION
23602360

2361-
#define MEMC_SESS_LOCK_ATTEMPTS 30
2362-
#define MEMC_SESS_LOCK_WAIT 100000
2361+
#define MEMC_SESS_LOCK_WAIT 150000
23632362
#define MEMC_SESS_LOCK_EXPIRATION 30
23642363

23652364
ps_module ps_mod_memcached = {
23662365
PS_MOD(memcached)
23672366
};
23682367

2369-
23702368
static int php_memc_sess_lock(memcached_st *memc, const char *key TSRMLS_DC)
23712369
{
23722370
char *lock_key = NULL;
23732371
int lock_key_len = 0;
2374-
int attempts = MEMC_SESS_LOCK_ATTEMPTS;
2375-
time_t expiration = time(NULL) + MEMC_SESS_LOCK_EXPIRATION;
2372+
long attempts;
2373+
long lock_maxwait;
2374+
time_t expiration;
23762375
memcached_return status;
2376+
/* set max timeout for session_start = max_execution_time. (c) Andrei Darashenka, Richter & Poweleit GmbH */
2377+
2378+
lock_maxwait = zend_ini_long(ZEND_STRL("max_execution_time"), 0);
2379+
if (lock_maxwait <= 0) {
2380+
lock_maxwait = MEMC_SESS_LOCK_EXPIRATION;
2381+
}
2382+
expiration = time(NULL) + lock_maxwait + 1;
2383+
attempts = lock_maxwait * 1000000 / MEMC_SESS_LOCK_WAIT;
23772384

23782385
lock_key_len = spprintf(&lock_key, 0, "memc.sess.lock_key.%s", key);
23792386
while (attempts--) {

0 commit comments

Comments
 (0)