Hacker News new | ask | show | jobs
by BugsBunnySan 3705 days ago
Related story time: At university, we ran a local quakeworld server (yes, this was in the stone age XD). And I wanted to write a tool to allow users to control to server. It would listen on a network port and pipe its input into the quakeworld server running as a child subprocess.

Sounds simple enough, right? Disregarding accept(2)ing connections,etc... it's just going to sit in an endless loop, select(2) on the sockets then read what comes in, and write that to the quakeworld server.

To debug this, everytime someone sent some data over the network, it would write a simple message ("blah") into a file on my home drive, called "~/blah" (very sophisticated debugging, I know).

Now, the semantics of select(2), cousin of poll(2), are interesting.

My understanding: select(2) blocks until you can read data from the socket.

Actual behaviour: select(2) blocks until a subsequent read on the socket does not block.

Fun fact: if there's not data available on the socket, read does not block, but returns with an error immediatly.

Result: Over the weekend, the process was spinning in an endless loop, writing 'blah' into a file on the nfs-home drive as quickly as the filesystem allowed. This being a university scale solaris NFS server, that's pretty fast.

End Result: A test file called 'blah', filled with about 800 GB of 'blah'. Good thing the admins where nice people and didn't shoot me when I went to explain the next monday why the home drive was filled with "blah" XD

EDIT: read(2) doesn't actually error on EOF, just returns 0, effect is the same though.

3 comments

> Good thing the admins where nice people and didn't shoot me when I went to explain the next monday why the home drive was filled with "blah" XD

They should be the ones explaining why they don't have disk quotas set up on a shared system.

AFAIR, they had one, which was so flakey they had to disable it all the time.

But yeah, maybe them being somewhat at fault as well helped me out a bit :)

Sounds like a story straight from Unix-Haters Handbook... :).
Read will return 0 when the peer has closed the connection, that's how you detect it. When there is no data, the call will block instead until some data arrives (unless the socket is set to non-block mode).
Hm yeah, it could've been that I disconnected from the server when I went home for the weekend and didn't check for that in the code. It was a long time ago :)
You have QuakeWorld and almost a terabyte in the same story. It seriously managed to write 800 gigs!? How did they have that much storage?
Wikipedia pegs QW as existing around 1996-2000...

https://en.wikipedia.org/wiki/QuakeWorld

Now, 800Gigs sounds like a lot, but I distinctly also recall that time as the era when we ran across 8GB clip issues. It wouldn't be unheard of for drives to actually be 20-60GB in size around this era, maybe larger for the expensive SCSI kind.

Getting 800GB online storage with something like RAID5 or RAID6 would probably take two fully loaded controllers; lets say 10 drives of usable storage across two arrays. (20 drives). That back of the envelope math is about 40GB per drive.

I could see this being an easy case at a LARGE university in some tech centrist area at about the timeframe of 16-18 years ago.