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

Revise fifo{,sock} #2671

Merged
merged 1 commit into from
Feb 17, 2019
Merged

Revise fifo{,sock} #2671

merged 1 commit into from
Feb 17, 2019

Conversation

nwf
Copy link
Member

@nwf nwf commented Feb 16, 2019

  • This PR is for the dev branch rather than for master.
  • This PR is compliant with the other contributing guidelines as well (if not, please describe why).
  • I have thoroughly tested my contribution.
  • The code changes are reflected in the documentation at docs/en/*.

@TerryE raises a number of good points on the fifo and fifosock PR (#2650) which was perhaps prematurely committed. This PR is to address those comments.

nwf referenced this pull request Feb 16, 2019
)

* lua_modules/fifo: a generic queue & socket wrapper

One occasionally wants a generic fifo, so here's a plausible
implementation that's reasonably flexible in its usage.

One possible consumer of this is a variant of TerryE's two-level fifo
trick currently in the telnetd example.  Factor that out to fifosock for
more general use.

* lua_examples/telnet: use factored out fifosock

* lua_modules/http: improve implementation

Switch to fifosock for in-order sending and waiting for everything to be
sent before closing.

Fix header callback by moving the invocation of the handler higher

* fifosock: optimistically cork and delay tx

If we just pushed a little bit of data into a fifosock that had idled,
wait a tick (1 ms) before transmitting.  Hopefully, this means that
we let the rest of the system push more data in before we send the first
packet.  But in a high-throughput situation, where we are streaming data
without idling the fifo, there won't be any additional delay and we'll
coalesce during operation as usual.

The fifosocktest mocks up enough of tmr for this to run, but assumes
an arbitrarily slow processor. ;)
Fixes to nodemcu#2650:

- Convert fifosock to returning tables containing ctors
- Improve docs
- Add a missed :on("sent", nil) in the http server
@nwf
Copy link
Member Author

nwf commented Feb 16, 2019

@marcelstoer If @TerryE signs off on these small fixups, can they be scheduled to go before the next drop?

@TerryE
Copy link
Collaborator

TerryE commented Feb 17, 2019

I haven't had the time to dynamic test this, but in general this is an excellent example. No doubt we can refine our coding and implementation styles as LFS etc. evolves.

My only real quibble is that I feel that @nwf Nathaniel is doing himself a disservice by listing me as the principle author, given that the bulk of the implementation is his. He should take the main credit here not me.

@nwf
Copy link
Member Author

nwf commented Feb 17, 2019

@TerryE All I did was copy code from the telnet server example and introduce bugs. ;)

@TerryE TerryE merged commit 1070466 into nodemcu:dev Feb 17, 2019
@marcelstoer marcelstoer added this to the Next release milestone Feb 17, 2019
@nwf nwf deleted the fifosock branch February 18, 2019 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants