And my blog's back from the dead as well

I was curious if my efforts at fixing some issues with my blogging software [1] were having any affect. So I checked the current server logs and yes, my efforts did have an affect:

Table: Slow death of a blogging engine
Site	Bytes	Hits	Status
Okay (200)	Redirects (300)	Client errors (400)	Server errors (500)
------------------------------
boston.conman.org	3,050,415,479	130,912	99,696	24,403	935	5,876

And some significantly bad affects if that last column is anything to go by (which were the number of requests that the server could not handle due to an internal problem, like my blogging software crashing [2]).

Upon initial investigations, it appeared the problem was lost data—my program was generating output, but it wasn't getting to Apache [3]. That's a buffering problem, and an easily fixed one (I just have to make sure that before my program ends, any data it has buffered is written out). But that didn't fix all the problems.

If anything, the problems were getting worse.

And they seemed to be smack dab in the middle of the actual blogging engine itself—a bit of code that I haven't really touched in six years. Mainly because I didn't want to touch this code. It was ugly. Convoluted. Comments like:

>
```
/*------------------------------------------------------------
; adjustments for partial days. The code is ugly because
; of the reverse hacks I've done without really understanding
; how I actually *implemented* the reverse display of entries.
; Funny how I'm the one writting the code and even *I* don't
; fully understand what I'm doing here. 8-)
;-------------------------------------------------------------*/
```

and

>
```
/*----------------------------------------------------
; I have no idea how long ago I wrote this code, but in
; all that time, I never knew that blog->stentry or
; blog->endentry could become negative. It didn't seem
; to affect the rest of the code, but with the new adtag
; feature, it became a problem. This bit o' code ensures
; that they at least remain positive.
;
; I still don't fully understand what I'm doing here.
;--------------------------------------------------------*/
```

litter the code. And to top it all off, the reverse printing of entries [4] never fully worked right. The more I hacked on the code to get it right, the more I came to realize—

I'm going to have to scrap this mess and **rewrite** it from the ground up (well, not the entire program—just the portion that deals with collecting up the entries and displaying them, which works out to be about half the code).

The code is tricky because of two interlocking features—the first being you can display the entries between two arbitrary dates (or a date and a given number of entries, or on the main page, seven days worth of entries, which isn't necessarily seven consecutive days). The second feature is you can reverse the order of printing.

The original implementation left a lot to be desired. Frankly, it was a bad design, which made it difficult to get these two interlocking features right (not to mention the automatic generation of next and previous links) and something about the last feature I added (adding the entry title to the page title when there's only one entry being displayed) just broke the engine completely (although how, I have no idea).

So late Sunday I started rewriting.

My sleeping schedule was shot anyway due to being sick for the past couple of days [5].

I finished the work (for the most part—I still have to write code to add entries; for the time being I'm adding them manually) sometime this afternoon, much to my surprise.

So much for the boring stuff—now onto fun stuff [6] …

[1] /boston/2007/08/13.2

[2] https://boston.conman.org/about/

[3] http://httpd.apache.org/

[4] https://boston.conman.org/about/technical.html

[5] /boston/2007/08/27.1

[6] /boston/2007/08/27.3-4

Gemini Mention this post

Contact the author