vol: Log more info on wrong SYNC response length
[openafs.git] / src / vol / daemon_com.c
index 0ae1e2b..4256a20 100644 (file)
@@ -27,6 +27,7 @@
 #include <rx/xdr.h>
 #include <afs/afsint.h>
 #include <afs/errors.h>
+#include <rx/rx_queue.h>
 
 #include "nfs.h"
 #include "daemon_com.h"
@@ -80,17 +81,13 @@ static int SYNC_ask_internal(SYNC_client_state * state, SYNC_command * com, SYNC
 void
 SYNC_getAddr(SYNC_endpoint_t * endpoint, SYNC_sockaddr_t * addr)
 {
-#ifdef USE_UNIX_SOCKETS
-    char tbuffer[AFSDIR_PATH_MAX];
-#endif /* USE_UNIX_SOCKETS */
-
     memset(addr, 0, sizeof(*addr));
 
 #ifdef USE_UNIX_SOCKETS
-    strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/",
-               endpoint->un, NULL);
     addr->sun_family = AF_UNIX;
-    strncpy(addr->sun_path, tbuffer, (sizeof(struct sockaddr_un) - sizeof(short)));
+    snprintf(addr->sun_path, sizeof(addr->sun_path), "%s/%s",
+            AFSDIR_SERVER_LOCAL_DIRPATH, endpoint->un);
+    addr->sun_path[sizeof(addr->sun_path) - 1] = '\0';
 #else  /* !USE_UNIX_SOCKETS */
 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
     addr->sin_len = sizeof(struct sockaddr_in);
@@ -115,7 +112,7 @@ osi_socket
 SYNC_getSock(SYNC_endpoint_t * endpoint)
 {
     osi_socket sd;
-    osi_Assert((sd = socket(endpoint->domain, SOCK_STREAM, 0)) >= 0);
+    opr_Verify((sd = socket(endpoint->domain, SOCK_STREAM, 0)) >= 0);
     return sd;
 }
 
@@ -443,7 +440,10 @@ SYNC_ask_internal(SYNC_client_state * state, SYNC_command * com, SYNC_response *
 
     if (res->hdr.response_len != n) {
        Log("SYNC_ask:  length field in response inconsistent "
-           "on circuit '%s'\n", state->proto_name);
+           "on circuit '%s' command %ld, %d != %lu\n", state->proto_name,
+           afs_printable_int32_ld(com->hdr.command),
+           n,
+           afs_printable_uint32_lu(res->hdr.response_len));
        res->hdr.response = SYNC_COM_ERROR;
        goto done;
     }