diff options
| author | John Wiegley | 2016-01-18 22:56:33 -0800 |
|---|---|---|
| committer | John Wiegley | 2016-01-18 22:56:33 -0800 |
| commit | 6acd2aa02c6f0eb9d3fadce0bb48183837beafd8 (patch) | |
| tree | d236a14dc554951c3e7c5a5b38a3bd98edc1315a /src | |
| parent | 564c84f4b12482aefe86539d2471607565c3ee7c (diff) | |
| parent | 549a765efeca2748e68a5c6ce6c9238784e82535 (diff) | |
| download | emacs-6acd2aa02c6f0eb9d3fadce0bb48183837beafd8.tar.gz emacs-6acd2aa02c6f0eb9d3fadce0bb48183837beafd8.zip | |
-
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.c | 8 | ||||
| -rw-r--r-- | src/w32.c | 39 | ||||
| -rw-r--r-- | src/w32proc.c | 7 |
3 files changed, 39 insertions, 15 deletions
diff --git a/src/buffer.c b/src/buffer.c index 1468e7a2be1..4df77a181d6 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -5630,13 +5630,7 @@ Decimal digits after the % specify field width to which to pad. */); | |||
| 5630 | doc: /* Symbol for current buffer's major mode. | 5630 | doc: /* Symbol for current buffer's major mode. |
| 5631 | The default value (normally `fundamental-mode') affects new buffers. | 5631 | The default value (normally `fundamental-mode') affects new buffers. |
| 5632 | A value of nil means to use the current buffer's major mode, provided | 5632 | A value of nil means to use the current buffer's major mode, provided |
| 5633 | it is not marked as "special". | 5633 | it is not marked as "special". */); |
| 5634 | |||
| 5635 | When a mode is used by default, `find-file' switches to it before it | ||
| 5636 | reads the contents into the buffer and before it finishes setting up | ||
| 5637 | the buffer. Thus, the mode and its hooks should not expect certain | ||
| 5638 | variables such as `buffer-read-only' and `buffer-file-coding-system' | ||
| 5639 | to be set up. */); | ||
| 5640 | 5634 | ||
| 5641 | DEFVAR_PER_BUFFER ("mode-name", &BVAR (current_buffer, mode_name), | 5635 | DEFVAR_PER_BUFFER ("mode-name", &BVAR (current_buffer, mode_name), |
| 5642 | Qnil, | 5636 | Qnil, |
| @@ -8043,14 +8043,19 @@ pipe2 (int * phandles, int pipe2_flags) | |||
| 8043 | { | 8043 | { |
| 8044 | int rc; | 8044 | int rc; |
| 8045 | unsigned flags; | 8045 | unsigned flags; |
| 8046 | unsigned pipe_size = 0; | ||
| 8046 | 8047 | ||
| 8047 | eassert (pipe2_flags == (O_BINARY | O_CLOEXEC)); | 8048 | eassert (pipe2_flags == (O_BINARY | O_CLOEXEC)); |
| 8048 | 8049 | ||
| 8050 | /* Allow Lisp to override the default buffer size of the pipe. */ | ||
| 8051 | if (w32_pipe_buffer_size > 0 && w32_pipe_buffer_size < UINT_MAX) | ||
| 8052 | pipe_size = w32_pipe_buffer_size; | ||
| 8053 | |||
| 8049 | /* make pipe handles non-inheritable; when we spawn a child, we | 8054 | /* make pipe handles non-inheritable; when we spawn a child, we |
| 8050 | replace the relevant handle with an inheritable one. Also put | 8055 | replace the relevant handle with an inheritable one. Also put |
| 8051 | pipes into binary mode; we will do text mode translation ourselves | 8056 | pipes into binary mode; we will do text mode translation ourselves |
| 8052 | if required. */ | 8057 | if required. */ |
| 8053 | rc = _pipe (phandles, 0, _O_NOINHERIT | _O_BINARY); | 8058 | rc = _pipe (phandles, pipe_size, _O_NOINHERIT | _O_BINARY); |
| 8054 | 8059 | ||
| 8055 | if (rc == 0) | 8060 | if (rc == 0) |
| 8056 | { | 8061 | { |
| @@ -8632,15 +8637,35 @@ sys_write (int fd, const void * buffer, unsigned int count) | |||
| 8632 | http://thread.gmane.org/gmane.comp.version-control.git/145294 | 8637 | http://thread.gmane.org/gmane.comp.version-control.git/145294 |
| 8633 | in the git mailing list. */ | 8638 | in the git mailing list. */ |
| 8634 | const unsigned char *p = buffer; | 8639 | const unsigned char *p = buffer; |
| 8635 | const unsigned chunk = 30 * 1024 * 1024; | 8640 | const bool is_pipe = (fd < MAXDESC |
| 8641 | && ((fd_info[fd].flags & (FILE_PIPE | FILE_NDELAY)) | ||
| 8642 | == (FILE_PIPE | FILE_NDELAY))); | ||
| 8643 | /* Some programs, notably Node.js's node.exe, seem to never | ||
| 8644 | completely empty the pipe, so writing more than the size of | ||
| 8645 | the pipe's buffer always returns ENOSPC, and we loop forever | ||
| 8646 | between send_process and here. As a workaround, write no | ||
| 8647 | more than the pipe's buffer can hold. */ | ||
| 8648 | DWORD pipe_buffer_size; | ||
| 8649 | if (is_pipe) | ||
| 8650 | { | ||
| 8651 | if (!GetNamedPipeInfo ((HANDLE)_get_osfhandle (fd), | ||
| 8652 | NULL, &pipe_buffer_size, NULL, NULL)) | ||
| 8653 | { | ||
| 8654 | DebPrint (("GetNamedPipeInfo: error %u\n", GetLastError ())); | ||
| 8655 | pipe_buffer_size = 4096; | ||
| 8656 | } | ||
| 8657 | } | ||
| 8658 | const unsigned chunk = is_pipe ? pipe_buffer_size : 30 * 1024 * 1024; | ||
| 8636 | 8659 | ||
| 8637 | nchars = 0; | 8660 | nchars = 0; |
| 8661 | errno = 0; | ||
| 8638 | while (count > 0) | 8662 | while (count > 0) |
| 8639 | { | 8663 | { |
| 8640 | unsigned this_chunk = count < chunk ? count : chunk; | 8664 | unsigned this_chunk = count < chunk ? count : chunk; |
| 8641 | int n = _write (fd, p, this_chunk); | 8665 | int n = _write (fd, p, this_chunk); |
| 8642 | 8666 | ||
| 8643 | nchars += n; | 8667 | if (n > 0) |
| 8668 | nchars += n; | ||
| 8644 | if (n < 0) | 8669 | if (n < 0) |
| 8645 | { | 8670 | { |
| 8646 | /* When there's no buffer space in a pipe that is in the | 8671 | /* When there's no buffer space in a pipe that is in the |
| @@ -8654,12 +8679,10 @@ sys_write (int fd, const void * buffer, unsigned int count) | |||
| 8654 | avoiding deadlock whereby each side of the pipe is | 8679 | avoiding deadlock whereby each side of the pipe is |
| 8655 | blocked on write, waiting for the other party to read | 8680 | blocked on write, waiting for the other party to read |
| 8656 | its end of the pipe. */ | 8681 | its end of the pipe. */ |
| 8657 | if (errno == ENOSPC | 8682 | if (errno == ENOSPC && is_pipe) |
| 8658 | && fd < MAXDESC | ||
| 8659 | && ((fd_info[fd].flags & (FILE_PIPE | FILE_NDELAY)) | ||
| 8660 | == (FILE_PIPE | FILE_NDELAY))) | ||
| 8661 | errno = EAGAIN; | 8683 | errno = EAGAIN; |
| 8662 | nchars = n; | 8684 | if (nchars == 0) |
| 8685 | nchars = -1; | ||
| 8663 | break; | 8686 | break; |
| 8664 | } | 8687 | } |
| 8665 | else if (n < this_chunk) | 8688 | else if (n < this_chunk) |
diff --git a/src/w32proc.c b/src/w32proc.c index a65f085fb3d..a89a9850466 100644 --- a/src/w32proc.c +++ b/src/w32proc.c | |||
| @@ -3702,6 +3702,13 @@ of time slices to wait (effectively boosting the priority of the child | |||
| 3702 | process temporarily). A value of zero disables waiting entirely. */); | 3702 | process temporarily). A value of zero disables waiting entirely. */); |
| 3703 | w32_pipe_read_delay = 50; | 3703 | w32_pipe_read_delay = 50; |
| 3704 | 3704 | ||
| 3705 | DEFVAR_INT ("w32-pipe-buffer-size", w32_pipe_buffer_size, | ||
| 3706 | doc: /* Size of buffer for pipes created to communicate with subprocesses. | ||
| 3707 | The size is in bytes, and must be non-negative. The default is zero, | ||
| 3708 | which lets the OS use its default size, usually 4KB (4096 bytes). | ||
| 3709 | Any negative value means to use the default value of zero. */); | ||
| 3710 | w32_pipe_buffer_size = 0; | ||
| 3711 | |||
| 3705 | DEFVAR_LISP ("w32-downcase-file-names", Vw32_downcase_file_names, | 3712 | DEFVAR_LISP ("w32-downcase-file-names", Vw32_downcase_file_names, |
| 3706 | doc: /* Non-nil means convert all-upper case file names to lower case. | 3713 | doc: /* Non-nil means convert all-upper case file names to lower case. |
| 3707 | This applies when performing completions and file name expansion. | 3714 | This applies when performing completions and file name expansion. |