Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
Fix a bug that when proxy client exit too fast, program will stuck at waiting for startup.
Update build script.
  • Loading branch information
tindy2013 committed Jan 20, 2020
1 parent 7a55d9f commit 7626789
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions scripts/build.alpine.clients.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ gcc ss_local*.o .libs/libshadowsocks-libev.a ../libudns/.libs/libudns.a -o ssr-l
mv ssr-local ../../base/tools/clients/
cd ../..

export ARCH=`uname -m`

if [[ "$ARCH" = "x86_64" ]];then
curl -LO https://github.com/v2ray/v2ray-core/releases/latest/download/v2ray-linux-64.zip
curl -LO https://github.com/joewalnes/websocketd/releases/download/v0.3.1/websocketd-0.3.1-linux_amd64.zip
Expand Down
15 changes: 9 additions & 6 deletions src/processes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,20 @@ bool runProgram(std::string command, std::string runpath, bool wait)
if(retval == FALSE)
return false;

sleep(500); //slow down to prevent some problem
//sleep(500); //slow down to prevent some problem
DWORD ExitCode = STILL_ACTIVE;

WaitForInputIdle(pi.hProcess, 2000);
do
{
retval = GetExitCodeProcess(pi.hProcess, &ExitCode);
if(retval == false)
if(retval == FALSE)
continue;
else if(ExitCode == STILL_ACTIVE)
break;
else
return ExitCode;
}
while(ExitCode != STILL_ACTIVE);
while(true);

AssignProcessToJobObject(job, pi.hProcess);
SetInformationJobObject(job, JobObjectExtendedLimitInformation, &job_limits, sizeof(job_limits));
Expand Down Expand Up @@ -131,8 +134,8 @@ void killByHandle()
#ifdef _WIN32
if(hProc != NULL)
{
TerminateProcess(hProc, 0);
CloseHandle(hProc);
if(TerminateProcess(hProc, 0))
CloseHandle(hProc);
}
#else
if(hProc != 0)
Expand Down

0 comments on commit 7626789

Please sign in to comment.