This commit is contained in:
parent
499708bd34
commit
6f31d348ec
169
logrotate-3.7.7-hashes.patch
Normal file
169
logrotate-3.7.7-hashes.patch
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
--- logrotate.c (revision 259)
|
||||||
|
+++ logrotate.c (revision 260)
|
||||||
|
@@ -46,8 +46,11 @@
|
||||||
|
char *baseName;
|
||||||
|
};
|
||||||
|
|
||||||
|
-LIST_HEAD(stateSet, logState) states;
|
||||||
|
+struct logStates {
|
||||||
|
+ LIST_HEAD(stateSet, logState) head;
|
||||||
|
+} **states;
|
||||||
|
|
||||||
|
+unsigned int hashSize;
|
||||||
|
int numLogs = 0;
|
||||||
|
int debug = 0;
|
||||||
|
char *mailCommand = DEFAULT_MAIL_COMMAND;
|
||||||
|
@@ -64,6 +67,59 @@
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+#define HASH_SIZE_MIN 64
|
||||||
|
+static int allocateHash(void)
|
||||||
|
+{
|
||||||
|
+ struct logInfo *log;
|
||||||
|
+ unsigned int hs;
|
||||||
|
+ int i;
|
||||||
|
+
|
||||||
|
+ hs = 0;
|
||||||
|
+
|
||||||
|
+ for (log = logs.tqh_first; log != NULL; log = log->list.tqe_next)
|
||||||
|
+ hs += log->numFiles;
|
||||||
|
+
|
||||||
|
+ hs *= 2;
|
||||||
|
+
|
||||||
|
+ /* Enforce some reasonable minimum hash size */
|
||||||
|
+ if (hs < HASH_SIZE_MIN)
|
||||||
|
+ hs = HASH_SIZE_MIN;
|
||||||
|
+
|
||||||
|
+ states = calloc(hs, sizeof(struct logStates *));
|
||||||
|
+ if (states == NULL) {
|
||||||
|
+ message(MESS_ERROR, "could not allocate memory for "
|
||||||
|
+ "hash table\n");
|
||||||
|
+ return 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (i = 0; i < hs; i++) {
|
||||||
|
+ states[i] = malloc(sizeof(struct logState));
|
||||||
|
+ if (states[i] == NULL) {
|
||||||
|
+ message(MESS_ERROR, "could not allocate memory for "
|
||||||
|
+ "hash element\n");
|
||||||
|
+ return 1;
|
||||||
|
+ }
|
||||||
|
+ LIST_INIT(&(states[i]->head));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ hashSize = hs;
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#define HASH_CONST 13
|
||||||
|
+static unsigned hashIndex(const char *fn)
|
||||||
|
+{
|
||||||
|
+ unsigned hash = 0;
|
||||||
|
+
|
||||||
|
+ while (*fn) {
|
||||||
|
+ hash *= HASH_CONST;
|
||||||
|
+ hash += *fn++;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return hash % hashSize;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static struct logState *newState(const char *fn)
|
||||||
|
{
|
||||||
|
struct tm now = *localtime(&nowSecs);
|
||||||
|
@@ -92,9 +148,10 @@
|
||||||
|
|
||||||
|
static struct logState *findState(const char *fn)
|
||||||
|
{
|
||||||
|
+ unsigned int i = hashIndex(fn);
|
||||||
|
struct logState *p;
|
||||||
|
|
||||||
|
- for (p = states.lh_first; p != NULL; p = p->list.le_next)
|
||||||
|
+ for (p = states[i]->head.lh_first; p != NULL; p = p->list.le_next)
|
||||||
|
if (!strcmp(fn, p->fn))
|
||||||
|
break;
|
||||||
|
|
||||||
|
@@ -103,7 +160,7 @@
|
||||||
|
if ((p = newState(fn)) == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
- LIST_INSERT_HEAD(&states, p, list);
|
||||||
|
+ LIST_INSERT_HEAD(&(states[i]->head), p, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
@@ -1313,6 +1370,7 @@
|
||||||
|
struct logState *p;
|
||||||
|
FILE *f;
|
||||||
|
char *chptr;
|
||||||
|
+ int i;
|
||||||
|
|
||||||
|
f = fopen(stateFilename, "w");
|
||||||
|
if (!f) {
|
||||||
|
@@ -1323,27 +1381,29 @@
|
||||||
|
|
||||||
|
fprintf(f, "logrotate state -- version 2\n");
|
||||||
|
|
||||||
|
- for (p = states.lh_first; p != NULL; p = p->list.le_next) {
|
||||||
|
- fputc('"', f);
|
||||||
|
- for (chptr = p->fn; *chptr; chptr++) {
|
||||||
|
- switch (*chptr) {
|
||||||
|
- case '"':
|
||||||
|
- fputc('\\', f);
|
||||||
|
- }
|
||||||
|
+ for (i = 0; i < hashSize; i++) {
|
||||||
|
+ for (p = states[i]->head.lh_first; p != NULL;
|
||||||
|
+ p = p->list.le_next) {
|
||||||
|
+ fputc('"', f);
|
||||||
|
+ for (chptr = p->fn; *chptr; chptr++) {
|
||||||
|
+ switch (*chptr) {
|
||||||
|
+ case '"':
|
||||||
|
+ fputc('\\', f);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- fputc(*chptr, f);
|
||||||
|
+ fputc(*chptr, f);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ fputc('"', f);
|
||||||
|
+ fprintf(f, " %d-%d-%d\n",
|
||||||
|
+ p->lastRotated.tm_year + 1900,
|
||||||
|
+ p->lastRotated.tm_mon + 1,
|
||||||
|
+ p->lastRotated.tm_mday);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
- fputc('"', f);
|
||||||
|
- fprintf(f, " %d-%d-%d\n",
|
||||||
|
- p->lastRotated.tm_year + 1900,
|
||||||
|
- p->lastRotated.tm_mon + 1,
|
||||||
|
- p->lastRotated.tm_mday);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- fclose(f);
|
||||||
|
-
|
||||||
|
- return 0;
|
||||||
|
+ fclose(f);
|
||||||
|
+ return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int readState(char *stateFilename)
|
||||||
|
@@ -1555,7 +1615,8 @@
|
||||||
|
poptFreeContext(optCon);
|
||||||
|
nowSecs = time(NULL);
|
||||||
|
|
||||||
|
- LIST_INIT(&states);
|
||||||
|
+ if (allocateHash() != 0)
|
||||||
|
+ return 1;
|
||||||
|
|
||||||
|
if (readState(stateFile))
|
||||||
|
{
|
||||||
|
@@ -1577,5 +1639,5 @@
|
||||||
|
rc = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
- return (rc != 0);
|
||||||
|
+ return (rc != 0);
|
||||||
|
}
|
@ -1,3 +1,8 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Oct 21 15:16:03 CEST 2008 - puzel@suse.cz
|
||||||
|
|
||||||
|
- logrotate-3.7.7-hashes.patch (bnc#415072)
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Sep 30 13:17:04 CEST 2008 - puzel@suse.cz
|
Tue Sep 30 13:17:04 CEST 2008 - puzel@suse.cz
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ BuildRequires: popt-devel
|
|||||||
BuildRequires: libselinux-devel
|
BuildRequires: libselinux-devel
|
||||||
Summary: Rotate, Compress, Remove, and Mail System Log Files
|
Summary: Rotate, Compress, Remove, and Mail System Log Files
|
||||||
Version: 3.7.7
|
Version: 3.7.7
|
||||||
Release: 8
|
Release: 9
|
||||||
License: GPL v2 or later
|
License: GPL v2 or later
|
||||||
Group: System/Base
|
Group: System/Base
|
||||||
Source: %{name}-%{version}.tar.bz2
|
Source: %{name}-%{version}.tar.bz2
|
||||||
@ -34,6 +34,7 @@ Patch2: %{name}-%{version}-autoext.patch
|
|||||||
Patch3: %{name}-%{version}-addextension.patch
|
Patch3: %{name}-%{version}-addextension.patch
|
||||||
Patch4: %{name}-%{version}-mess_err.patch
|
Patch4: %{name}-%{version}-mess_err.patch
|
||||||
Patch5: %{name}-%{version}-cron-check-for-another-instance.patch
|
Patch5: %{name}-%{version}-cron-check-for-another-instance.patch
|
||||||
|
Patch6: %{name}-%{version}-hashes.patch
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
PreReq: %fillup_prereq /bin/rm /bin/mv
|
PreReq: %fillup_prereq /bin/rm /bin/mv
|
||||||
Requires: bzip2 cron
|
Requires: bzip2 cron
|
||||||
@ -62,6 +63,7 @@ Authors:
|
|||||||
%patch3
|
%patch3
|
||||||
%patch4
|
%patch4
|
||||||
%patch5
|
%patch5
|
||||||
|
%patch6
|
||||||
|
|
||||||
%build
|
%build
|
||||||
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes
|
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes
|
||||||
@ -97,6 +99,8 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
%config(noreplace)/etc/logrotate.d/wtmp
|
%config(noreplace)/etc/logrotate.d/wtmp
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Oct 21 2008 puzel@suse.cz
|
||||||
|
- logrotate-3.7.7-hashes.patch (bnc#415072)
|
||||||
* Tue Sep 30 2008 puzel@suse.cz
|
* Tue Sep 30 2008 puzel@suse.cz
|
||||||
- use chekcproc in logrotate.cron script instead of pgrep (bnc#426162)
|
- use chekcproc in logrotate.cron script instead of pgrep (bnc#426162)
|
||||||
* Wed Sep 03 2008 puzel@suse.cz
|
* Wed Sep 03 2008 puzel@suse.cz
|
||||||
|
Loading…
Reference in New Issue
Block a user