Fixed request id generation when growing requests array is needed. (#86)

* Fixed request id generation when growing requests array is needed.

Previously: incorrect index is used after growing request arrays. At the end of GrowRequests(), arrays would have size `newsize'. But `newsize+1' was used as index into array (which would always fail with IndexOutOfRangeException).

This might have gone undetected because it only manifests itself when there are >= 200 concurrent requests (since arrays start with size 200).

* Remove obsolete xmldoc

Co-authored-by: Dmitry Kalyanov <kalyanov@bars.group>
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
This commit is contained in:
Kalyanov Dmitry 2021-01-26 16:32:27 +03:00 коммит произвёл GitHub
Родитель 401dd4d819
Коммит 3330ff0790
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 4 добавлений и 5 удалений

Просмотреть файл

@ -71,9 +71,9 @@ namespace Mono.WebServer
/// This *MUST* be called with the reqlock held!
/// </summary>
/// <returns>ID to use for a new request.</returns>
/// <param name="curlen">Current length of the allocation tables.</param>
int GrowRequests (ref int curlen)
int GrowRequests ()
{
int curlen = request_ids.Length;
int newsize = curlen + curlen/3;
var new_request_ids = new int [newsize];
var new_requests = new Worker [newsize];
@ -91,8 +91,7 @@ namespace Mono.WebServer
Array.Clear (buffers, 0, buffers.Length);
buffers = new_buffers;
curlen = newsize;
return curlen + 1;
return curlen;
}
/// <summary>
@ -115,7 +114,7 @@ namespace Mono.WebServer
int newid;
if (requests_count >= reqlen)
newid = GrowRequests (ref reqlen);
newid = GrowRequests ();
else
newid = Array.IndexOf (request_ids, 0);