diff options
| author | Eli Zaretskii | 2022-09-06 15:09:09 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2022-09-06 15:09:09 +0300 |
| commit | 088b81031b8873f898cc611d73d1d2d55eb3c942 (patch) | |
| tree | 158e52cc75d1a411566cf9f8c6fcb0e1b95db81f /lib-src | |
| parent | a99665cf38b0a237d6d0afed09a061ee0080cb19 (diff) | |
| download | emacs-088b81031b8873f898cc611d73d1d2d55eb3c942.tar.gz emacs-088b81031b8873f898cc611d73d1d2d55eb3c942.zip | |
Fix the MS-Windows build
* lib-src/emacsclient.c (DEFAULT_TIMEOUT): Move out of the
!WINDOWSNT condition, to fix the MS-Windows compilation.
(set_socket_timeout) [WINDOWSNT]: Protect against too-large values
of timeout.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/emacsclient.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 15acb4589a9..2e5d8d0cc24 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -55,8 +55,6 @@ char *w32_getenv (const char *); | |||
| 55 | # include <sys/socket.h> | 55 | # include <sys/socket.h> |
| 56 | # include <sys/un.h> | 56 | # include <sys/un.h> |
| 57 | 57 | ||
| 58 | # define DEFAULT_TIMEOUT (30) | ||
| 59 | |||
| 60 | # define SOCKETS_IN_FILE_SYSTEM | 58 | # define SOCKETS_IN_FILE_SYSTEM |
| 61 | 59 | ||
| 62 | # define INVALID_SOCKET (-1) | 60 | # define INVALID_SOCKET (-1) |
| @@ -68,6 +66,8 @@ char *w32_getenv (const char *); | |||
| 68 | 66 | ||
| 69 | #endif /* !WINDOWSNT */ | 67 | #endif /* !WINDOWSNT */ |
| 70 | 68 | ||
| 69 | #define DEFAULT_TIMEOUT (30) | ||
| 70 | |||
| 71 | #include <ctype.h> | 71 | #include <ctype.h> |
| 72 | #include <errno.h> | 72 | #include <errno.h> |
| 73 | #include <getopt.h> | 73 | #include <getopt.h> |
| @@ -1898,7 +1898,12 @@ set_socket_timeout (HSOCKET socket, int seconds) | |||
| 1898 | timeout.tv_usec = 0; | 1898 | timeout.tv_usec = 0; |
| 1899 | setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout); | 1899 | setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout); |
| 1900 | #else | 1900 | #else |
| 1901 | DWORD timeout = seconds * 1000; | 1901 | DWORD timeout; |
| 1902 | |||
| 1903 | if (seconds > INT_MAX / 1000) | ||
| 1904 | timeout = INT_MAX; | ||
| 1905 | else | ||
| 1906 | timeout = seconds * 1000; | ||
| 1902 | setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) &timeout, sizeof timeout); | 1907 | setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) &timeout, sizeof timeout); |
| 1903 | #endif | 1908 | #endif |
| 1904 | } | 1909 | } |