-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate linenoise package with web server
In the previous version of console implementation, we tried to integrate tiny-web-server to enable the ability of processing commands from web requests. As the result, the package linenoise which is responsible for command-line auto-complete needs to be disabled during the running time of tiny-web-server. Because the `line_edit()` function in linenoise.c doesn't have the ability to handle web requests correctly. When we start the web server, we use `cmd_select` in console.c and use `select` system call to monitor web socket file descriptor and stdin_fd at the same time, however, this ability should present in the `line_edit` function in linenoise.c so we can process commands from command-line and from web requests at the same time. When we start the web server, we use `cmd_select` in console.c and use `select` function to monitor web socket file descriptor and stdin_fd at the same time. I re-design the control flow of web request and command-line input by implement the hook function `web_select()`, which use the function `select()` to monitor both input file descriptor and web file descriptor and modify `line_edit()` to use `web_select()` so we can process command-line input as normal. One may wonder why don't we simply modify the function `line_edt()`, the reason is that linenoise is an upstream package so we only want to do the miminal changes to this package. Change change change change change change
- Loading branch information
Showing
4 changed files
with
55 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters