Posts

Showing posts with the label bugs

gettimeofday() should never be used to measure time

gettimeofday() and time() should only be used to get the current time if the current wall-clock time is actually what you want. They should never be used to measure time or schedule an event X time into the future. What's the problem? gettimeofday() returns the current wall clock time and timezone. time() returns a subset of this info (only whole seconds, and not timezone). Using these functions in order to measure the passage of time (how long an operation took) therefore seems like a no-brainer. After all, in real life you measure by checking your watch before and after the operation. The differences are: 1. Nobody sneaks in and changes your wristwatch when you're not looking You usually aren't running NTP on your wristwatch, so it probably won't jump a second or two (or 15 minutes) in a random direction because it happened to sync up against a proper clock at that point. Good NTP implementations try to not make...

Erlang BGP daemon

I'm writing a BGP daemon in Erlang . It can connect, parse update packets and announce routes. I started up an old Cisco 2620 router and sent route announcement to it until it cried: %SYS-2-MALLOCFAIL: Memory allocation of 65536 bytes failed from 0x8046F3C8, Pool: Processor Free: 79840 Cause: Memory fragmentation Alternate Pool: None Free: 0 Cause: No Alternate pool -Process= "BGP Router", ipl= 0, pid= 84 -Traceback= 804733A4 804754C8 8046F3CC 80851CDC 8081C7D8 80832848 80832F3C 8 %BGP-5-ADJCHANGE: neighbor 172.16.x.x Down No memory Muhahahaha! The program: git clone git://github.com/ThomasHabets/eggpd.git Update later that night I flooded the 2620 again for a few minutes and then disconnected the peer. It stopped responding. Well almost. It answers to ping (17 % packet loss), and my existing telnet session seems to be working somewhat, although there is a delay of about 10 minutes between ...

Solaris installation

In what top scientists are calling "pretty gay", Solaris can't handle disks that used to have non-solaris stuff on them without being wiped first. I thought only the windows installer borked if the partition table looked weird, but no! The installer could not see the disk, and I was dropped into a dtterm where I had to do dd if=/dev/zero of=/dev/dsk/c0t0d0 bs=1048576 and reboot. So... wipe the disk before trying to install Solaris.