summaryrefslogtreecommitdiff
path: root/source/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
commit1b3977c5367a0b713b194f369abd9872ae01ac2a (patch)
treeacbfc993c1bfdd750797a785fac55f1834c7a406 /source/lib
parent81b5a628d1471f71964b21817b9bec1ac80585c4 (diff)
downloadsamba-1b3977c5367a0b713b194f369abd9872ae01ac2a.tar.gz
*Wonderful* patch from Andrew Bartlett that will help ensure tdb's are
cleaned on clients abending connections. Thanks Andrew ! Jeremy.
Diffstat (limited to 'source/lib')
-rw-r--r--source/lib/util_sock.c64
1 files changed, 19 insertions, 45 deletions
diff --git a/source/lib/util_sock.c b/source/lib/util_sock.c
index 144498138a7..d741f038cea 100644
--- a/source/lib/util_sock.c
+++ b/source/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;
}
/****************************************************************************