date: 2003-05-29
description: TRServ getting more awesome, old archives, TRServ bug
lj-entry-id: 283,169

TRServ getting more awesome, old archives, TRServ bug - 2003-05-29 - Entry 336 - TOGoS's Journal

I just realized that slashdot is really weird.

phbbbbbbbbbbttttttt. After I said that I went to slashdot and it was all weird (red headlines (in light mode!)) and a link to email daddypants. This is like when I got to world '9' of SMB Lost Levels.

Anyway, I've spent last night making TRServ more awesome. I need to work on it a little more, and write documentation.

Earlier (about 6:30, maybe? It's 7:45 as I write this) a stupid yellow plane flew by a few times. That was weird. Oh, and as I went looking for my old doom levels on one of my old apps CDs (I found them) I ran across a bunch of random documents and started reading those...

I have just run across all the old slashdot stories that I saved. I can't remember why I saved them.

And I re-researched the Bert/Bin Laden thing. It's weird.

Well, I slept for a few hours, there. After we came back from grocery shopping at about 13:something I went to bed and fell asleep. Dreams:

Most of it seemed to be based around this doom level... It was supposedly some fancy new doom add-on. Ia was a really big rectangular room, and it had a big waterfall (or maybe more than one) in front of one of the walls. And it had dolphins swimming through it. Unless you looked at it from the other side. Then they looked like sharks. And there were monsters all over the room, and you could fly around.

Arrr.. Just went and playeyed balabeo2 and forest2.wads :-).

Anyway, also in my dream, we always gave Fizz a ride home. One day, we looked out the window as we were going home and we saw Fizz out there. We waved at him, I think. Then I realized that that was weird because I had thought he was sitting next to me in the car. He gave kind of a worried look. Then I looked at him and it wasn't Fizz. It was like Ryan Grady or someone. For some reason I wanted to punch him.

I remember there was one dream I had involving a little red glider thing that supposedly you could ride in. I spent the whole dream trying to make new wheels for it, since the old ones had broken off. I was thinking how great it would be if I gould get in and fly around.

And there was one dream in which I was heading over to Doudna to go to my new Math class (Calc 3, I guess :-P).

There was this Doom level that everyone thought was really cool because of the way this guy made it seem like there was a tunnel going through the air. There was this round white building (resembled something natural like a shell more than a building) that looked like this from the side:

    __________________
  _/ _  _  _  _  _    \_
 /  |_||_||_||_||_|     \
|      _______           |
|_____|       |__________|

See how it has an over-under place, there in the middle? So I went looking at it and saw how he did it. He did it like I make bridges (actually, that still doesn't explain the windows, but I overlooked that in the dream).

I went inside and started going around. To the right (according to the picture) I went. There was this big building like maybe one of the dorms in Platteville. It was really dark, and I couldn't see anything. I went in some room and then came out and tought I'd try to poen my eyes more, and then I could see fine. I thought it was like a deathmatch Doom game, though (although I wasn't quite sure. I thought it might be real), so when this girl walked by me I pulled out a machine gun and scared her by shooting the wall next to her. But I think that got the po-pos mad at me and they started chasing me around. I think I was managing to get away from them.

Perhaps this should go in tomorrow's entry, since it is now the 30th of may (about 3:15). Nah. Anyway, after working for a while, I finally found where this bug was in TRServer. See, when I opened a page in the web browser, it would usually load one of the images, but not load the next one. Right away I found that this only happened in multi-threaded mode, so it was a thread problem. I actually had a hunch that it was because threads were closing each other's streams, but it took me a while to find out where the problem was...

Old, buggy code (this is in ThreadedServer#run):

t = Thread.new(sock) do |sock|
  begin
    @request_handler.handle_request sock
  rescue
    debug "ThreadedServer: Handler error: #{$!}\n"
    debug $@.join("  \n"), "\n\n"
  ensure
   sock.close unless sock.closed?
   @ntlock.lock
   @request_handling_threads.delete Thread.current
   @ntlock.unlock
  end
end

New, fixed code:

t = Thread.new(sock) do |tsock|
  begin
    @request_handler.handle_request sock
  rescue
    debug "ThreadedServer: Handler error: #{$!}\n"
    debug $@.join("  \n"), "\n\n"
  ensure
   if tsock.respond_to? :close
     tsock.close unless tsock.closed?
   end
   @ntlock.lock
   @request_handling_threads.delete Thread.current
   @ntlock.unlock
  end
end

I knew I should have been more careful when I first wrote that ;-)