summaryrefslogtreecommitdiff
path: root/source3/lib/util_sock.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util_sock.c')
-rw-r--r--source3/lib/util_sock.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 1a7cc02229..ced1130536 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1123,20 +1123,16 @@ ssize_t read_smb_length_return_keepalive(int fd,
{
ssize_t len=0;
int msg_type;
- bool ok = false;
- while (!ok) {
- ok = (read_socket_with_timeout(fd,inbuf,4,4,timeout,pre) == 4);
- if (!ok) {
- return -1;
- }
+ if (read_socket_with_timeout(fd, inbuf, 4, 4, timeout, pre) != 4) {
+ return -1;
+ }
- len = smb_len(inbuf);
- msg_type = CVAL(inbuf,0);
+ len = smb_len(inbuf);
+ msg_type = CVAL(inbuf,0);
- if (msg_type == SMBkeepalive) {
- DEBUG(5,("Got keepalive packet\n"));
- }
+ if (msg_type == SMBkeepalive) {
+ DEBUG(5,("Got keepalive packet\n"));
}
DEBUG(10,("got smb length of %lu\n",(unsigned long)len));
@@ -1154,16 +1150,15 @@ ssize_t read_smb_length_return_keepalive(int fd,
ssize_t read_smb_length(int fd, char *inbuf, unsigned int timeout, enum smb_read_errors *pre)
{
ssize_t len;
+ uint8_t msgtype = SMBkeepalive;
- for(;;) {
- len = read_smb_length_return_keepalive(fd, inbuf, timeout, pre);
-
- if(len < 0)
+ while (msgtype == SMBkeepalive) {
+ len = read_smb_length_return_keepalive(fd, inbuf, timeout,
+ pre);
+ if (len < 0) {
return len;
-
- /* Ignore session keepalives. */
- if(CVAL(inbuf,0) != SMBkeepalive)
- break;
+ }
+ msgtype = CVAL(inbuf, 0);
}
DEBUG(10,("read_smb_length: got smb length of %lu\n",