summaryrefslogtreecommitdiff
path: root/source3/lib/util_sock.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-10-30 16:22:24 -0700
committerJeremy Allison <jra@samba.org>2007-10-30 16:22:24 -0700
commitc3250149e12338fac5093991b385ad2807c92d1f (patch)
treefa1e5387fb10d02b1f09da59fc20d7a8520e65fc /source3/lib/util_sock.c
parent4367f4b4d4ce075f3fe8e88e68dbda47e2252349 (diff)
downloadsamba-c3250149e12338fac5093991b385ad2807c92d1f.tar.gz
samba-c3250149e12338fac5093991b385ad2807c92d1f.tar.bz2
samba-c3250149e12338fac5093991b385ad2807c92d1f.zip
Add new parameter, "min receivefile size" (by default set
to zero). If non-zero, writeX calls greater than this value will be left in the socket buffer for later handling with recvfile (or userspace equivalent). Definition of recvfile for your system is left as an exercise for the reader (I'm working on getting splice working :-). Jeremy. (This used to be commit 11c03b75ddbcb6e36b231bb40a1773d1c550621c)
Diffstat (limited to 'source3/lib/util_sock.c')
-rw-r--r--source3/lib/util_sock.c106
1 files changed, 1 insertions, 105 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index e66bd5f15a..bbcbcacb4a 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1113,7 +1113,7 @@ bool send_keepalive(int client)
Timeout is in milliseconds.
****************************************************************************/
-static ssize_t read_smb_length_return_keepalive(int fd,
+ssize_t read_smb_length_return_keepalive(int fd,
char *inbuf,
unsigned int timeout)
{
@@ -1260,86 +1260,6 @@ ssize_t receive_smb_raw(int fd,
return len;
}
-static ssize_t receive_smb_raw_talloc(TALLOC_CTX *mem_ctx, int fd,
- char **buffer, unsigned int timeout)
-{
- char lenbuf[4];
- ssize_t len,ret;
-
- smb_read_error = 0;
-
- len = read_smb_length_return_keepalive(fd, lenbuf, timeout);
- if (len < 0) {
- DEBUG(10,("receive_smb_raw: length < 0!\n"));
-
- /*
- * Correct fix. smb_read_error may have already been
- * set. Only set it here if not already set. Global
- * variables still suck :-). JRA.
- */
-
- if (smb_read_error == 0)
- smb_read_error = READ_ERROR;
- return -1;
- }
-
- /*
- * A WRITEX with CAP_LARGE_WRITEX can be 64k worth of data plus 65 bytes
- * of header. Don't print the error if this fits.... JRA.
- */
-
- if (len > (BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE)) {
- DEBUG(0,("Invalid packet length! (%lu bytes).\n",
- (unsigned long)len));
- if (len > BUFFER_SIZE + (SAFETY_MARGIN/2)) {
-
- /*
- * Correct fix. smb_read_error may have already been
- * set. Only set it here if not already set. Global
- * variables still suck :-). JRA.
- */
-
- if (smb_read_error == 0)
- smb_read_error = READ_ERROR;
- return -1;
- }
- }
-
- /*
- * The +4 here can't wrap, we've checked the length above already.
- */
-
- *buffer = TALLOC_ARRAY(mem_ctx, char, len+4);
-
- if (*buffer == NULL) {
- DEBUG(0, ("Could not allocate inbuf of length %d\n",
- (int)len+4));
- if (smb_read_error == 0)
- smb_read_error = READ_ERROR;
- return -1;
- }
-
- memcpy(*buffer, lenbuf, sizeof(lenbuf));
-
- if(len > 0) {
- if (timeout > 0) {
- ret = read_socket_with_timeout(fd,(*buffer)+4, len,
- len, timeout);
- } else {
- ret = read_data(fd, (*buffer)+4, len);
- }
-
- if (ret != len) {
- if (smb_read_error == 0) {
- smb_read_error = READ_ERROR;
- }
- return -1;
- }
- }
-
- return len + 4;
-}
-
/****************************************************************************
Wrapper for receive_smb_raw().
Checks the MAC on signed packets.
@@ -1364,30 +1284,6 @@ bool receive_smb(int fd, char *buffer, unsigned int timeout)
return true;
}
-ssize_t receive_smb_talloc(TALLOC_CTX *mem_ctx, int fd, char **buffer,
- unsigned int timeout)
-{
- ssize_t len;
-
- len = receive_smb_raw_talloc(mem_ctx, fd, buffer, timeout);
-
- if (len < 0) {
- return -1;
- }
-
- /* Check the incoming SMB signature. */
- if (!srv_check_sign_mac(*buffer, true)) {
- DEBUG(0, ("receive_smb: SMB Signature verification failed on "
- "incoming packet!\n"));
- if (smb_read_error == 0) {
- smb_read_error = READ_BAD_SIG;
- }
- return -1;
- }
-
- return len;
-}
-
/****************************************************************************
Send an smb to a fd.
****************************************************************************/