|
|
Tuesday, March 18th, 2008
Handy to know: if you write to stderr from a CGI application (note: when I say "CGI application", I don't actually know what that means -- what I mean is, an application invoked by the http server in response to a GET or POST request and which uses environment variables to get information about the request), the output will go into the http server's log file. At least it will if the http server is Apache.
posted afternoon of March 18th, 2008: Respond ➳ More posts about Programming
|  |
Monday, March 17th, 2008
This evening and yesterday evening, I am (amazingly) starting to see progress towards a clean basement -- much of the sawdust is swept or vacuumed up, my bench is clear of tools and I'm reasonably clear on where the tools are located; I found a couple of tools that I've been wondering where they were; I'm just about ready to start work on the repeatedly delayed fence for the front yard. I've built it in my head enough times now, it should be fairly straightforward getting it into physical existence.
posted evening of March 17th, 2008: Respond ➳ More posts about Carpentry
|  |
Sunday, March 16th, 2008
Last night and this morning, I added another feature to the site, which you might not notice if you don't use my blogroll often; but it's a neat feature so I'm going to tell you about it. The expandable categories in the blogroll will now remember between invocations of the site, whether they are open or not; so if you click on "Blogs | Politics" and then visit Obsidian Wings, next time you come to READIN, the Blogs | Politics links will be open. A little thing but I had been wanting to do it for a few months now. Ideally I would like to have the categories be prefaced by a "+" or "-" character to indicate that there is material beneath them; right now you just have to know that something is there "because it looks like a blogroll", which doesn't seem ideal. I think this is within my Javascript programming abilities, look for it to happen sometime in the next month or two. Also, I improved the formatting of the indentations in the blogroll. I had been doing it with blocks of characters; instead I am now using <span>s with padding-left. This means that long link titles wrap with a hanging indent rather than wrapping to the leftmost column; much prettier.
posted morning of March 16th, 2008: Respond ➳ More posts about The site
|  |
Saturday, March 15th, 2008
For a while my A string has been fraying and in need of replacement -- tonight I put a new string on. Well a couple of things about this: it took a frustratingly long time to get it on and wound properly, a job that should take less than a minute. So I'm frustrated about not being skillful at it. But more, I don't like how long it took me to get around to doing it -- I get intimidated by stuff like this in a really not useful way. Both of these things are also true of sharpening knives, and it drives me crazy that all the knives in my kitchen and most of the blades in my wood shop are not sharp the way they ought to be, and how intimidated I get at the thought of making them sharp. I'm not sure how to approach this.
posted evening of March 15th, 2008: Respond ➳ More posts about Fiddling
|  |
Saturday, March 8th, 2008
Listening in the car to Robyn Hitchcock's April '96 concert in Bilbao, and Sylvia says "I want to hear the one about the street." Cool -- I fast-forwarded to "De Chirico Street". Listened for a minute and then Sylvia says, "There's too much stuff happening on that street."
posted evening of March 8th, 2008: Respond ➳ More posts about Gig Notes
|  |
Friday, February 15th, 2008
The fix is in -- the server is using poll instead of select, a new version has been built and delivered to the client, it can handle loads of clients. Here is the long and short of how you do it (without error-checking, which is dull*): The Old Code
void select_files(int *fds, int nfds)
{
int i, maxid;
fd_set rset, wset;
timeval tval;
FD_ZERO (&rset);
FD_ZERO (&wset);
maxid = 0;
for (i = 0; i < nfds; ++i) {
FD_SET (fds[i], &rset);
FD_SET (fds[i], &wset);
if (fds[i] > maxid) maxid = fds[i];
}
tval.tv_sec = 5;
tval.tv_usec = 0;
select (maxid + 1, &rset, &wset, NULL, &tval);
for (i = 0; i < nfds; ++i) {
if (FD_ISSET(fds[i], &rset))
read_file(fds[i]);
if (FD_ISSET(fds[i], &wset))
write_file(fds[i]);
}
} The New Code
void poll_files(int *fds, int nfds)
{
int i;
pollfd *pfds = (pollfd *)
malloc (nfds * sizeof (pollfd));
for (i = 0; i < nfds; ++i) {
pfds[i].fd = fds[i];
pfds[i].events = POLLIN | POLLOUT;
pfds[i].revents = 0;
}
poll (pfds, nfds, 5000);
for (i = 0; i < nfds; ++i) {
if (pfds[i].revents & POLLIN)
read_file(fds[i]);
if (pfds[i].revents & POLLOUT)
write_file(fds[i]);
}
}
In order to take advantage of the newly accessible file descriptors above 1024, you will need to add these lines to your /etc/security/limits.conf file:
(username) soft nofile 1024
(username) hard nofile 4096
I chose 1024 for the soft limit since most apps are not interested in the high number of files, and 4096 for the hard limit because I read on some message boards that performance will degrade above that number. Feel free to choose other values. You then need to make the following calls from your code (or call ulimit from the script that starts your application):
struct rlimit nofile;
if (getrlimit (RLIMIT_NOFILE, &nofile) != 0) {
fprintf (stderr, "Could not get NOFILE");
exit (1);
}
nofile.rlim_cur = 4096;
if (setrlimit (RLIMIT_NOFILE, &nofile) != 0) {
fprintf (stderr, "Could not set NOFILE");
exit (1);
}
 *If you're interested in the error-checking code, drop me a line -- I just don't feel like typing it out right now.
posted afternoon of February 15th, 2008: Respond ➳ More posts about Programming Projects
|  |
Wednesday, February 13th, 2008
Here's a neat trick: let's say you forgot to close a code block somewhere in a large C source file, and you can't figure out where, and the compiler is not helping you. Try putting a } character at the very end of the file, placing the cursor on it, and presing the % key -- vim will jump to the most recent { which was not matched by a }. (Note: this will not work if you have unmatched {'s inside conditional compilation blocks, which is generally a bad habit anyway.)
posted afternoon of February 13th, 2008: Respond
|  |
|
A good thing to keep in mind when you are trying to write a TCP server that will support thousands of simultaneous connections: the default ulimit for maximum number of open files on a Linux system appears to be 1024. A further thing to keep in mind once you figure out how to adjust that upwards: there is a reason the default maximum is 1024! See, if you use select() to multiplex your I/O (like I do), you will be passing structures of type fd_set around. These structures can only deal with file descriptors less than or equal to 1023. Try and set bit 1024, and you will break your program. But fear not! There is a solution; that solution is to use poll() instead of select(); apparently poll() is the new standard. First I ever heard of it! Switching from one to the other seems like it's not too hard, though I've just now started.
posted afternoon of February 13th, 2008: Respond
|  |
Friday, February first, 2008
The two shows I downloaded last night are indeed great music; I am tentatively liking the 1996 show better than the 2008 show, which I have however not yet listened to all of.** If anyone would like a link to the 96* show files, drop me a line. Here is the setlist:
- DeChirico Street (from Moss Elixir)
- Lysander (from Perspex Island)
- Balloon Man (from Globe of Frogs)
- Devil's Radio (from Moss Elixir)
- Chinese Bones (from Globe of Frogs)
- My Wife & My Dead Wife (from fegMania!)
- Beautiful Girl (from Eye)
- Glass Hotel (from Eye)
- I Something You (from Storefront Hitchcock)
- You & Oblivion (from Moss Elixir)
- Queen Of Eyes (from Underwater Moonlight)
- Man With A Woman's Shadow (from Moss Elixir)
- Kingdom Of Love (from Underwater Moonlight)
- Serpent At The Gates of Wisdom (from Respect)
- Heliotrope (from Moss Elixir)
- I Am Not Me (from Moss Elixir)
- Only The Stones Remain (by the Soft Boys, I think only released as a single)
 *Not that there are 96 of them, I mean they're from that year. **After listening to more: Yes, the 96 gig is the better -- It actually adds something to the music over what is published on the albums, where the 2008 show is beautiful but not in a much different or superior way from I Often Dream of Trains.
posted evening of February first, 2008: Respond ➳ More posts about Writing Projects
|  |
Thursday, January 31st, 2008
Haven't downloaded any Robyn concerts for a while now; but two new tapes became available today. One is of his gig the day before yesterday at Queen Elizabeth Hall in London; as soon as I read about it this morning I started fervently wishing for a tape of the show. And whaddaya know, half an hour later or so I get e-mail informing me of its availability. Quick on the heels of that message came another one, about a show from April '96 in Bilbao. Looking forward to listening to both. Another opportunity for listening to Hitchcock: He'll be on Jools Holland's BBC show tomorrow night. Apparently I will be able to watch it on Fuse, though I'm not completely sure how that works yet.
posted evening of January 31st, 2008: Respond ➳ More posts about Robyn Hitchcock -- gig notes
| Previous posts about Projects Archives  | |
|
Drop me a line! or, sign my Guestbook. • Check out Ellen's writing at Patch.com.
| |