summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2011-07-28 20:23:30 -0700
committerJeremy Allison <jra@samba.org>2011-07-29 20:37:42 +0200
commit1d4d9194abf3694e2f890744c6f7764088b1c1f3 (patch)
treebd6183f8e875413caae52258fcca68ca803fac9c /source3/smbd
parent9edc1599125fbd3588a22d9a4145666a9c322798 (diff)
downloadsamba-1d4d9194abf3694e2f890744c6f7764088b1c1f3.tar.gz
samba-1d4d9194abf3694e2f890744c6f7764088b1c1f3.tar.bz2
samba-1d4d9194abf3694e2f890744c6f7764088b1c1f3.zip
Secod part of bugfix for bug #8335 - file copy aborts with smb2_validate_message_id: bad message_id
Modify the credit granting algorithm to closer to what I believe Windows does. Split up max_credits into 1/16ths, and then scale the requested credits by how many 16ths have been currently granted. Less than 1/16th == grant all requested (100%), scale down as more have been granted. Never ask for less than 1 if the client asked for at least 1. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Fri Jul 29 20:37:42 CEST 2011 on sn-devel-104
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/smb2_server.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index 11b5ed8bf0..288cc79b54 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -455,9 +455,30 @@ static void smb2_set_operation_credit(struct smbd_server_connection *sconn,
SMB_ASSERT(sconn->smb2.max_credits >= sconn->smb2.credits_granted);
- /* Remember what we gave out. */
- credits_granted = MIN(credits_requested, (sconn->smb2.max_credits -
- sconn->smb2.credits_granted));
+ if (credits_requested) {
+ uint16_t modified_credits_requested;
+ uint32_t multiplier;
+
+ /*
+ * Split up max_credits into 1/16ths, and then scale
+ * the requested credits by how many 16ths have been
+ * currently granted. Less than 1/16th == grant all
+ * requested (100%), scale down as more have been
+ * granted. Never ask for less than 1 as the client
+ * asked for at least 1. JRA.
+ */
+
+ multiplier = 16 - (((sconn->smb2.credits_granted * 16) / sconn->smb2.max_credits) % 16);
+
+ modified_credits_requested = (multiplier * credits_requested) / 16;
+ if (modified_credits_requested == 0) {
+ modified_credits_requested = 1;
+ }
+
+ /* Remember what we gave out. */
+ credits_granted = MIN(modified_credits_requested,
+ (sconn->smb2.max_credits - sconn->smb2.credits_granted));
+ }
if (credits_granted == 0 && sconn->smb2.credits_granted == 0) {
/* First negprot packet, or ensure the client credits can