emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c6d8db8d91: Display error in emacsclient if setsockopt failed


From: Stefan Kangas
Subject: master c6d8db8d91: Display error in emacsclient if setsockopt failed
Date: Fri, 9 Sep 2022 05:22:42 -0400 (EDT)

branch: master
commit c6d8db8d91649d4e30bb26c662ac867136005c0c
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Display error in emacsclient if setsockopt failed
    
    * lib-src/emacsclient.c (set_tcp_socket, set_socket_timeout): Display
    an error message if setsockopt failed.
---
 lib-src/emacsclient.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 49d90a989f..88800b9b2e 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1078,7 +1078,9 @@ set_tcp_socket (const char *local_server_file)
 
   /* The cast to 'const char *' is to avoid a compiler warning when
      compiling for MS-Windows sockets.  */
-  setsockopt (s, SOL_SOCKET, SO_LINGER, (const char *) &l_arg, sizeof l_arg);
+  int ret = setsockopt (s, SOL_SOCKET, SO_LINGER, (const char *) &l_arg, 
sizeof l_arg);
+  if (ret < 0)
+    sock_err_message ("setsockopt");
 
   /* Send the authentication.  */
   auth_string[AUTH_KEY_LENGTH] = '\0';
@@ -1892,11 +1894,13 @@ start_daemon_and_retry_set_socket (void)
 static void
 set_socket_timeout (HSOCKET socket, int seconds)
 {
+  int ret;
+
 #ifndef WINDOWSNT
   struct timeval timeout;
   timeout.tv_sec = seconds;
   timeout.tv_usec = 0;
-  setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout);
+  ret = setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout);
 #else
   DWORD timeout;
 
@@ -1904,8 +1908,11 @@ set_socket_timeout (HSOCKET socket, int seconds)
     timeout = INT_MAX;
   else
     timeout = seconds * 1000;
-  setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) &timeout, sizeof 
timeout);
+  ret = setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) &timeout, sizeof 
timeout);
 #endif
+
+  if (ret < 0)
+    sock_err_message ("setsockopt");
 }
 
 static bool



reply via email to

[Prev in Thread] Current Thread [Next in Thread]