-
Notifications
You must be signed in to change notification settings - Fork 140
Use the actual pipe size instead of 8,192 #615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,6 +165,10 @@ int main(int argc, char *argv[]) | |
| pexit("Failed to create !terminal stdin pipe"); | ||
|
|
||
| mainfd_stdin = fds[1]; | ||
| ret = fcntl(mainfd_stdin, F_GETPIPE_SZ); | ||
| if (ret < 0) | ||
| pexit("main stdin pipe size determination failed"); | ||
| mainfd_stdin_size = (size_t)ret; | ||
| workerfd_stdin = fds[0]; | ||
|
|
||
| if (g_unix_set_fd_nonblocking(mainfd_stdin, TRUE, NULL) == FALSE) | ||
|
|
@@ -175,6 +179,10 @@ int main(int argc, char *argv[]) | |
| pexit("Failed to create !terminal stdout pipe"); | ||
|
|
||
| mainfd_stdout = fds[0]; | ||
| ret = fcntl(mainfd_stdout, F_GETPIPE_SZ); | ||
| if (ret < 0) | ||
| pexit("main stdout pipe size determination failed"); | ||
| mainfd_stdout_size = (size_t)ret; | ||
| workerfd_stdout = fds[1]; | ||
| } | ||
|
|
||
|
|
@@ -194,6 +202,13 @@ int main(int argc, char *argv[]) | |
| pexit("Failed to create stderr pipe"); | ||
|
|
||
| mainfd_stderr = fds[0]; | ||
| ret = fcntl(mainfd_stderr, F_GETPIPE_SZ); | ||
| if (ret < 0) | ||
| pexit("main stderr pipe size determination failed"); | ||
| mainfd_stderr_size = (size_t)ret; | ||
| if ((mainfd_stdout >= 0) && (mainfd_stderr_size != mainfd_stdout_size)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, why do we care about the sizes to be the same?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've never seen these being different in real life. As a matter of fact I'd remove the whole condition as it never triggers. |
||
| nwarn("main stderr and stdout pipe sizes don't match"); | ||
| } | ||
| workerfd_stderr = fds[1]; | ||
|
|
||
| GPtrArray *runtime_argv = configure_runtime_args(csname); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,13 +112,14 @@ static void drain_log_buffers(stdpipe_t pipe) | |
|
|
||
| static bool read_stdio(int fd, stdpipe_t pipe, gboolean *eof) | ||
| { | ||
| char buf[STDIO_BUF_SIZE]; | ||
| size_t buf_size = ((pipe == STDOUT_PIPE) ? mainfd_stdout_size : mainfd_stderr_size); | ||
| char *buf = alloca(buf_size); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't |
||
| ssize_t num_read = 0; | ||
|
|
||
| if (eof) | ||
| *eof = false; | ||
|
|
||
| num_read = read(fd, buf, STDIO_BUF_SIZE); | ||
| num_read = read(fd, buf, buf_size); | ||
| if (num_read == 0) { | ||
| if (eof) | ||
| *eof = true; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I admit the fcntl should never fail, since we've just created the pipe and it will just be valid, but could we maybe default to DEF_STDOUT_BUF_SIZE also in this case and also for
mainfd_stdout_sizebelow? It seems to be more fail-safe way than simply exiting.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this one seems to be way brutal, just warning and
mainfd_stdin_size = DEF_STDOUT_BUF_SIZE;would do it with grace it seems.