Commit Diff


commit - 193a9895e31f4ad3a6c86206c7616f5c70f6cfd9
commit + 6bc2f9f7680b060eb40c6f73db70909e987b390f
blob - 1d4c48d0a434e3b3a63efcf8ddc675a2c9e8384b
blob + 1b394d8df372ef32024ea6938f17be6116f6e493
--- transport.go
+++ transport.go
@@ -98,24 +98,11 @@ func (t *transport) send(ctx context.Context, msg Mess
 
 // allocateTag returns a valid tag given a tag pool map. It receives a hint as
 // to where to start the tag search. It returns an error if the allocation is
-// not possible.
+// not possible. The provided map must not contain NOTAG as a key.
 func allocateTag(r *fcallRequest, m map[Tag]*fcallRequest, hint Tag) (Tag, error) {
-	// Tversion can only use NOTAG, so check if we're sending a Tversion.
-	if r.message.Type() == Tversion {
-		if _, exists := m[NOTAG]; exists {
-			return 0, errors.New("NOTAG already in use")
-		}
-		return NOTAG, nil
-	}
-
-	// The tag pool is depleted if all 65536 tags are taken, or if 65535 tags
-	// are taken and NOTAG is available.
-	if len(m) > 0xFFFF {
+	// The tag pool is depleted if 65535 (0xFFFF) tags are taken.
+	if len(m) >= 0xFFFF {
 		return 0, errors.New("tag pool depleted")
-	} else if len(m) == 0xFFFF {
-		if _, exists := m[NOTAG]; !exists {
-			return 0, errors.New("tag pool depleted")
-		}
 	}
 
 	// Look for the first tag that doesn't exist in the map and return it.