我们正在使用来托管一些内部Git repos。当尝试检出一个存储库时,我们将返回以下错误:
RPC失败;result=22,HTTP = 500 致命:远程终端意外挂起。
在Windows事件查看器中,它记录以下消息:
Exception information:
Exception type: ArithmeticException
Exception message: Overflow or underflow in the arithmetic operation.
Request information:
Request URL: http://localhost:50287/MyRepo.git/git-upload-pack
Request path: /MyRepo.git/git-upload-pack 如果我在本地调试Bonobo,C#中不会抛出任何异常;它来自git进程的外部流。代码使用Process来运行git.exe,如下所示:
using (var process = System.Diagnostics.Process.Start(info))
{
inStream.CopyTo(process.StandardInput.BaseStream);
process.StandardInput.Write('\0');
process.StandardOutput.BaseStream.CopyTo(outStream);
process.WaitForExit();
}传递给git的命令参数是:
上传-包--无状态-rpc D:\PathToRepos\MyRepo
如果我从命令提示符中使用克隆命令运行git.exe,则项目将正确地克隆(并警告templates not found)。
我认为这是C#和git之间的数据类型问题,git正在流到Response.OutputStream。
发布于 2014-01-17 21:57:06
这个问题是由于响应缓冲输出造成的。在发送之前,它将尝试在内存中缓冲整个流,而对于大型存储库,这导致了ArithmeticException。由于Response.Buffer默认为true,所以在发送数据之前必须显式地将其设置为false。显然,数据还必须以块的形式读取和传输。
Response.Buffer = false;
while ((read = process.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length)) > 0)
{
Response.OutputStream.Write(buffer, 0, read);
Response.OutputStream.Flush();
}https://stackoverflow.com/questions/20893126
复制相似问题