diff options
| author | Eric Marsden | 2024-12-11 16:59:45 +0100 |
|---|---|---|
| committer | Robert Pluim | 2024-12-13 14:12:39 +0100 |
| commit | c265febd97e940e6580ae42aa648358a0a2ed830 (patch) | |
| tree | ac196e4708f07102b87138e237bc0f5a4fb4fd9c | |
| parent | 989cdb2c35889476702e4d2bd82d8195fa2e7ec0 (diff) | |
| download | emacs-c265febd97e940e6580ae42aa648358a0a2ed830.tar.gz emacs-c265febd97e940e6580ae42aa648358a0a2ed830.zip | |
Add support for TCP_NODELAY on network streams
* src/process.c (socket_options): add entry for TCP_NODELAY.
* lisp/emacs-lisp/bytecomp.el: add :nodelay to valid keywords
for make-network-process compiler-macro.
* doc/lispref/processes.texi: document :nodelay keyword argument
to set-network-process-option and make-network-process.
(Bug#74793)
| -rw-r--r-- | doc/lispref/processes.texi | 7 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 4 | ||||
| -rw-r--r-- | src/process.c | 5 |
3 files changed, 14 insertions, 2 deletions
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 79ef959ae65..e0d71ac22b6 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi | |||
| @@ -3090,6 +3090,13 @@ listening on that port. If @var{reuseaddr-flag} is @code{nil}, there | |||
| 3090 | may be a period of time after the last use of that port (by any | 3090 | may be a period of time after the last use of that port (by any |
| 3091 | process on the host) where it is not possible to make a new server on | 3091 | process on the host) where it is not possible to make a new server on |
| 3092 | that port. | 3092 | that port. |
| 3093 | |||
| 3094 | @item :nodelay @var{nodelay-flag} | ||
| 3095 | If @var{nodelay-flag} is non-@code{nil}, the @code{TCP_NODELAY} option | ||
| 3096 | is enabled on the socket. This disables the Nagle algorithm, meaning | ||
| 3097 | that network segments are sent as soon as possible, even when they | ||
| 3098 | contain little data. This reduces network latency on the network | ||
| 3099 | connection, but can lead to many small packets being sent. | ||
| 3093 | @end table | 3100 | @end table |
| 3094 | 3101 | ||
| 3095 | @defun set-network-process-option process option value &optional no-error | 3102 | @defun set-network-process-option process option value &optional no-error |
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index f058fc48cc7..07eb4690fce 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -6049,8 +6049,8 @@ and corresponding effects." | |||
| 6049 | :buffer :host :service :type :family :local :remote :coding | 6049 | :buffer :host :service :type :family :local :remote :coding |
| 6050 | :nowait :noquery :stop :filter :filter-multibyte :sentinel | 6050 | :nowait :noquery :stop :filter :filter-multibyte :sentinel |
| 6051 | :log :plist :tls-parameters :server :broadcast :dontroute | 6051 | :log :plist :tls-parameters :server :broadcast :dontroute |
| 6052 | :keepalive :linger :oobinline :priority :reuseaddr :bindtodevice | 6052 | :keepalive :linger :oobinline :priority :reuseaddr :nodelay |
| 6053 | :use-external-socket) | 6053 | :bindtodevice :use-external-socket) |
| 6054 | '(:name :service)))) | 6054 | '(:name :service)))) |
| 6055 | 6055 | ||
| 6056 | (provide 'byte-compile) | 6056 | (provide 'byte-compile) |
diff --git a/src/process.c b/src/process.c index b71ba3daf2d..cd1378f07ad 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -38,6 +38,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 38 | #include <sys/socket.h> | 38 | #include <sys/socket.h> |
| 39 | #include <netdb.h> | 39 | #include <netdb.h> |
| 40 | #include <netinet/in.h> | 40 | #include <netinet/in.h> |
| 41 | #include <netinet/tcp.h> | ||
| 41 | #include <arpa/inet.h> | 42 | #include <arpa/inet.h> |
| 42 | 43 | ||
| 43 | #else | 44 | #else |
| @@ -2861,6 +2862,9 @@ static const struct socket_options { | |||
| 2861 | #ifdef SO_REUSEADDR | 2862 | #ifdef SO_REUSEADDR |
| 2862 | { ":reuseaddr", SOL_SOCKET, SO_REUSEADDR, SOPT_BOOL, OPIX_REUSEADDR }, | 2863 | { ":reuseaddr", SOL_SOCKET, SO_REUSEADDR, SOPT_BOOL, OPIX_REUSEADDR }, |
| 2863 | #endif | 2864 | #endif |
| 2865 | #ifdef TCP_NODELAY | ||
| 2866 | { ":nodelay", IPPROTO_TCP, TCP_NODELAY, SOPT_BOOL, OPIX_MISC }, | ||
| 2867 | #endif | ||
| 2864 | { 0, 0, 0, SOPT_UNKNOWN, OPIX_NONE } | 2868 | { 0, 0, 0, SOPT_UNKNOWN, OPIX_NONE } |
| 2865 | }; | 2869 | }; |
| 2866 | 2870 | ||
| @@ -3899,6 +3903,7 @@ The following network options can be specified for this connection: | |||
| 3899 | :broadcast BOOL -- Allow send and receive of datagram broadcasts. | 3903 | :broadcast BOOL -- Allow send and receive of datagram broadcasts. |
| 3900 | :dontroute BOOL -- Only send to directly connected hosts. | 3904 | :dontroute BOOL -- Only send to directly connected hosts. |
| 3901 | :keepalive BOOL -- Send keep-alive messages on network stream. | 3905 | :keepalive BOOL -- Send keep-alive messages on network stream. |
| 3906 | :nodelay BOOL -- Set TCP_NODELAY on the network socket. | ||
| 3902 | :linger BOOL or TIMEOUT -- Send queued messages before closing. | 3907 | :linger BOOL or TIMEOUT -- Send queued messages before closing. |
| 3903 | :oobinline BOOL -- Place out-of-band data in receive data stream. | 3908 | :oobinline BOOL -- Place out-of-band data in receive data stream. |
| 3904 | :priority INT -- Set protocol defined priority for sent packets. | 3909 | :priority INT -- Set protocol defined priority for sent packets. |