--- fsl.c 2002/07/19 13:26:51 1.16
+++ fsl.c 2002/07/23 12:21:57 1.17
@@ -295,24 +295,13 @@
cpIdent = NULL;
cpISF = NULL;
+ /* properly handle repeated execution */
+ closelog();
+
/*FIXME this should be available to the user to help him finding out what the application passes along
* fprintf(stderr, "DEBUG: BEGIN ident=\"%s\", logopt=0x%.8lx, facility=0x%.8lx\n", ident, (unsigned long)logopt, (unsigned long)facility);
*/
- /* check for repeated execution */
- if (ctx.l2_nch != NULL) {
- l2_channel_destroy(ctx.l2_nch);
- ctx.l2_nch = NULL;
- }
- if (ctx.l2_env != NULL) {
- l2_env_destroy(ctx.l2_env);
- ctx.l2_env = NULL;
- }
- if (ctx.levelmap != NULL) {
- free(ctx.levelmap);
- ctx.levelmap = NULL;
- }
-
/*FIXME this should be available to the user to help him finding out what the application passes along
* currently we completely ignore logopt LOG_CONS, LOG_NDELAY, LOG_PERROR, LOG_PID
*/
@@ -539,7 +528,7 @@
if (buf.base != NULL)
free(buf.base);
if (rc != 0)
- exit(rc);
+ closelog();
/*fprintf(stderr, "DEBUG: ------------------------------------------------------------\n");*/
return;
}
@@ -554,15 +543,16 @@
l2_env_destroy(ctx.l2_env);
ctx.l2_env = NULL;
}
- return;
+ if (ctx.levelmap != NULL) {
+ free(ctx.levelmap);
+ ctx.levelmap = NULL;
+ }
}
int setlogmask(int maskpri)
{
int oldmask;
- /*FIXME this is currently a no-op. Should we care about maskpri, set l2 global mask or continue to ignore?*/
- /* remember the logging mask */
oldmask = ctx.maskpri;
if (maskpri != 0)
ctx.maskpri = maskpri;
@@ -589,11 +579,19 @@
unsigned int levelmask;
int i;
+ /* check for previous proper initialization */
if (ctx.l2_nch == NULL)
return;
- priority &= LOG_PRIMASK; /* strip off facility */
- /*fprintf(stderr, "DEBUG: prioriy =0x%.8lx ", (unsigned long)priority);*/
+ /* strip off facility */
+ priority &= LOG_PRIMASK;
+ /*fprintf(stderr, "DEBUG: prioriy =0x%.8lx, ctx.maskpri=0x%.8lx ", (unsigned long)priority, (unsigned long)ctx.maskpri);*/
+
+ /* check against maskpri */
+ if ((LOG_MASK(priority) & ctx.maskpri) == 0) {
+ /*fprintf(stderr, "DEBUG: short circuit maskpri\n");*/
+ return;
+ }
levelmask = 0;
for (i = 0; sysloglevel2string[i].string != NULL; i++) {
|