18 Sep 2004 elanthis   » (Journeyer)

Network Code == PITA

The Telnet Proxy for mudmagic.com is just about finished. We had some problems for the last week or so. I added a feature to track the number of connections from each host (to be able to limit them), and the linked list code had a bug that caused an infinite loop. Only, despite expecting that code to be the part causing the lockups, having debugger output to back up that hunch, and having looked directly at the line of code causing the problem some 50 times, I just couldn't see the problem. One of those instances where you just need someone other than the person who wrote the code to look it over, I guess. I rewrote the linked list code from scratch to get it working, and only afterwards did I finally see what the old code was doing wrong. Namely, when unlinking an entry, it did (last->next = current) instead of (last->next = current->next) like it was supposed to. Drat.

Anyways, I've also, having had this learning experience in writing networked code, decided to gut and rewrite the network code in AweMUD. The basics are in place and working great, although there are some more features I need to re-enable and some API cleanups to work out.

The biggest motivator to wanting the new code is an old bug in AweMUD where the connection tracking code had a bug (do you see a pattern here?) in which it would lose count and end up deciding that there were many connections from a particular host that wasn't connected at all.

The second biggest motivator is my need for perfection in my code, and the fact that the network code in AweMUD was crap. And incorrect in places. (Like wanting to call send() on a socket even though it might block.)

[#] Comments

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!