[patch] fix libsmb/smbclient behaviour on server restart
drze at missioncriticallinux.com
drze at missioncriticallinux.com
Wed Jul 11 01:15:38 GMT 2001
Trying this again.. this time with diff inlined.
Against 2.2.0 --
Without this patch, smbclient would:
- die on server restart
- send wrong smb messages (and hang) after server restart
-Adrian
--------------------------------------
diff -ruN samba-2.2.0/source/client/client.c
samba-2.2.0-drze/source/client/client.c--- samba-2.2.0/source/client/client.c Sun Apr 15 13:40:11 2001
+++ samba-2.2.0-drze/source/client/client.c Tue Jul 10 13:45:46 2001
@@ -1829,8 +1829,8 @@
session keepalives and then drop them here.
*/
if (FD_ISSET(cli->fd,&fds)) {
-
receive_smb(cli->fd,cli->inbuf,0);
-
goto again;
+
if (receive_smb(cli->fd,cli->inbuf,0))
+
goto again;
}
cli_chkpath(cli, "\\");
@@ -1954,6 +1954,8 @@
}
}
+
pwd_set_cleartext(&c->pwd, password);
+
if (!cli_session_setup(c, username,
password, strlen(password),
password, strlen(password),
@@ -2207,6 +2209,8 @@
pstring term_code;
pstring new_name_resolve_order;
char *p;
+
+
signal(SIGPIPE, SIG_IGN);
#ifdef KANJI
pstrcpy(term_code, KANJI);
diff -ruN samba-2.2.0/source/libsmb/clientgen.c
samba-2.2.0-drze/source/libsmb/clientgen.c
--- samba-2.2.0/source/libsmb/clientgen.c Thu Dec 14 15:40:01 2000
+++ samba-2.2.0-drze/source/libsmb/clientgen.c Tue Jul 10 14:27:52 2001
@@ -72,26 +72,38 @@
size_t nwritten=0;
ssize_t ret;
BOOL reestablished=False;
+
char *outbuf = cli->outbuf;
+
size_t bufsize;
len = smb_len(cli->outbuf) + 4;
while (nwritten < len) {
-
ret = write_socket(cli->fd,cli->outbuf+nwritten,len - nwritten);
+
ret = write_socket(cli->fd,outbuf+nwritten,len - nwritten);
if (ret <= 0 && errno == EPIPE && !reestablished) {
+
bufsize = sizeof(char) * cli->bufsize;
+
outbuf = (char*)malloc(bufsize);
+
memcpy(outbuf, cli->outbuf, bufsize);
+
if (cli_reestablish_connection(cli)) {
reestablished = True;
nwritten=0;
continue;
}
+
+
free(outbuf);
}
if (ret <= 0) {
DEBUG(0,("Error writing %d bytes to client. %d\n",
(int)len,(int)ret));
+
return False;
}
nwritten += ret;
}
-
+
+
if(reestablished)
+
free(outbuf);
+
return True;
}
More information about the samba-technical
mailing list