OBS User unknown 2007-05-11 13:39:40 +00:00 committed by Git OBS Bridge
parent 3eb02fdc81
commit 302c09c160
3 changed files with 116 additions and 7 deletions

View File

@ -1,6 +1,6 @@
--- Makefile
+++ Makefile 2006-05-16 17:16:01.000000000 +0200
@@ -21,7 +21,7 @@
@@ -21,7 +21,7 @@ startpar: $(OBJS)
install: startpar
$(INSTALL) -d $(DESTDIR)$(sbindir) $(DESTDIR)$(man8dir)
@ -11,7 +11,7 @@
clean:
--- proc.c
+++ proc.c 2006-05-16 18:10:47.000000000 +0200
@@ -45,30 +45,29 @@
@@ -45,30 +45,29 @@ static unsigned long int scan_one(const
int read_proc(unsigned long int * const prcs_run, unsigned long int * const prcs_blked)
{
@ -56,8 +56,8 @@
running = scan_one(StatBuf, "procs_running");
blocked = scan_one(StatBuf, "procs_blocked");
--- startpar.c
+++ startpar.c 2006-05-16 17:16:01.000000000 +0200
@@ -127,6 +127,19 @@
+++ startpar.c 2007-05-11 12:07:21.215446308 +0200
@@ -127,6 +127,19 @@ void waitsplash()
splashpid = 0;
}
@ -77,7 +77,7 @@
void callsplash(int n, char *path, char *action)
{
char *p;
@@ -169,24 +182,11 @@
@@ -169,24 +182,11 @@ void callsplash(int n, char *path, char
}
close(1);
dup(2);
@ -103,7 +103,7 @@
void writebuf(struct prg *p)
{
char *b = p->buf;
@@ -360,6 +360,7 @@
@@ -360,6 +360,7 @@ int run_single(char *prg, int spl)
close(1);
dup(2);
@ -111,3 +111,103 @@
if (run_mode)
{
char path[128];
@@ -510,6 +511,7 @@ void usage(int status)
int main(int argc, char **argv)
{
+ volatile int broken;
int timo = -1;
int gtimo = -1;
int r, c, i, s, last, num;
@@ -706,6 +708,7 @@ int main(int argc, char **argv)
exit(1);
}
+ broken = 0; /* Detect broken hardware */
gettimeofday(&glastio, 0);
limit = checklimit(inpar, (run_mode) ? run_mode : "stop");
lastlim.tv_sec = glastio.tv_sec;
@@ -721,6 +724,7 @@ int main(int argc, char **argv)
last = -1;
maxfd = -1;
active = 0;
+ pid = 0;
diff = ((now.tv_sec - lastlim.tv_sec) * 1000) +
((now.tv_usec - lastlim.tv_usec)/ 1000);
@@ -795,8 +799,7 @@ int main(int argc, char **argv)
} /* for (s = 0; s < par; s++) */
- if (s < limit && num < argc)
- continue; /* start new processes */
+ broken++; /* no endless loops due broken systems */
if (interactive_task)
{
@@ -809,9 +812,14 @@ int main(int argc, char **argv)
p->pid = 0;
p->fd = 0;
interactive_task = NULL;
+ broken = 0; /* run_single() uses waitpid() */
continue;
}
}
+
+ if ((active < limit) && (num < argc) && (broken < argc))
+ continue; /* try to start new processes */
+
if (active == 0)
{
if (num < argc)
@@ -828,16 +836,25 @@ int main(int argc, char **argv)
if (active == 1 && last >= 0)
{
p = prgs + last;
- writebuf(p);
- continue;
+ if ((pid = waitpid(p->pid, &r, maxfd < 0 ? 0 : WNOHANG)) == 0)
+ {
+ writebuf(p);
+ continue;
+ }
+ broken = 0;
}
FD_SET(pidpipe[0], &rset);
/* drain the pidpipe */
- while ((r = read(pidpipe[0], pipebuf, sizeof pipebuf)) > 0)
+ while ((c = read(pidpipe[0], pipebuf, sizeof pipebuf)) > 0)
;
- pid = waitpid(-1, &r, maxfd < 0 ? 0 : WNOHANG);
+ if (pid == 0)
+ {
+ pid = waitpid(-1, &r, maxfd < 0 ? 0 : WNOHANG);
+ broken = 0;
+ }
+
if (pid > 0)
{
if (pid == splashpid)
@@ -874,7 +891,7 @@ int main(int argc, char **argv)
}
break;
}
- }
+ } /* for (s = 0; s < par; s++) */
continue;
}
@@ -993,9 +1010,9 @@ int main(int argc, char **argv)
}
p->lastio.tv_sec = now.tv_sec;
p->lastio.tv_usec = now.tv_usec;
- }
+ } /* for (s = 0; s < par; s++) */
}
- }
+ } /* for (;;) */
finished:
waitsplash();

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri May 11 12:10:18 CEST 2007 - werner@suse.de
- startpar: Try to start more processes even on high loaded systems
- startpar: Detect endless loops on broken systems (no SIGCHILD)
-------------------------------------------------------------------
Thu Apr 19 13:45:46 CEST 2007 - werner@suse.de

View File

@ -22,7 +22,7 @@ Group: System/Base
PreReq: coreutils
Autoreqprov: on
Version: 2.86
Release: 61
Release: 67
Summary: SysV-Style init
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source: sysvinit-2.86.tar.bz2
@ -280,6 +280,9 @@ rm -rf ${RPM_BUILD_ROOT}
%doc %{_mandir}/man8/startpar.8.gz
%changelog
* Fri May 11 2007 - werner@suse.de
- startpar: Try to start more processes even on high loaded systems
- startpar: Detect endless loops on broken systems (no SIGCHILD)
* Thu Apr 19 2007 - werner@suse.de
- Correct exit status of checkproc n case of using a pid file,
thanks to Alessandro Soraruf