]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Get rid of E_RECV.
authorAndre Noll <maan@systemlinux.org>
Sun, 25 Nov 2007 09:59:29 +0000 (10:59 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 25 Nov 2007 09:59:29 +0000 (10:59 +0100)
recv_bin_buffer() returns the converted errno on errors.
So there's no point in having a paraslash error number for recv errors.

afs.c
command.c
error.h
net.c

diff --git a/afs.c b/afs.c
index e84d9a8839a14b5ec7267b62f2c5065414863276..09d4212610e26f5be064d97097bdff4ed8879055 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -206,7 +206,7 @@ int send_callback_request(callback_function *f, struct osl_object *query,
        if (ret < 0)
                goto out;
        if (ret != sizeof(int)) {
-               ret = -E_RECV;
+               ret = -E_AFS_SHORT_READ;
                goto out;
        }
        ret = *(int *) buf;
index ab948b09b129546da1d62a515059deb013e6f50d..c7d1c46791aa09f439bb553e1f8cfdf543f9b51c 100644 (file)
--- a/command.c
+++ b/command.c
@@ -741,15 +741,15 @@ int handle_connect(int fd, struct sockaddr_in *addr)
        /* We can't use send_buffer here since buf may contain null bytes */
        ret = send_bin_buffer(fd,(char *) crypt_buf, numbytes);
        if (ret < 0)
-               goto err_out;
+               goto net_err;
        /* recv decrypted number */
        ret = recv_buffer(fd, buf, sizeof(buf));
        if (ret < 0)
-               goto err_out;
+               goto net_err;
        numbytes = ret;
        ret = -E_AUTH;
        if (!numbytes)
-               goto err_out;
+               goto net_err;
        if (sscanf(buf, CHALLENGE_RESPONSE_MSG "%lu", &chall_response) < 1
                        || chall_response != challenge_nr)
                goto err_out;
@@ -767,12 +767,14 @@ int handle_connect(int fd, struct sockaddr_in *addr)
                numbytes = strlen(buf);
        ret = send_bin_buffer(fd, buf, numbytes);
        if (ret < 0)
-               goto err_out;
+               goto net_err;
        if (use_rc4)
                enable_crypt(fd, rc4_recv, rc4_send, NULL);
        ret = read_command(fd, &command);
-       if (ret < 0)
+       if (ret == -E_COMMAND_SYNTAX)
                goto err_out;
+       if (ret < 0)
+               goto net_err;
        ret = -E_BAD_CMD;
        cmd = parse_cmd(command);
        if (!cmd)
@@ -795,9 +797,9 @@ int handle_connect(int fd, struct sockaddr_in *addr)
                goto out;
        }
 err_out:
+       send_va_buffer(fd, "%s\n", PARA_STRERROR(-ret));
+net_err:
        PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-ret));
-       if (ret != -E_SEND && ret != -E_RECV)
-               send_va_buffer(fd, "%s\n", PARA_STRERROR(-ret));
        ret = EXIT_FAILURE;
 out:
        free(command);
diff --git a/error.h b/error.h
index f1a3e41dd7ef84b54280b54d3a759a08e4397845..c420f490e0b9fc59b27babb2e2f518c1ba3e9260 100644 (file)
--- a/error.h
+++ b/error.h
@@ -86,6 +86,7 @@ extern const char **para_errlist[];
        PARA_ERROR(AFS_SIGNAL, "afs caught deadly signal"), \
        PARA_ERROR(AFS_SOCKET, "afs socket not writable"), \
        PARA_ERROR(AFS_PARENT_DIED, "fatal: server process terminated"), \
+       PARA_ERROR(AFS_SHORT_READ, "short read from afs socket"), \
 
 
 #define MOOD_ERRORS \
@@ -173,7 +174,6 @@ extern const char **para_errlist[];
 
 #define NET_ERRORS \
        PARA_ERROR(SEND, "send error"), \
-       PARA_ERROR(RECV, "receive error"), \
        PARA_ERROR(SOCKET, "socket error"), \
        PARA_ERROR(CONNECT, "connect error"), \
        PARA_ERROR(ACCEPT, "accept error"), \
diff --git a/net.c b/net.c
index c7bb8b4b71293ee89964b55175c2170fb10c3e31..2991b6db5c42b58c0028c371890739323662bba7 100644 (file)
--- a/net.c
+++ b/net.c
@@ -203,12 +203,10 @@ __printf_2_3 int send_va_buffer(int fd, const char *fmt, ...)
  * \param buf the buffer to write the decrypted data to
  * \param size the size of \a buf
  *
- * Receive at most \a size bytes from filedescriptor fd. If encryption is
+ * Receive at most \a size bytes from file descriptor \a fd. If encryption is
  * available, decrypt the received buffer.
  *
- * \return The number of bytes received on success. On receive errors, -E_RECV
- * is returned. On crypt errors, the corresponding crypt error number is
- * returned.
+ * \return The number of bytes received on success, negative on errors.
  *
  * \sa recv(2)
  */
@@ -254,8 +252,7 @@ int recv_buffer(int fd, char *buf, size_t size)
 {
        int n;
 
-       if (!size)
-               return -E_RECV;
+       assert(size);
        n = recv_bin_buffer(fd, buf, size - 1);
        if (n >= 0)
                buf[n] = '\0';