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

Improve Jaguar network-disabled. #465

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

floitsch
Copy link
Member

No description provided.

@floitsch floitsch requested a review from kasperl January 16, 2024 06:10
Copy link
Member

@kasperl kasperl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure why I'm not super excited about this change. There are a lot of good stuff in here.

@@ -95,13 +95,13 @@ func RunCmd() *cobra.Command {
"program runs on the current computer instead.\n" +
"\n" +
"The following define flags have a special meaning:\n" +
" '-D jag.disabled': Disable Jaguar for this program.\n" +
" Disables the HTTP server on the device.\n" +
" '-D jag.network-disabled': Disable Jaguar for this program.\n" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the name of this define. Not entirely sure why.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in person: the name isn't great.

  • the network isn't really disabled.
  • it's only affecting Jaguar which disables the http-based endpoint
  • other containers are still free to use the network.

We still need to find a better name.

cmd/jag/commands/run.go Outdated Show resolved Hide resolved
src/network.toit Outdated
@@ -211,14 +211,16 @@ class EndpointHttp implements Endpoint:
// Handle installing containers.
else if path == "/install" and request.method == "PUT":
container-name ::= headers.single HEADER-CONTAINER-NAME
crc32 := int.parse (headers.single HEADER_CRC32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
crc32 := int.parse (headers.single HEADER_CRC32)
crc32 := int.parse (headers.single HEADER-CRC32)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

src/network.toit Outdated
respond-ok writer

// Handle code running.
else if path == "/run" and request.method == "PUT":
crc32 := int.parse (headers.single HEADER_CRC32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
crc32 := int.parse (headers.single HEADER_CRC32)
crc32 := int.parse (headers.single HEADER-CRC32)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

src/jaguar.toit Outdated Show resolved Hide resolved
src/jaguar.toit Outdated
// We start the container from a separate task to allow the server
// to continue operating. This also means that the container running
// isn't covered by the flashing mutex or associated timeout.
task::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to go through some hoops to avoid this for installed containers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be better now.

src/jaguar.toit Outdated
disabled / bool := false
network-free / monitor.Semaphore ::= monitor.Semaphore
container-done / monitor.Semaphore ::= monitor.Semaphore
monitor NetworkManager:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should just be a wrapper around some state and a monitor.Signal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

src/jaguar.toit Outdated
network-is-disabled -> bool:
return network-is-disabled_

start-network-endpoint -> none:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really starting any network endpoints.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to serve taking an endpoint and device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants