Up to Main Index Up to Journal for March, 2021
JOURNAL FOR SUNDAY 7TH MARCH, 2021
______________________________________________________________________________
SUBJECT: Decision on next WolfMUD release delayed a week
DATE: Sun 7 Mar 18:51:45 GMT 2021
This weekend I said I was going to give my verdict as to whether the new
client communication changes would be included in the next release of WolfMUD
or not. However, I had my first Coronavirus vaccine jab this week and I’ve
been feeling awful ever since. Needless to say, I’ve not been coding much this
week as a result :( I’m therefore going to put off making a decision until
next weekend — once I’ve had a chance to work on the code some more.
I did fix a data race in the new code. Due to a thumping headache and brains
full of cotton wool, It took me hours longer than it should have to find and
sort out.
Way back on the 28th April 2020 I made commit 48d9639 with the subject of
“attr: Don’t modify passed []byte in Player.Write”. It included this code:
// force new slice allocation leaving the originally passed []byte
// untouched, as per the io.Writer documention.
n, err = p.Writer.Write(append(b[:len(b):len(b)], p.buildPrompt()...))
Apart from the spelling mistake in the comment, the code looks reasonable
enough. Until you realise that p.buildPrompt can return a zero length prompt.
If the prompt is of zero length then append will return the original slice.
In the case of the specific problem this fix was intended to solve that is
okay — the original slice remains unchanged.
It becomes a problem with the new communication code. Now the message is
placed on the backlog channel and written later to the client. This means that
when the same message is sent to multiple clients and the prompt is zero
length the same message may appear in multiple channels causing a data race.
Hours to reproduce, hours to debug and hours to test…
I’m also limited as to how many concurrent bots I can launch against the
WolfMUD server for testing. When the server has the race detector enabled it
very quickly consumes my 8Gb of RAM *sigh*.
In other news, I’m just waiting for an item to be restocked before ordering
the new fan and some other parts for my Raspberry Pi 4. I’m also going to add
a Raspberry Pi Pico to the order. I’ve worked with Arduino before and the Pico
looks like a nice board to have a play with. I don’t have a specific project
in mind, although it does look like TinyGo[1] may be adding support for the
Pico…
--
Diddymus
[1] TinyGo — A Go compiler for small places: https://tinygo.org
Up to Main Index Up to Journal for March, 2021