Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153973506
D56526.id175926.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D56526.id175926.diff
View Options
diff --git a/usr.sbin/ctld/ctld.cc b/usr.sbin/ctld/ctld.cc
--- a/usr.sbin/ctld/ctld.cc
+++ b/usr.sbin/ctld/ctld.cc
@@ -2295,18 +2295,17 @@
log_err(1, "setitimer");
}
-static int
+static void
wait_for_children(bool block)
{
pid_t pid;
int status;
- int num = 0;
- for (;;) {
- /*
- * If "block" is true, wait for at least one process.
- */
- if (block && num == 0)
+ /*
+ * If "block" is true, wait for at least one process.
+ */
+ while (nchildren > 0) {
+ if (block)
pid = wait4(-1, &status, 0, NULL);
else
pid = wait4(-1, &status, WNOHANG, NULL);
@@ -2321,10 +2320,10 @@
} else {
log_debugx("child process %d terminated gracefully", pid);
}
- num++;
- }
+ nchildren--;
- return (num);
+ block = false;
+ }
}
static void
@@ -2343,15 +2342,13 @@
if (dont_fork) {
log_debugx("incoming connection; not forking due to -d flag");
} else {
- nchildren -= wait_for_children(false);
- assert(nchildren >= 0);
+ wait_for_children(false);
while (conf->maxproc() > 0 && nchildren >= conf->maxproc()) {
log_debugx("maxproc limit of %d child processes hit; "
"waiting for child process to exit",
conf->maxproc());
- nchildren -= wait_for_children(true);
- assert(nchildren >= 0);
+ wait_for_children(true);
}
log_debugx("incoming connection; forking child process #%d",
nchildren);
@@ -2791,8 +2788,7 @@
log_warnx("exiting on signal");
return (0);
} else {
- nchildren -= wait_for_children(false);
- assert(nchildren >= 0);
+ wait_for_children(false);
if (timed_out()) {
newconf->isns_update();
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 26, 5:04 AM (16 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31922883
Default Alt Text
D56526.id175926.diff (1 KB)
Attached To
Mode
D56526: ctld: Update nchildren directly in wait_for_children
Attached
Detach File
Event Timeline
Log In to Comment