diff options
Diffstat (limited to 'net/spreadlogd/patches/patch-aa')
-rw-r--r-- | net/spreadlogd/patches/patch-aa | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/net/spreadlogd/patches/patch-aa b/net/spreadlogd/patches/patch-aa new file mode 100644 index 00000000000..36f2afba6b6 --- /dev/null +++ b/net/spreadlogd/patches/patch-aa @@ -0,0 +1,104 @@ +$NetBSD: patch-aa,v 1.1.1.1 2007/07/29 06:58:59 obache Exp $ + +--- config.c.orig 2006-05-05 20:25:41.000000000 +0100 ++++ config.c +@@ -301,6 +301,15 @@ int config_close(void) { + SpreadConfiguration *sc; + LogFacility *lf; + int i; ++#ifdef HAVE_FCNTL_H ++ struct flock fl; ++ ++ fl.l_type = F_UNLCK; /* tell it to unlock the region */ ++ fl.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */ ++ fl.l_start = 0; /* Offset from l_whence */ ++ fl.l_len = 0; /* length, 0 = to EOF */ ++ fl.l_pid = getpid(); /* our PID */ ++#endif + sciter = sl_getlist(&spreaddaemons); + if(!sciter) return 0; + sc = (SpreadConfiguration *)sciter->data; +@@ -314,13 +323,23 @@ int config_close(void) { + if(lf->vhostdir) { + for (i=0;i< FHASH_SIZE;i++) { + if(lf->hash[i].fd>0) { +- if(!skiplocking) flock(lf->hash[i].fd, LOCK_UN); ++ if(!skiplocking) ++#ifdef HAVE_FCNTL_H ++ fcntl(lf->hash[i].fd, F_SETLK, &fl); ++#else ++ flock(lf->hash[i].fd, LOCK_UN); ++#endif + close(lf->hash[i].fd); + lf->hash[i].fd = -1; + } + } + } else if(lf->logfile && lf->logfile->fd>0) { +- if(!skiplocking) flock(lf->logfile->fd, LOCK_UN); ++ if(!skiplocking) ++#ifdef HAVE_FCNTL_H ++ fcntl(lf->logfile->fd, F_SETLK, &fl); ++#else ++ flock(lf->logfile->fd, LOCK_UN); ++#endif + close(lf->logfile->fd); + lf->logfile->fd = -1; + } +@@ -356,6 +375,15 @@ int config_start(void) { + struct skiplistnode *sciter, *lfiter; + SpreadConfiguration *sc; + LogFacility *lf; ++#ifdef HAVE_FCNTL_H ++ struct flock fl; ++ ++ fl.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ ++ fl.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */ ++ fl.l_start = 0; /* Offset from l_whence */ ++ fl.l_len = 0; /* length, 0 = to EOF */ ++ fl.l_pid = getpid(); /* our PID */ ++#endif + sciter = sl_getlist(&spreaddaemons); + if(!sciter) return 0; + sc = (SpreadConfiguration *)sciter->data; +@@ -381,7 +409,11 @@ int config_start(void) { + } + } + if(!skiplocking) { +- if(flock(lf->logfile->fd, LOCK_NB|LOCK_EX)==-1) { ++#ifdef HAVE_FCNTL_H ++ if(fcntl(lf->logfile->fd, F_SETLK, &fl)==-1) { ++#else ++ if(flock(lf->logfile->fd, LOCK_NB|LOCK_EX)==-1) { ++#endif + fprintf(stderr, "Cannot lock %s, is another spreadlogd running?\n", + lf->logfile->filename); + exit(1); +@@ -441,6 +473,15 @@ int config_get_fd(SpreadConfiguration *s + hash_element temp; + char *cp; + char fullpath[MAXPATHLEN]; ++#ifdef HAVE_FCNTL_H ++ struct flock fl; ++ ++ fl.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ ++ fl.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */ ++ fl.l_start = 0; /* Offset from l_whence */ ++ fl.l_len = 0; /* length, 0 = to EOF */ ++ fl.l_pid = getpid(); /* our PID */ ++#endif + lf = sl_find(sc->logfacilities, group, NULL); + if(!lf || !lf->logfile || !lf->logfile->filename) return -1; + if(lf->vhostdir) { +@@ -457,7 +498,11 @@ int config_get_fd(SpreadConfiguration *s + O_CREAT|O_APPEND|O_WRONLY, + 00644); + if(!skiplocking) { +- if(flock(temp.fd, LOCK_NB|LOCK_EX)==-1) { ++#ifdef HAVE_FCNTL_H ++ if(fcntl(temp.fd, F_SETLK, &fl)==-1) { ++#else ++ if(flock(temp.fd, LOCK_NB|LOCK_EX)==-1) { ++#endif + fprintf(stderr, "Cannot lock %s, is another spreadlogd running?\n", + fullpath); + exit(1); |