jakubgarfield / Bonobo-Git-Server

Bonobo Git Server for Windows is a web application you can install on your IIS and easily manage and connect to your git repositories. Go to homepage for release and more info.
http://bonobogitserver.com
MIT License
1.81k stars 603 forks source link

Fix for #747 'git fetch' sporadically hangs, GitServiceExecutor now asynchronous. #840

Open ijd02 opened 5 years ago

ijd02 commented 5 years ago

Fixed git deadlock bug in GitServiceExecutor. Fault due to stdIn & stdOut buffers in the git.exe filling and blocking further processing. Handling in GitServiceExecutor now asynchronous i.e. Bonobo is continually emptying the buffers even while its sending data to git. Link to initial issue: https://github.com/jakubgarfield/Bonobo-Git-Server/issues/747

willdean commented 5 years ago

Thanks for this. There are a couple of issues I would like to discuss: (Note that I didn't write the original code, so I'm not defensive about it in the slightest!)

But thanks for the PR, anyway, I would definitely like to add this improvement once we're fully happy with it.

ijd02 commented 5 years ago

Hi Will,I wondered about the need for input to be async, once fetch was was working I never went back and tested if synchronous would work. Yes fixing stderr would probably wise. I focused on my immediate issue only. I'm not even sure how stderr is being handled currently. I'm totally new to c# and do little Windows programming so the mixture of old and new styles is inadvertent and may be incorrect. While programming and looking up various API documentation I didn't come across any warning about old/new style. What exactly do you mean by "old-style Process async methods"?I did initially try using OutputDataReceived of the Process class but this wasn't viable due to newlines being mangled i.e. not suitable for raw binary data. I didn't totally follow documentation around the async keyword and related functionality, but I'm highly experience with multi-threaded programming in assembler/C/C++ on a range of operating systems. My understanding is that calling process.StandardOutput.BaseStream.CopyToAsync() will create a new thread to execute the operation and terminate once complete. When this thread has read all available bytes from stdout the next attempt to read byte will block the thread until a new byte becomes available. i.e. the operation never terminates except when the process terminates. The only other way I could think of was to manually create thread and write my own loop that continually calls read on stdout.  

This email is not my primary account so responses may be a little delayed, I was also away over the last few days. Regards, Ian.

On Friday, 5 July 2019, 08:51:10 am UTC, Will Dean <notifications@github.com> wrote:  

Thanks for this. There are a couple of issues I would like to discuss: (Note that I didn't write the original code, so I'm not defensive about it in the slightest!)

But thanks for the PR, anyway, I would definitely like to add this improvement once we're fully happy with it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.