| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
It is possible to use var chanPool = make(map[string](*chan string))
directly during declaration, even if it's a global variable. There is
no need to call a function to initialize it.
|
| |
|
|
|
|
| |
This also deduplicates some code.
|
|
|
|
| |
This is being done quite a few times, so let's make it a function.
|
| |
|
| |
|
|
|
|
|
|
| |
The WebSocket library closes it for us (which is not behavior that I
like, but fine). Closing it again causes segmentation faults as Body
becomes a null pointer or something like that.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It is way too expensive to query the database every time we need to
check whether a user has chosen a course in a group. Since we can
(hopefully) guarantee that there is only one usable connection for any
given moment and user, we could store this data along with the
connection as a local variable in handleConn, which would be eligible
for garbage collection when handleConn exits. Here we create the
data structures that globally represent courseTypes and courseGroups,
and during the initial stages of handleConn, perform database queries to
populate userCourseGroups with the groups that the user has already
chosen.
Note that the HELLO command handler does similar database queries, and
as per the TODO listed in the comments, should be moved up here for
efficiency. (HELLO also serves as some sort of an initial connection
check; this should probably be replaced with WebSocket's native pings.)
|
| |
|
| |
|
| |
|
|
|
|
| |
Implements: https://todo.sr.ht/~runxiyu/cca/9
|
| |
|
|
|
|
|
|
|
|
|
| |
Because of the poor performance of using NGINX as a reverse proxy, I've
added native TLS in commit 4a1a7af76408e956ebc343bf28960fdd00c00c58.
Serving static files was already supported, but it was expected that
people use a static web server to do so, so we didn't support
a configurable static path. Now since reverse proxy setups are
discouraged, it makes more sense to be better at serving static files.
|
|
|
|
|
| |
It's currently a copy of the student page with a few words changed and
no checkboxes
|
| |
|
| |
|
|
|
|
|
| |
This URL should be configurable in the JS at least, but I'm not sure how
I should be filling out JS templates. I'll leave it hardcoded for now.
|
| |
|
|
|
|
|
|
| |
I would love to serve FastCGI but it is a huge pain to get WebSocket
working, at least with NGINX. I don't think OpenBSD httpd would be
better at this either.
|
| |
|
|
|
|
| |
Just use "psql cca"
|
| |
|
| |
|
|
|
|
|
|
| |
I would have used IPv6, i.e. [::1]:5555, but our school network only has
IPv4 and it'd be easier to keep everything on the same protocol, though
this probably wouldn't matter for standard reverse proxy setups.
|
| |
|
|
|
|
| |
This is useful for testing whether connection collisions work well.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
I used named returns to inspect return values (especially error values)
|
|
|
|
|
|
| |
The entry is deleted from cancelPool if and only if cancelPool's cancel
function for the user is equal to &newCancel. This compare-and-delete
works because of locking.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Cancel occurs in async. When the cancelled function exits, it deletes
the entry in cancelPool, and could replace the new routine's cancel
function, which is of course undesirable. Therefore this commit causes
handleConn to stop deleting from cancelPool entirely.
Note that this introduces a memory leak at the size of
context.CancelFunc per user, because we are never deleting from
cancelPool.
This does not actually solve the race condition documented in
fc911928 where two new connections start sufficiently close to each
other.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When beginning to handle a WebSocket connection, we shall create a new
context, with the request context as its parent. We use the new context
for everything from now on, except for reporting error messages, which
is handled by creating a reportError function in a closure in
makeReportError and passing it along to command-handling functions.
Note that if one user attempts to rapidly launch WebSocket connections,
there might still be a race condition where the old connection hasn't
been completely established yet (i.e. an entry hasn't been added to
cancelPool) and the new connection isn't able to cancel the old
connection. I'm a bit tired to think of a solution now but it could
probably be solved by moving the cancellation registration and
cancelling sooner during the initial handshake.
Note that more parts of the event loop needs to select from ctx.Done
(from newCtx) for this to work reliably.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
The new names are a bit more descriptive in what each do, and I intend
to add an "admin" template in the future.
This has no user-facing effects.
|
| |
|
| |
|
| |
|
| |
|
| |
|