summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-06-09 01:38:54 +0000
committerJeremy Allison <jra@samba.org>2001-06-09 01:38:54 +0000
commitf63ee18c684af33342de2c5757f9fdf0b7d84997 (patch)
tree0115bdef20e84af196e58bfa8fa5ff6795641087 /source3/lib
parentc7b67c26e2e6d0ba3e881a729bf91e8ba1d9bde7 (diff)
downloadsamba-f63ee18c684af33342de2c5757f9fdf0b7d84997.tar.gz
samba-f63ee18c684af33342de2c5757f9fdf0b7d84997.tar.bz2
samba-f63ee18c684af33342de2c5757f9fdf0b7d84997.zip
*Wonderful* patch from Andrew Bartlett that will help ensure tdb's are
cleaned on clients abending connections. Thanks Andrew ! Jeremy. (This used to be commit 1b3977c5367a0b713b194f369abd9872ae01ac2a)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_sock.c64
1 files changed, 19 insertions, 45 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 144498138a..d741f038ce 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -661,8 +661,10 @@ BOOL receive_smb(int fd,char *buffer, unsigned int timeout)
if (len > (BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE)) {
DEBUG(0,("Invalid packet length! (%d bytes).\n",len));
- if (len > BUFFER_SIZE + (SAFETY_MARGIN/2))
- exit(1);
+ if (len > BUFFER_SIZE + (SAFETY_MARGIN/2)) {
+ smb_read_error = READ_ERROR;
+ return False;
+ }
}
if(len > 0) {
@@ -711,55 +713,27 @@ BOOL client_receive_smb(int fd,char *buffer, unsigned int timeout)
}
/****************************************************************************
- send an null session message to a fd
-****************************************************************************/
-
-BOOL send_null_session_msg(int fd)
-{
- ssize_t ret;
- uint32 blank = 0;
- size_t len = 4;
- size_t nwritten=0;
- char *buffer = (char *)&blank;
-
- while (nwritten < len)
- {
- ret = write_socket(fd,buffer+nwritten,len - nwritten);
- if (ret <= 0)
- {
- DEBUG(0,("send_null_session_msg: Error writing %d bytes to client. %d. Exiting\n",(int)len,(int)ret));
- exit(1);
- }
- nwritten += ret;
- }
-
- DEBUG(10,("send_null_session_msg: sent 4 null bytes to client.\n"));
- return True;
-}
-
-/****************************************************************************
send an smb to a fd
****************************************************************************/
BOOL send_smb(int fd,char *buffer)
{
- size_t len;
- size_t nwritten=0;
- ssize_t ret;
- len = smb_len(buffer) + 4;
-
- while (nwritten < len)
- {
- ret = write_socket(fd,buffer+nwritten,len - nwritten);
- if (ret <= 0)
- {
- DEBUG(0,("Error writing %d bytes to client. %d. Exiting\n",(int)len,(int)ret));
- exit(1);
- }
- nwritten += ret;
- }
+ size_t len;
+ size_t nwritten=0;
+ ssize_t ret;
+ len = smb_len(buffer) + 4;
+
+ while (nwritten < len) {
+ ret = write_socket(fd,buffer+nwritten,len - nwritten);
+ if (ret <= 0) {
+ DEBUG(0,("Error writing %d bytes to client. %d. (%s)\n",
+ (int)len,(int)ret, strerror(errno) ));
+ return False;
+ }
+ nwritten += ret;
+ }
- return True;
+ return True;
}
/****************************************************************************