Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem were solved in this pull request?
Issue Number: close #281
Problem: 在
cli
模式使用ctrl+c
后始终显示miniob >
无法退出。What is changed and how it works?
问题原因
cli
模式下signal_handler
可以正常接收signal
并关闭服务。但由于信号处理完成后返回中断点继续执行,导致重新回到
read_command
函数无限循环直到获取到非空命令。解决方法
移除
read_command
函数,如果命令为空,返回状态EMPTY_CMD
。在
server.cpp
调用处判断如果出现空命令,则重新执行read_event
。这样可以利用到
Server
中的started_
来判断服务是否已经关停,再按回车就会退出。Other information
ctrl+c
后必须再按回车才会结束readline
的阻塞状态,然后才会退出。这会导致接收到信号并且系统执行
shutdown
后可以再执行一条语句。(本pr未解决,不知道是否需要处理这种情况)