Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 4 #65

Merged
merged 7 commits into from
Jul 15, 2021
Merged

Fix issue 4 #65

merged 7 commits into from
Jul 15, 2021

Conversation

cuteant
Copy link
Owner

@cuteant cuteant commented Jul 1, 2021

Fix #4

@cuteant cuteant marked this pull request as draft July 1, 2021 18:55
@yyjdelete
Copy link
Collaborator

yyjdelete commented Jul 2, 2021

@cuteant
By the way, can you check the implement for LoopExecutor.TaskDelay(int) is right? First notice this in #37 (comment).

protected override void TaskDelay(int millisecondsTimeout)
{
_ = _timerHandle.Start(millisecondsTimeout, 0);
}

It's only used here, and I think it required to be sync blocked here like the base class does , but the override in LoopExecutor don't look like an sync wait(Not sure whether it will actual affact anything or not)

[MethodImpl(MethodImplOptions.NoInlining)]
private bool ConfirmShutdownSlow()
{
if (!InEventLoop) { ThrowHelper.ThrowInvalidOperationException_Must_be_invoked_from_an_event_loop(); }
CancelScheduledTasks();
if (0ul >= (ulong)_gracefulShutdownStartTime)
{
_gracefulShutdownStartTime = GetTimeFromStart();
}
if (RunAllTasks() || RunShutdownHooks())
{
if (IsShutdown)
{
// Executor shut down - no new tasks anymore.
return true;
}
// There were tasks in the queue. Wait a little bit more until no tasks are queued for the quiet period or
// terminate if the quiet period is 0.
// See https://github.com/netty/netty/issues/4241
if (0ul >= (ulong)Volatile.Read(ref v_gracefulShutdownQuietPeriod))
{
return true;
}
_taskQueue.TryEnqueue(WakeupTask);
return false;
}
long nanoTime = GetTimeFromStart();
if (IsShutdown || (nanoTime - _gracefulShutdownStartTime > Volatile.Read(ref v_gracefulShutdownTimeout)))
{
return true;
}
if (nanoTime - _lastExecutionTime <= Volatile.Read(ref v_gracefulShutdownQuietPeriod))
{
// Check if any tasks were added to the queue every 100ms.
// TODO: Change the behavior of takeTask() so that it returns on timeout.
_taskQueue.TryEnqueue(WakeupTask);
TaskDelay(100);
return false;
}
// No tasks were added for last quiet period - hopefully safe to shut down.
// (Hopefully because we really cannot make a guarantee that there will be no execute() calls by a user.)
return true;
}

protected virtual void TaskDelay(int millisecondsTimeout)
{
Thread.Sleep(millisecondsTimeout);
}

…and seems obsoleted and no longer work on net5.0+ubuntu20.04

Generated with
```
openssl genrsa -out ssl.key 2048
openssl req -new -x509 -key ssl.key -out dotnetty.com.cer -days 3650 -subj /CN=dotnetty.com
openssl req -new -x509 -key ssl.key -out contoso.com.cer -days 3650 -subj /CN=contoso.com
openssl pkcs12 -export -out dotnetty.com.pfx -inkey ssl.key -in dotnetty.com.cer
openssl pkcs12 -export -out contoso.com.pfx -inkey ssl.key -in contoso.com.cer
```
password="password"
@cuteant
Copy link
Owner Author

cuteant commented Jul 2, 2021

@yyjdelete 我想了下,真是有问题,LoopExecutor中实现的 TaskDelay 的调用分两种情况

  1. 在 Run 方法中执行,这儿逻辑没问题
    protected override void Run()
  2. 在 CleanupAndTerminate 方法中执行,这儿就出问题了,因为这时候 loop已经关闭了
    CleanupAndTerminate(false);

@cuteant cuteant closed this Jul 3, 2021
@cuteant cuteant reopened this Jul 3, 2021
@cuteant
Copy link
Owner Author

cuteant commented Jul 3, 2021

上面表述不准确,实际上 LoopExecutor调用CleanupAndTerminate不应对任务进行处理,要稍微修改下DoShutdown这个方法

cuteant and others added 3 commits July 11, 2021 18:11
    - Add AbstractScheduledEventExecutor::EnusreWakingUp
    - Remove SingleThreadEventExecutor::TaskDelay

* TlsHandler: Replace BatchingPendingWriteQueue with SslHandlerCoalescingBufferQueue
@cuteant cuteant force-pushed the fix-issue-4 branch 2 times, most recently from 0fa437d to da7a29a Compare July 11, 2021 16:51
@cuteant cuteant force-pushed the fix-issue-4 branch 2 times, most recently from 062437c to 46eb327 Compare July 14, 2021 16:52
* Fix MediationStream::ReadFromInput

* ignore some exceptions in TlsHandler::HandleUnwrapThrowable
@cuteant cuteant marked this pull request as ready for review July 15, 2021 17:29
@cuteant cuteant merged commit 9f31f09 into main Jul 15, 2021
@cuteant cuteant deleted the fix-issue-4 branch July 15, 2021 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Libuv + Tls + Browser
2 participants