sysvinit/startpar-preload.diff

78 lines
1.9 KiB
Diff

--- startpar.c 2009-03-25 16:16:59.308479056 +0100
+++ startpar.c 2009-03-25 16:52:25.357391610 +0100
@@ -85,6 +85,19 @@
static int pidpipe[2];
static double iorate = 800.0;
+void sighandler_nopreload(int x)
+{
+ (void)x;
+ ispreload = NoPreload;
+}
+
+
+void sighandler_preload(int x)
+{
+ (void)x;
+ ispreload = Preload;
+}
+
void *xcalloc(size_t nmemb, size_t size)
{
void *r;
@@ -253,14 +266,14 @@
return par;
/* if we have preload running, we expect I/O not to be a problem */
- if (ispreload == Preload)
+ if (ispreload != NoPreload)
prcs_blked = 0;
newpar = (par*numcpu) - prcs_run + 1; /* +1 for startpar its self */
newpar -= (int)(((double)prcs_blked)*iorate); /* I/O load reduction */
#if DEBUG
- fprintf(stderr, "checksystem par=%d newpar=%d (prcs_run=%u) %ld\n", par, newpar, prcs_run, time(0));
+ fprintf(stderr, "checksystem par=%d newpar=%d (prcs_run=%lu) %ld\n", par, newpar, prcs_run, time(0));
dump_status();
#endif
if (newpar <= 0)
@@ -284,6 +297,7 @@
void run(struct prg *p)
{
char *m = 0;
+ pid_t parent = getpid();
p->len = 0;
p->pid = (pid_t)0;
@@ -368,7 +382,8 @@
t = connect(s, (struct sockaddr *)&remote, len);
if (t != -1)
{
- ispreload = Preload;
+ if (ispreload != Preload)
+ kill(parent, SIGUSR1);
send(s, p->name, strlen(p->name), 0);
recv(s, str, 100, 0);
}
@@ -379,7 +394,7 @@
* In case we can't connect to it later, it means it did
* its job and we can guess I/O is no longer a problem.
*/
- ispreload = NoPreload;
+ kill(parent, SIGUSR2);
}
close(s);
}
@@ -601,6 +616,9 @@
char *run_level = getenv("RUNLEVEL");
char *splashopt = 0;
+ (void)signal(SIGUSR1, sighandler_preload);
+ (void)signal(SIGUSR2, sighandler_nopreload);
+
(void)signal(SIGCHLD, SIG_DFL);
numcpu = sysconf(_SC_NPROCESSORS_ONLN);
myname = argv[0];