|
cvs: pecl /apc apc_cache.c apc_fcntl.c apc_fcntl.h apc_lock.h apc_sma.c: msg#00250php.pecl.cvs
rasmus Thu Jul 28 19:10:33 2005 EDT Modified files: /pecl/apc apc_cache.c apc_fcntl.c apc_fcntl.h apc_lock.h apc_sma.c Log: Try to make the fcntl locking more robust by blocking Apache1 signals in the allocator and also retrying on an EINTR. Also added fcntl RDLOCK on read-only cache info calls. http://cvs.php.net/diff.php/pecl/apc/apc_cache.c?r1=3.87&r2=3.88&ty=u Index: pecl/apc/apc_cache.c diff -u pecl/apc/apc_cache.c:3.87 pecl/apc/apc_cache.c:3.88 --- pecl/apc/apc_cache.c:3.87 Sun Jul 24 16:44:03 2005 +++ pecl/apc/apc_cache.c Thu Jul 28 19:10:31 2005 @@ -28,7 +28,7 @@ */ -/* $Id: apc_cache.c,v 3.87 2005/07/24 20:44:03 rasmus Exp $ */ +/* $Id: apc_cache.c,v 3.88 2005/07/28 23:10:31 rasmus Exp $ */ #include "apc_cache.h" #include "apc_lock.h" @@ -42,6 +42,7 @@ #define CREATE_LOCK apc_lck_create(NULL, 0, 1) #define DESTROY_LOCK(c) apc_lck_destroy(c->lock) #define LOCK(c) { HANDLE_BLOCK_INTERRUPTIONS(); apc_lck_lock(c->lock); } +#define RDLOCK(c) { HANDLE_BLOCK_INTERRUPTIONS(); apc_lck_rdlock(c->lock); } #define UNLOCK(c) { apc_lck_unlock(c->lock); HANDLE_UNBLOCK_INTERRUPTIONS(); } /* }}} */ @@ -752,7 +753,7 @@ if(!cache) return NULL; - LOCK(cache); + RDLOCK(cache); info = (apc_cache_info_t*) apc_emalloc(sizeof(apc_cache_info_t)); if(!info) { http://cvs.php.net/diff.php/pecl/apc/apc_fcntl.c?r1=3.21&r2=3.22&ty=u Index: pecl/apc/apc_fcntl.c diff -u pecl/apc/apc_fcntl.c:3.21 pecl/apc/apc_fcntl.c:3.22 --- pecl/apc/apc_fcntl.c:3.21 Thu Jul 7 23:55:00 2005 +++ pecl/apc/apc_fcntl.c Thu Jul 28 19:10:32 2005 @@ -25,7 +25,7 @@ */ -/* $Id: apc_fcntl.c,v 3.21 2005/07/08 03:55:00 rasmus Exp $ */ +/* $Id: apc_fcntl.c,v 3.22 2005/07/28 23:10:32 rasmus Exp $ */ #include "apc_fcntl.h" #include "apc.h" @@ -64,28 +64,39 @@ close(fd); } -int lock_reg(int fd, int cmd, int type, off_t offset, int whence, off_t len) +static int lock_reg(int fd, int cmd, int type, off_t offset, int whence, off_t len) { + int ret; struct flock lock; lock.l_type = type; lock.l_start = offset; lock.l_whence = whence; lock.l_len = len; + lock.l_pid = 0; - return( fcntl(fd, cmd, &lock) ); + do { ret = fcntl(fd, cmd, &lock) ; } + while(ret < 0 && errno == EINTR); + return(ret); } void apc_fcntl_lock(int fd) { - if(lock_reg(fd, F_SETLKW, F_WRLCK, 0, SEEK_SET, 1) < 0) { + if(lock_reg(fd, F_SETLKW, F_WRLCK, 0, SEEK_SET, 0) < 0) { apc_eprint("apc_fcntl_lock failed errno:%d", errno); } } +void apc_fcntl_rdlock(int fd) +{ + if(lock_reg(fd, F_SETLKW, F_RDLCK, 0, SEEK_SET, 0) < 0) { + apc_eprint("apc_fcntl_rdlock failed errno:%d", errno); + } +} + void apc_fcntl_unlock(int fd) { - if(lock_reg(fd, F_SETLK, F_UNLCK, 0, SEEK_SET, 1) < 0) { + if(lock_reg(fd, F_SETLKW, F_UNLCK, 0, SEEK_SET, 0) < 0) { apc_eprint("apc_fcntl_unlock failed errno:%d", errno); } } http://cvs.php.net/diff.php/pecl/apc/apc_fcntl.h?r1=3.11&r2=3.12&ty=u Index: pecl/apc/apc_fcntl.h diff -u pecl/apc/apc_fcntl.h:3.11 pecl/apc/apc_fcntl.h:3.12 --- pecl/apc/apc_fcntl.h:3.11 Thu Jun 23 05:10:36 2005 +++ pecl/apc/apc_fcntl.h Thu Jul 28 19:10:32 2005 @@ -25,7 +25,7 @@ */ -/* $Id: apc_fcntl.h,v 3.11 2005/06/23 09:10:36 rasmus Exp $ */ +/* $Id: apc_fcntl.h,v 3.12 2005/07/28 23:10:32 rasmus Exp $ */ #ifndef APC_FCNTL_H #define APC_FCNTL_H @@ -34,6 +34,7 @@ extern int apc_fcntl_create(const char* pathname); extern void apc_fcntl_destroy(int semid); extern void apc_fcntl_lock(int semid); +extern void apc_fcntl_rdlock(int semid); extern void apc_fcntl_unlock(int semid); #endif http://cvs.php.net/diff.php/pecl/apc/apc_lock.h?r1=3.9&r2=3.10&ty=u Index: pecl/apc/apc_lock.h diff -u pecl/apc/apc_lock.h:3.9 pecl/apc/apc_lock.h:3.10 --- pecl/apc/apc_lock.h:3.9 Wed Jun 29 10:00:10 2005 +++ pecl/apc/apc_lock.h Thu Jul 28 19:10:32 2005 @@ -26,7 +26,7 @@ */ -/* $Id: apc_lock.h,v 3.9 2005/06/29 14:00:10 sniper Exp $ */ +/* $Id: apc_lock.h,v 3.10 2005/07/28 23:10:32 rasmus Exp $ */ #ifndef APC_LOCK #define APC_LOCK @@ -42,16 +42,19 @@ #define apc_lck_create(a,b,c) (int)tsrm_mutex_alloc() #define apc_lck_destroy(a) tsrm_mutex_free((MUTEX_T)a) #define apc_lck_lock(a) tsrm_mutex_lock((MUTEX_T)a) +#define apc_lck_rdlock(a) tsrm_mutex_lock((MUTEX_T)a) #define apc_lck_unlock(a) tsrm_mutex_unlock((MUTEX_T)a) #elif defined(APC_SEM_LOCKS) #define apc_lck_create(a,b,c) apc_sem_create(NULL,(b),(c)) #define apc_lck_destroy(a) apc_sem_destroy(a) #define apc_lck_lock(a) apc_sem_lock(a) +#define apc_lck_rdlock(a) apc_sem_lock(a) #define apc_lck_unlock(a) apc_sem_unlock(a) #else #define apc_lck_create(a,b,c) apc_fcntl_create((a)) #define apc_lck_destroy(a) apc_fcntl_destroy(a) #define apc_lck_lock(a) apc_fcntl_lock(a) +#define apc_lck_rdlock(a) apc_fcntl_rdlock(a) #define apc_lck_unlock(a) apc_fcntl_unlock(a) #endif http://cvs.php.net/diff.php/pecl/apc/apc_sma.c?r1=1.26&r2=1.27&ty=u Index: pecl/apc/apc_sma.c diff -u pecl/apc/apc_sma.c:1.26 pecl/apc/apc_sma.c:1.27 --- pecl/apc/apc_sma.c:1.26 Thu Jul 28 18:50:46 2005 +++ pecl/apc/apc_sma.c Thu Jul 28 19:10:32 2005 @@ -26,7 +26,7 @@ */ -/* $Id: apc_sma.c,v 1.26 2005/07/28 22:50:46 iliaa Exp $ */ +/* $Id: apc_sma.c,v 1.27 2005/07/28 23:10:32 rasmus Exp $ */ #include "apc_sma.h" #include "apc.h" @@ -39,8 +39,9 @@ #endif /* {{{ locking macros */ -#define LOCK(c) apc_lck_lock(c) -#define UNLOCK(c) apc_lck_unlock(c) +#define LOCK(c) { HANDLE_BLOCK_INTERRUPTIONS(); apc_lck_lock(c); } +#define RDLOCK(c) { HANDLE_BLOCK_INTERRUPTIONS(); apc_lck_rdlock(c); } +#define UNLOCK(c) { apc_lck_unlock(c); HANDLE_UNBLOCK_INTERRUPTIONS(); } /* }}} */ enum { POWER_OF_TWO_BLOCKSIZE=0 }; /* force allocated blocks to 2^n? */ @@ -373,7 +374,7 @@ return; } - assert(sma_initialized); + assert(sma_initialized); LOCK(sma_lock); for (i = 0; i < sma_numseg; i++) { @@ -410,7 +411,7 @@ info->list[i] = NULL; } - LOCK(sma_lock); + RDLOCK(sma_lock); /* For each segment */ for (i = 0; i < sma_numseg; i++) { |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | cvs: pecl /apc apc_sma.c: 00250, Ilia Alshanetsky |
|---|---|
| Next by Date: | cvs: pecl /apc apc_cache.c apc_cache.h apc_globals.h apc_main.c apc_sma.c package.xml php_apc.c: 00250, Rasmus Lerdorf |
| Previous by Thread: | cvs: pecl /apc apc_sma.ci: 00250, Ilia Alshanetsky |
| Next by Thread: | cvs: pecl /apc apc_cache.c apc_cache.h apc_globals.h apc_main.c apc_sma.c package.xml php_apc.c: 00250, Rasmus Lerdorf |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |