|
Michal Schmidt |
e43452 |
From 79dbd0ccda06dc6b9d1a6a8a04a214895b0d91e8 Mon Sep 17 00:00:00 2001
|
|
Michal Schmidt |
e43452 |
From: Lennart Poettering <lennart@poettering.net>
|
|
Michal Schmidt |
e43452 |
Date: Tue, 3 Jan 2012 20:41:20 +0100
|
|
Michal Schmidt |
f1996e |
Subject: [PATCH] nspawn: get rid of BUFFER_SIZE, use LINE_MAX instead (cherry
|
|
Michal Schmidt |
f1996e |
picked from commit
|
|
Michal Schmidt |
e43452 |
b72491a2fd8c237299055c636d4f748bca2b4b1f)
|
|
Michal Schmidt |
e43452 |
|
|
Michal Schmidt |
e43452 |
---
|
|
Michal Schmidt |
e43452 |
src/nspawn.c | 12 +++++-------
|
|
Michal Schmidt |
e43452 |
1 files changed, 5 insertions(+), 7 deletions(-)
|
|
Michal Schmidt |
e43452 |
|
|
Michal Schmidt |
e43452 |
diff --git a/src/nspawn.c b/src/nspawn.c
|
|
Michal Schmidt |
e43452 |
index 653d7db..3ea603f 100644
|
|
Michal Schmidt |
e43452 |
--- a/src/nspawn.c
|
|
Michal Schmidt |
e43452 |
+++ b/src/nspawn.c
|
|
Michal Schmidt |
e43452 |
@@ -394,11 +394,9 @@ static int is_os_tree(const char *path) {
|
|
Michal Schmidt |
e43452 |
return r < 0 ? 0 : 1;
|
|
Michal Schmidt |
e43452 |
}
|
|
Michal Schmidt |
e43452 |
|
|
Michal Schmidt |
e43452 |
-#define BUFFER_SIZE 1024
|
|
Michal Schmidt |
e43452 |
-
|
|
Michal Schmidt |
e43452 |
static int process_pty(int master, sigset_t *mask) {
|
|
Michal Schmidt |
e43452 |
|
|
Michal Schmidt |
e43452 |
- char in_buffer[BUFFER_SIZE], out_buffer[BUFFER_SIZE];
|
|
Michal Schmidt |
e43452 |
+ char in_buffer[LINE_MAX], out_buffer[LINE_MAX];
|
|
Michal Schmidt |
e43452 |
size_t in_buffer_full = 0, out_buffer_full = 0;
|
|
Michal Schmidt |
e43452 |
struct epoll_event stdin_ev, stdout_ev, master_ev, signal_ev;
|
|
Michal Schmidt |
e43452 |
bool stdin_readable = false, stdout_writable = false, master_readable = false, master_writable = false;
|
|
Michal Schmidt |
e43452 |
@@ -519,9 +517,9 @@ static int process_pty(int master, sigset_t *mask) {
|
|
Michal Schmidt |
e43452 |
(master_readable && out_buffer_full <= 0) ||
|
|
Michal Schmidt |
e43452 |
(stdout_writable && out_buffer_full > 0)) {
|
|
Michal Schmidt |
e43452 |
|
|
Michal Schmidt |
e43452 |
- if (stdin_readable && in_buffer_full < BUFFER_SIZE) {
|
|
Michal Schmidt |
e43452 |
+ if (stdin_readable && in_buffer_full < LINE_MAX) {
|
|
Michal Schmidt |
e43452 |
|
|
Michal Schmidt |
e43452 |
- if ((k = read(STDIN_FILENO, in_buffer + in_buffer_full, BUFFER_SIZE - in_buffer_full)) < 0) {
|
|
Michal Schmidt |
e43452 |
+ if ((k = read(STDIN_FILENO, in_buffer + in_buffer_full, LINE_MAX - in_buffer_full)) < 0) {
|
|
Michal Schmidt |
e43452 |
|
|
Michal Schmidt |
e43452 |
if (errno == EAGAIN || errno == EPIPE || errno == ECONNRESET || errno == EIO)
|
|
Michal Schmidt |
e43452 |
stdin_readable = false;
|
|
Michal Schmidt |
e43452 |
@@ -553,9 +551,9 @@ static int process_pty(int master, sigset_t *mask) {
|
|
Michal Schmidt |
e43452 |
}
|
|
Michal Schmidt |
e43452 |
}
|
|
Michal Schmidt |
e43452 |
|
|
Michal Schmidt |
e43452 |
- if (master_readable && out_buffer_full < BUFFER_SIZE) {
|
|
Michal Schmidt |
e43452 |
+ if (master_readable && out_buffer_full < LINE_MAX) {
|
|
Michal Schmidt |
e43452 |
|
|
Michal Schmidt |
e43452 |
- if ((k = read(master, out_buffer + out_buffer_full, BUFFER_SIZE - out_buffer_full)) < 0) {
|
|
Michal Schmidt |
e43452 |
+ if ((k = read(master, out_buffer + out_buffer_full, LINE_MAX - out_buffer_full)) < 0) {
|
|
Michal Schmidt |
e43452 |
|
|
Michal Schmidt |
e43452 |
if (errno == EAGAIN || errno == EPIPE || errno == ECONNRESET || errno == EIO)
|
|
Michal Schmidt |
e43452 |
master_readable = false;
|