[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] cfexecd enhancement to distinguish scheduled runs
From: |
Joe Buehler |
Subject: |
[PATCH] cfexecd enhancement to distinguish scheduled runs |
Date: |
Mon, 16 Jan 2006 12:23:09 -0500 |
User-agent: |
Mozilla Thunderbird 1.0.6 (Windows/20050716) |
I have the inittab on various machines set up to run cfexecd
once as a one-time boot job and once as a long-term daemon.
Periodic cfengine cron-type jobs need to be run only from the
daemon and not at boot time.
Attached is a patch that defines "scheduled_run" if and
only if cfexecd runs cfagent because it is scheduled to do so.
One caveat: I couldn't find the documentation that says how to
define multiple classes with the -D option to cfagent so took
a guess at using colon as a separator, based on the source code.
--
Joe Buehler
--- src/cfexecd.c.~1~ 2005-10-10 17:06:17.000000000 -0400
+++ src/cfexecd.c 2006-01-16 11:28:18.000000000 -0500
@@ -94,7 +94,7 @@
void StartServer ARGLIST((int argc, char **argv));
void Syntax ARGLIST((void));
void *ExitCleanly ARGLIST((void));
-void *LocalExec ARGLIST((void *dummy));
+void *LocalExec ARGLIST((void *scheduled_run));
void MailResult ARGLIST((char *filename, char *to));
int ScheduleRun ARGLIST((void));
void AddClassToHeap ARGLIST((char *class));
@@ -298,7 +298,7 @@
if (ONCE)
{
GetCfStuff();
- LocalExec(NULL);
+ LocalExec((void *)0);
}
else
{ char **nargv;
@@ -360,15 +360,15 @@
pthread_attr_setstacksize(&PTHREADDEFAULTS,(size_t)2048*1024);
#endif
- if (pthread_create(&tid,&PTHREADDEFAULTS,LocalExec,NULL) != 0)
+ if (pthread_create(&tid,&PTHREADDEFAULTS,LocalExec,(void *)1) != 0)
{
CfLog(cfinform,"Can't create thread!","pthread_create");
- LocalExec(NULL);
+ LocalExec((void *)1);
}
pthread_attr_destroy(&PTHREADDEFAULTS);
#else
- LocalExec(NULL);
+ LocalExec((void *)1);
#endif
#endif
@@ -617,7 +617,7 @@
/**************************************************************/
-void *LocalExec(void *dummy)
+void *LocalExec(void *scheduled_run)
{ FILE *pp;
char line[CF_BUFSIZE],filename[CF_BUFSIZE],*sp;
@@ -634,19 +634,15 @@
Verbose("------------------------------------------------------------------\n\n");
-Verbose(" LocalExec at %s\n",ctime(&starttime));
+Verbose(" LocalExec(%sscheduled) at %s\n", scheduled_run ? "" : "not ",
ctime(&starttime));
Verbose("------------------------------------------------------------------\n");
/* Need to make sure we have LD_LIBRARY_PATH here or children will die */
-if (NOSPLAY)
- {
- snprintf(cmd,CF_BUFSIZE-1,"%s/bin/cfagent -q -Dfrom_cfexecd",CFWORKDIR);
- }
-else
- {
- snprintf(cmd,CF_BUFSIZE-1,"%s/bin/cfagent -Dfrom_cfexecd",CFWORKDIR);
- }
+snprintf(cmd,CF_BUFSIZE-1,"%s/bin/cfagent%s -Dfrom_cfexecd%s",
+ CFWORKDIR,
+ NOSPLAY ? " -q" : "",
+ scheduled_run ? ":scheduled_run" : "");
timestamp(starttime, line, CF_BUFSIZE);
- [PATCH] cfexecd enhancement to distinguish scheduled runs,
Joe Buehler <=