cvs: pecl /apc apc_cache.c apc_fcntl.c apc_sma.c
| From: | George Schlossnagle | Date: | Fri, 27 Jun 2003 16:19:19 +0000 |
| Subject: | cvs: pecl /apc apc_cache.c apc_fcntl.c apc_sma.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-340@lists.php.net to get a copy of this message | ||
gschlossnagle Fri Jun 27 12:19:19 2003 EDT
Modified files:
/pecl/apc apc_cache.c apc_fcntl.c apc_sma.c
Log:
missed a semaphore check
Index: pecl/apc/apc_cache.c
diff -u pecl/apc/apc_cache.c:3.49 pecl/apc/apc_cache.c:3.50
--- pecl/apc/apc_cache.c:3.49 Thu Jun 26 20:07:26 2003
+++ pecl/apc/apc_cache.c Fri Jun 27 12:19:18 2003
@@ -14,20 +14,20 @@
+----------------------------------------------------------------------+
*/
-/* $Id: apc_cache.c,v 3.49 2003/06/27 00:07:26 rasmus Exp $ */
+/* $Id: apc_cache.c,v 3.50 2003/06/27 16:19:18 gschlossnagle Exp $ */
#include "apc_cache.h"
-#include "apc_sem.h"
+#include "apc_lock.h"
#include "apc_sma.h"
#include "SAPI.h"
/* TODO: rehash when load factor exceeds threshold */
/* {{{ locking macros */
-#define CREATE_LOCK apc_sem_create(NULL, 0, 1)
-#define DESTROY_LOCK(c) apc_sem_destroy(c->lock)
-#define LOCK(c) apc_sem_lock(c->lock)
-#define UNLOCK(c) apc_sem_unlock(c->lock)
+#define CREATE_LOCK apc_lck_create(NULL, 0, 1)
+#define DESTROY_LOCK(c) apc_lck_destroy(c->lock)
+#define LOCK(c) apc_lck_lock(c->lock)
+#define UNLOCK(c) apc_lck_unlock(c->lock)
/* }}} */
/* {{{ struct definition: slot_t */
Index: pecl/apc/apc_fcntl.c
diff -u pecl/apc/apc_fcntl.c:3.13 pecl/apc/apc_fcntl.c:3.14
--- pecl/apc/apc_fcntl.c:3.13 Fri Jun 27 12:02:11 2003
+++ pecl/apc/apc_fcntl.c Fri Jun 27 12:19:18 2003
@@ -14,23 +14,27 @@
+----------------------------------------------------------------------+
*/
-/* $Id: apc_fcntl.c,v 3.13 2003/06/27 16:02:11 gschlossnagle Exp $ */
+/* $Id: apc_fcntl.c,v 3.14 2003/06/27 16:19:18 gschlossnagle Exp $ */
#include "apc_fcntl.h"
#include "apc.h"
#include <unistd.h>
#include <fcntl.h>
-
int apc_fcntl_create(const char* pathname)
{
int fd;
- fd = open(pathname, O_RDWR|O_CREAT, 0666);
+ char *lock_path = pathname;
+ if(pathname == NULL) {
+ lock_path = malloc(strlen("/tmp/.apc.") + 6);
+ snprintf(lock_path, strlen("/tmp/.apc.") + 6, "/tmp/.apc.%d",
getpid());
+ }
+ fd = open(lock_path, O_RDWR|O_CREAT, 0666);
if(fd > 0 ) {
- unlink(pathname);
+ unlink(lock_path);
return fd;
} else {
- apc_eprint("apc_fcntl_create: open(%s, O_RDWR|O_CREAT, 0666) failed:", pathname);
+ apc_eprint("apc_fcntl_create: open(%s, O_RDWR|O_CREAT, 0666) failed:",
lock_path);
}
return -1;
}
Index: pecl/apc/apc_sma.c
diff -u pecl/apc/apc_sma.c:1.10 pecl/apc/apc_sma.c:1.11
--- pecl/apc/apc_sma.c:1.10 Fri Jun 27 11:53:17 2003
+++ pecl/apc/apc_sma.c Fri Jun 27 12:19:19 2003
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: apc_sma.c,v 1.10 2003/06/27 15:53:17 gschlossnagle Exp $ */
+/* $Id: apc_sma.c,v 1.11 2003/06/27 16:19:19 gschlossnagle Exp $ */
#include "apc_sma.h"
#include "apc.h"
@@ -215,7 +215,6 @@
#endif
{
int i;
- char *lock_path = NULL;
if (sma_initialized) {
return;
@@ -242,10 +241,7 @@
sma_segments = (int*) apc_emalloc(sma_numseg*sizeof(int));
sma_shmaddrs = (void**) apc_emalloc(sma_numseg*sizeof(void*));
- lock_path = malloc(strlen("/tmp/.apc.") + 6);
- snprintf(lock_path, strlen("/tmp/.apc.") + 6, "/tmp/.apc.%d", getpid());
- sma_lock = apc_lck_create(lock_path, 0, 1);
- free(lock_path);
+ sma_lock = apc_lck_create(NULL, 0, 1);
for (i = 0; i < sma_numseg; i++) {
header_t* header;