The curious case of slow downloads
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.<p>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.<p>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).<p>Now, the semantics of select(2), cousin of poll(2), are interesting.<p>My understanding: select(2) blocks until you can read data from the socket.<p>Actual behaviour: select(2) blocks until a subsequent read on the socket does not block.<p>Fun fact: if there's not data available on the socket, read does not block, but returns with an error immediatly.<p>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.<p>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<p>EDIT: read(2) doesn't actually error on EOF, just returns 0, effect is the same though.