You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Victor J. Orlikowski" <v....@gte.net> on 2000/11/17 01:38:03 UTC
[PATCH] rotatelogs fix .. update
There were some indention problems in the rotatelogs patch I posted
earlier. Ben Laurie likes tabs, not spaces. Here's the patch that
takes that into account.
Index: src/main/http_log.c
===================================================================
RCS file: /cvs/apache/apache-1.3/src/main/http_log.c,v
retrieving revision 1.87
diff -u -d -r1.87 http_log.c
--- http_log.c 2000/11/14 09:57:08 1.87
+++ http_log.c 2000/11/17 00:35:38
@@ -664,9 +664,8 @@
break;
case OC_REASON_UNWRITABLE:
- if (pl->pid != -1) {
- kill(pl->pid, SIGTERM);
- }
+ /* We should not kill off the pipe here, since it may only be full.
+ * If it really is locked, we should kill it off manually. */
break;
case OC_REASON_RESTART:
Index: src/support/rotatelogs.c
===================================================================
RCS file: /cvs/apache/apache-1.3/src/support/rotatelogs.c,v
retrieving revision 1.12
diff -u -d -r1.12 rotatelogs.c
--- rotatelogs.c 2000/06/21 22:54:45 1.12
+++ rotatelogs.c 2000/11/17 00:35:39
@@ -13,17 +13,16 @@
#include <fcntl.h>
#define BUFSIZE 65536
+#define ERRMSGSZ 82
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
int main (int argc, char **argv)
{
- char buf[BUFSIZE], buf2[MAX_PATH];
- time_t tLogEnd = 0;
- time_t tRotation;
- int nLogFD = -1;
- int nRead;
+ char buf[BUFSIZE], buf2[MAX_PATH], errbuf[ERRMSGSZ];
+ time_t tLogEnd = 0, tRotation;
+ int nLogFD = -1, nLogFDprev = -1, nMessCount = 0, nRead, nWrite;
char *szLogRoot;
if (argc != 3) {
@@ -63,7 +62,7 @@
if (errno != EINTR)
exit(4);
if (nLogFD >= 0 && (time(NULL) >= tLogEnd || nRead < 0)) {
- close(nLogFD);
+ nLogFDprev = nLogFD;
nLogFD = -1;
}
if (nLogFD < 0) {
@@ -72,15 +71,46 @@
tLogEnd = tLogStart + tRotation;
nLogFD = open(buf2, O_WRONLY | O_CREAT | O_APPEND, 0666);
if (nLogFD < 0) {
- perror(buf2);
- exit(2);
+ /* Uh-oh. Failed to open the new log file. Try to clear
+ * the previous log file, note the lost log entries,
+ * and keep on truckin'. */
+ if (nLogFDprev == -1) {
+ perror(buf2);
+ exit(2);
+ }
+ else {
+ nLogFD = nLogFDprev;
+ sprintf(errbuf,
+ "Resetting log file due to error opening "
+ "new log file. %10d messages lost.\n",
+ nMessCount);
+ nWrite = strlen(errbuf);
+ ftruncate(nLogFD, 0);
+ write(nLogFD, errbuf, nWrite);
+ }
}
- }
- if (write(nLogFD, buf, nRead) != nRead) {
- perror(buf2);
- exit(5);
+ else {
+ close(nLogFDprev);
+ }
+ nMessCount = 0;
+ }
+ do {
+ nWrite = write(nLogFD, buf, nRead);
+ } while (nWrite < 0 && errno == EINTR);
+ if (nWrite != nRead) {
+ nMessCount++;
+ sprintf(errbuf,
+ "Error writing to log file. "
+ "%10d messages lost.\n",
+ nMessCount);
+ nWrite = strlen(errbuf);
+ ftruncate(nLogFD, 0);
+ write (nLogFD, errbuf, nWrite);
+ }
+ else {
+ nMessCount++;
}
}
- /* We never get here, but surpress the compile warning */
+ /* We never get here, but suppress the compile warning */
return (0);
}
Victor
--
Victor J. Orlikowski
======================
v.j.orlikowski@gte.net
vjo@raleigh.ibm.com
vjo@us.ibm.com
Re: style giude, was Re: [PATCH] rotatelogs fix .. update
Posted by Ben Laurie <be...@algroup.co.uk>.
Brian Havard wrote:
>
> On Thu, 16 Nov 2000 22:32:04 -0600, William A. Rowe, Jr. wrote:
>
> >> From: Tony Finch [mailto:dot@dotat.at]
> >> Sent: Thursday, November 16, 2000 9:53 PM
> >>
> >> I intend to commit this.
> >
> >Undoubtedly - but not without a vote here - this has been argued
> >to death in the past and for mostly good reasons. I'm -.5 for this
> >change, tabified code tends to get brutalized - especially when
> >we need mass edits. Further, your definition is wrong, tab advances
> >the column to 8 + (cur column mod 8), not 8 spaces, as you worded it.
>
> Agreed, the style guide shouldn't be changed without a vote and I'm -1
> (vote not veto) on this change.
To drag up an old issue ... I'm +1 on this: it documents a fact of life.
Cheers,
Ben.
>
> >> Index: styleguide.html
> >> ===================================================================
> >> RCS file: /home/cvs/apache-devsite/styleguide.html,v
> >> retrieving revision 1.7
> >> diff -u -r1.7 styleguide.html
> >> --- styleguide.html 1998/04/20 05:32:47 1.7
> >> +++ styleguide.html 2000/11/17 03:48:04
> >> @@ -31,8 +31,8 @@
> >> following line at the start of a function definition.
> >> </LI>
> >> <LI>Code inside a block (whether surrounded by braces or not) is
> >> - indented by four space characters. Tab characters are not
> >> - used. Comments are indented to the same level as the surrounding
> >> + indented by four space characters. Tab characters are
> >> equivalent to
> >> + eight spaces. Comments are indented to the same level as
> >> the surrounding
> >> code.
> >> </LI>
> >> <LI>Closing braces are always on a separate line from surrounding
>
> --
> ______________________________________________________________________________
> | Brian Havard | "He is not the messiah! |
> | brianh@kheldar.apana.org.au | He's a very naughty boy!" - Life of Brian |
> ------------------------------------------------------------------------------
--
http://www.apache-ssl.org/ben.html
"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff
RE: style giude, was Re: [PATCH] rotatelogs fix .. update
Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Thu, 16 Nov 2000 22:32:04 -0600, William A. Rowe, Jr. wrote:
>> From: Tony Finch [mailto:dot@dotat.at]
>> Sent: Thursday, November 16, 2000 9:53 PM
>>
>> I intend to commit this.
>
>Undoubtedly - but not without a vote here - this has been argued
>to death in the past and for mostly good reasons. I'm -.5 for this
>change, tabified code tends to get brutalized - especially when
>we need mass edits. Further, your definition is wrong, tab advances
>the column to 8 + (cur column mod 8), not 8 spaces, as you worded it.
Agreed, the style guide shouldn't be changed without a vote and I'm -1
(vote not veto) on this change.
>> Index: styleguide.html
>> ===================================================================
>> RCS file: /home/cvs/apache-devsite/styleguide.html,v
>> retrieving revision 1.7
>> diff -u -r1.7 styleguide.html
>> --- styleguide.html 1998/04/20 05:32:47 1.7
>> +++ styleguide.html 2000/11/17 03:48:04
>> @@ -31,8 +31,8 @@
>> following line at the start of a function definition.
>> </LI>
>> <LI>Code inside a block (whether surrounded by braces or not) is
>> - indented by four space characters. Tab characters are not
>> - used. Comments are indented to the same level as the surrounding
>> + indented by four space characters. Tab characters are
>> equivalent to
>> + eight spaces. Comments are indented to the same level as
>> the surrounding
>> code.
>> </LI>
>> <LI>Closing braces are always on a separate line from surrounding
--
______________________________________________________________________________
| Brian Havard | "He is not the messiah! |
| brianh@kheldar.apana.org.au | He's a very naughty boy!" - Life of Brian |
------------------------------------------------------------------------------
RE: style giude, was Re: [PATCH] rotatelogs fix .. update
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
> From: Tony Finch [mailto:dot@dotat.at]
> Sent: Thursday, November 16, 2000 9:53 PM
>
> I intend to commit this.
Undoubtedly - but not without a vote here - this has been argued
to death in the past and for mostly good reasons. I'm -.5 for this
change, tabified code tends to get brutalized - especially when
we need mass edits. Further, your definition is wrong, tab advances
the column to 8 + (cur column mod 8), not 8 spaces, as you worded it.
> Index: styleguide.html
> ===================================================================
> RCS file: /home/cvs/apache-devsite/styleguide.html,v
> retrieving revision 1.7
> diff -u -r1.7 styleguide.html
> --- styleguide.html 1998/04/20 05:32:47 1.7
> +++ styleguide.html 2000/11/17 03:48:04
> @@ -31,8 +31,8 @@
> following line at the start of a function definition.
> </LI>
> <LI>Code inside a block (whether surrounded by braces or not) is
> - indented by four space characters. Tab characters are not
> - used. Comments are indented to the same level as the surrounding
> + indented by four space characters. Tab characters are
> equivalent to
> + eight spaces. Comments are indented to the same level as
> the surrounding
> code.
> </LI>
> <LI>Closing braces are always on a separate line from surrounding
>
>
> Tony.
> --
> en oeccget g mtcaa f.a.n.finch
> v spdlkishrhtewe y dot@dotat.at
> eatp o v eiti i d. fanf@covalent.net
>
Re: style giude, was Re: [PATCH] rotatelogs fix .. update
Posted by Tony Finch <do...@dotat.at>.
I intend to commit this.
Index: styleguide.html
===================================================================
RCS file: /home/cvs/apache-devsite/styleguide.html,v
retrieving revision 1.7
diff -u -r1.7 styleguide.html
--- styleguide.html 1998/04/20 05:32:47 1.7
+++ styleguide.html 2000/11/17 03:48:04
@@ -31,8 +31,8 @@
following line at the start of a function definition.
</LI>
<LI>Code inside a block (whether surrounded by braces or not) is
- indented by four space characters. Tab characters are not
- used. Comments are indented to the same level as the surrounding
+ indented by four space characters. Tab characters are equivalent to
+ eight spaces. Comments are indented to the same level as the surrounding
code.
</LI>
<LI>Closing braces are always on a separate line from surrounding
Tony.
--
en oeccget g mtcaa f.a.n.finch
v spdlkishrhtewe y dot@dotat.at
eatp o v eiti i d. fanf@covalent.net
RE: [PATCH] rotatelogs fix .. update
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
> From: Victor J. Orlikowski [mailto:v.j.orlikowski@gte.net]
> Sent: Thursday, November 16, 2000 8:56 PM
>
> O.k., then shall I re-work rotatelogs in both 1.3 and 2.0 so that the
> indention uses spaces only?
I've made this mistake before, hang on...
Every once in a while we touch code that has tabs. Lots of tabs.
mod_isapi.c was a really good example/bad style.
And every line I touched, even when I -thought- I did it right, was
changed in CVS.
The problem comes down to this - if you are making code changes, change
as few lines as possible (my latest 1.3.15 commits violated this principal,
before anyone jumps on me for being hypocritical. I try.)
When the tabs get in the way... untabify the original, untabify your new
code. Pass on the untabbed version as a style patch only. Then update
and rediff the untabbified good code.
That way, real changes are easy to differentiate between style cleanup.
Bill
Re: [PATCH] rotatelogs fix .. update
Posted by "Victor J. Orlikowski" <v....@gte.net>.
O.k., then shall I re-work rotatelogs in both 1.3 and 2.0 so that the
indention uses spaces only?
Victor
--
Victor J. Orlikowski
======================
v.j.orlikowski@gte.net
vjo@raleigh.ibm.com
vjo@us.ibm.com
Re: [PATCH] rotatelogs fix .. update
Posted by Tony Finch <do...@dotat.at>.
Brian Havard <br...@kheldar.apana.org.au> wrote:
>
>Regardless of what Ben likes, the style guide says no tabs. See
>http://dev.apache.org/styleguide.html
The style guide is wrong in this respect. There have been tabs in the
code since before it was imported into CVS. They are *not* an issue.
Tony.
--
en oeccget g mtcaa f.a.n.finch
v spdlkishrhtewe y dot@dotat.at
eatp o v eiti i d. fanf@covalent.net
Re: [PATCH] rotatelogs fix .. update
Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Thu, 16 Nov 2000 19:38:03 -0500, Victor J. Orlikowski wrote:
>There were some indention problems in the rotatelogs patch I posted
>earlier. Ben Laurie likes tabs, not spaces. Here's the patch that
>takes that into account.
Regardless of what Ben likes, the style guide says no tabs. See
http://dev.apache.org/styleguide.html
--
______________________________________________________________________________
| Brian Havard | "He is not the messiah! |
| brianh@kheldar.apana.org.au | He's a very naughty boy!" - Life of Brian |
------------------------------------------------------------------------------