<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4837264360454149618</id><updated>2012-01-10T16:19:39.632-05:00</updated><title type='text'>$ traceroute God</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://roysjosh.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://roysjosh.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Joshua Roys</name><uri>http://www.blogger.com/profile/05809636265443360857</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4837264360454149618.post-3069880061631804471</id><published>2011-05-16T18:51:00.000-04:00</published><updated>2011-05-16T18:51:17.005-04:00</updated><title type='text'>Linux and the Brother HL-2270DW printer: success!</title><content type='html'>This printer was remarkably easy to setup under Linux.&amp;nbsp; It was something of an impulse buy after my inkjet ran out of ink... and after I clicked "Checkout" I thought to check what Google had to say about the support for Linux.&amp;nbsp; There were no great success stories, so I thought I would have to fight with it for a few weeks to get it to a decent state...&amp;nbsp; Surprise!&amp;nbsp; It took only a few hours, of which most were me exploring the device.&lt;br /&gt;&lt;br /&gt;I setup the printer on the network using ethernet (the wireless is nice, if I need it later... but for now it's sitting next to the router, so...) and for sanity I set it to get the same dhcp leased IP address (the lazy man's static).&amp;nbsp; The Printers dialog in Fedora 14 quickly discovered the printer after I opened the Network arrow, which was really cool.&amp;nbsp; I found out, via Wireshark, that it has some kind of webservice broadcast thing as well as a SNMP method of discovery... oh, and netbios.&amp;nbsp; There's probably a few I'm missing...&amp;nbsp; oh yes, dns-sd/avahi and LLMNR... anyway, the network support built-in to this printer really impressed me.&lt;br /&gt;&lt;br /&gt;I actually ended up selecting IPP printers and entering the URI manually rather than choosing the automatically discovered one, which had a URI like: dnssd://Brother%20HL-2270DW%20series._ipp._tcp.local/&amp;nbsp; Entering it manually seemed to give me a few more options and even detected the toner level (well, kind of- I think the "starter" cartridge screws it up... we'll see after I print my way through it).&amp;nbsp; The URI I used was: ipp://$IP/pcl_p1 and the driver I chose was "Generic PCL Laser Printer" with the Duplex option checked.&amp;nbsp; And it's worked perfectly since then!!&amp;nbsp; How awesome is that.&amp;nbsp; I didn't even have to install any of the semi-GPLv2 software from Brother.&lt;br /&gt;&lt;br /&gt;In short, I would recommend this printer to anyone that's looking for a full-featured (black/white and single-function) and yet not way too expensive laser printer.&amp;nbsp; Especially if you can find it on sale for $79.99 like I did :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4837264360454149618-3069880061631804471?l=roysjosh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://roysjosh.blogspot.com/feeds/3069880061631804471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://roysjosh.blogspot.com/2011/05/linux-and-brother-hl-2270dw-printer.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/3069880061631804471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/3069880061631804471'/><link rel='alternate' type='text/html' href='http://roysjosh.blogspot.com/2011/05/linux-and-brother-hl-2270dw-printer.html' title='Linux and the Brother HL-2270DW printer: success!'/><author><name>Joshua Roys</name><uri>http://www.blogger.com/profile/05809636265443360857</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4837264360454149618.post-3016523395875793539</id><published>2011-02-04T16:48:00.003-05:00</published><updated>2011-02-20T20:34:23.751-05:00</updated><title type='text'>update your xbee firmware under linux!</title><content type='html'>I just got a pair of xbee radios from Digi (&lt;a href="http://www.digi.com/xbee/"&gt;http://www.digi.com/xbee/&lt;/a&gt;) last week, as I begin my hobby of embedded electronics, and they're very cool.&amp;nbsp; I already have a ton of ideas that, given time and money, I want to work on.&amp;nbsp; The only thing that bothered me was that there was no firmware update utility for Linux.&amp;nbsp; Well, no more!&amp;nbsp; The datasheet from Digi had the details of how to enter the bootloader and upload firmware to the xbee, and I spent the past few nights learning about serial communication and programming.&amp;nbsp; The result is a small utility that can upload new firmware images to your xbee!&lt;br /&gt;&lt;br /&gt;As of now, there are a couple of caveats (that will all eventually be fixed):&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strike&gt;the device is hard-coded as /dev/ttyUSB0&lt;/strike&gt;&lt;/li&gt;&lt;li&gt;&lt;strike&gt;you can only program an xbee currently in AT mode (you can go to API mode fine, but my utility doesn't speak API yet)&lt;/strike&gt;&lt;/li&gt;&lt;li&gt;need to handle radios in strange states or non-default baud rates, etc. &lt;/li&gt;&lt;/ul&gt;I only have 2 radios to test on, so: FLASH AT YOUR OWN RISK!&amp;nbsp; This works for me, but I'm sure that there will be situations and hardware that this will not work on (for now).&amp;nbsp; That aside, the xbee bootloader seems fairly robust, and when I accidentally re-programmed the same block several hundred times, it was able to recover.&lt;br /&gt;&lt;br /&gt;I'll edit this later after I find a place to put my code...&lt;br /&gt;&lt;b&gt;Edit:&lt;/b&gt; &lt;a href="https://github.com/roysjosh/xbee-comm"&gt;https://github.com/roysjosh/xbee-comm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And now, the text equivalent of a screenshot!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ time { ./xbfwup 2270/ebl_files/XB24-ZB_2270.ebl ; }&lt;br /&gt;Read 100608 byte firmware file (786 blocks).&lt;br /&gt;................................................... 50&lt;br /&gt;.................................................. 100&lt;br /&gt;.................................................. 150&lt;br /&gt;.................................................. 200&lt;br /&gt;.................................................. 250&lt;br /&gt;.................................................. 300&lt;br /&gt;.................................................. 350&lt;br /&gt;.................................................. 400&lt;br /&gt;.................................................. 450&lt;br /&gt;.................................................. 500&lt;br /&gt;.................................................. 550&lt;br /&gt;.................................................. 600&lt;br /&gt;.................................................. 650&lt;br /&gt;.................................................. 700&lt;br /&gt;.................................................. 750&lt;br /&gt;...................................&lt;br /&gt;Programming complete, running uploaded firmware...&lt;br /&gt;&lt;br /&gt;real&amp;nbsp;&amp;nbsp;&amp;nbsp; 0m25.392s&lt;br /&gt;user&amp;nbsp;&amp;nbsp;&amp;nbsp; 0m0.023s&lt;br /&gt;sys &amp;nbsp; &amp;nbsp; 0m0.042s&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4837264360454149618-3016523395875793539?l=roysjosh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://roysjosh.blogspot.com/feeds/3016523395875793539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://roysjosh.blogspot.com/2011/02/update-your-xbee-firmware-under-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/3016523395875793539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/3016523395875793539'/><link rel='alternate' type='text/html' href='http://roysjosh.blogspot.com/2011/02/update-your-xbee-firmware-under-linux.html' title='update your xbee firmware under linux!'/><author><name>Joshua Roys</name><uri>http://www.blogger.com/profile/05809636265443360857</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4837264360454149618.post-6341602095530148221</id><published>2010-11-18T11:26:00.000-05:00</published><updated>2010-11-18T11:26:24.601-05:00</updated><title type='text'>firefox, x509, Subject CN, and subjectAltNames</title><content type='html'>Note to self: firefox will ignore the Subject CN if you have a DNS subjectAltName in your certificate.&amp;nbsp; Sigh.&amp;nbsp; /me revokes and regenerates certificates...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4837264360454149618-6341602095530148221?l=roysjosh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://roysjosh.blogspot.com/feeds/6341602095530148221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://roysjosh.blogspot.com/2010/11/firefox-x509-subject-cn-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/6341602095530148221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/6341602095530148221'/><link rel='alternate' type='text/html' href='http://roysjosh.blogspot.com/2010/11/firefox-x509-subject-cn-and.html' title='firefox, x509, Subject CN, and subjectAltNames'/><author><name>Joshua Roys</name><uri>http://www.blogger.com/profile/05809636265443360857</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4837264360454149618.post-2781837495377769494</id><published>2010-01-28T14:25:00.004-05:00</published><updated>2010-01-28T14:31:17.188-05:00</updated><title type='text'>order is important: memset, thunderbird 3.0.1</title><content type='html'>&lt;div style="font-family: inherit;"&gt;A few minutes ago, I heard that Thunderbird 3.0.1 can cause &lt;a href="https://bugzilla.redhat.com/show_bug.cgi?id=559312"&gt;email corruption&lt;/a&gt;, which alarmed me, because that's what I am currently running.&amp;nbsp; I investigated, and noticed that in the &lt;a href="https://bugzilla.redhat.com/attachment.cgi?id=387369&amp;amp;action=diff"&gt;patch&lt;/a&gt; the root issue was an incorrect usage of &lt;a href="http://www.kernel.org/doc/man-pages/online/pages/man3/memset.3.html"&gt;memset&lt;/a&gt;...&amp;nbsp; Specifically, the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;"size_t n[umber]"&lt;/span&gt; parameter, which indicates how many bytes to write, was swapped with the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;"int c[onstant]"&lt;/span&gt; parameter, indicating the byte to write.&amp;nbsp; Luckily for most of these "backwards" errors, the fill-byte &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;constant&lt;/span&gt; is a 0, so when it is placed in the "number of bytes to write" position, it doesn't matter that there is now a "random" number in the fill-byte &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;constant&lt;/span&gt;.&amp;nbsp; Unfortunately, you then end up using uninitialized (or old) data, like in this case with TB3.&amp;nbsp; A &lt;a href="http://www.google.com/codesearch?q=memset%5C%28.*%2C0%5C%29%3B&amp;amp;hl=en&amp;amp;btnG=Search+Code"&gt;google codesearch&lt;/a&gt; reveals just how often this problem occurs...&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4837264360454149618-2781837495377769494?l=roysjosh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://roysjosh.blogspot.com/feeds/2781837495377769494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://roysjosh.blogspot.com/2010/01/order-is-important-memset-thunderbird.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/2781837495377769494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/2781837495377769494'/><link rel='alternate' type='text/html' href='http://roysjosh.blogspot.com/2010/01/order-is-important-memset-thunderbird.html' title='order is important: memset, thunderbird 3.0.1'/><author><name>Joshua Roys</name><uri>http://www.blogger.com/profile/05809636265443360857</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4837264360454149618.post-8531285526074536363</id><published>2009-10-16T16:21:00.001-04:00</published><updated>2009-11-03T14:15:48.694-05:00</updated><title type='text'>jwhois-4.0 and 100% CPU usage on whois lookups</title><content type='html'>A few months ago I started to notice that every now and then a whois lookup would eat one of my CPUs.  Running whois under strace quickly revealed something interesting:&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ strace whois $FOO&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;...&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3&lt;br /&gt;fcntl(3, F_GETFL)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0x2 (flags O_RDWR)&lt;br /&gt;fcntl(3, F_SETFL, O_RDWR|&lt;b&gt;O_NONBLOCK&lt;/b&gt;)&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0&lt;br /&gt;connect(3, {sa_family=AF_INET, sin_port=htons(43), sin_addr=inet_addr("149.17.192.7")}, 16) = -1 EINPROGRESS (Operation now in progress)&lt;br /&gt;select(1024, NULL, [3], NULL, {75, 0})&amp;nbsp; = 1 (out [3], left {74, 974605})&lt;br /&gt;getsockopt(3, SOL_SOCKET, SO_ERROR, [-1482919303840792576], [4]) = 0&lt;br /&gt;...&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;read(3, 0x7fffeb6b97b0, 1023)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = -1 &lt;b&gt;EAGAIN&lt;/b&gt; (Resource temporarily unavailable)&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;... (repeat the above a lot, varies from run to run) ...&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;read(3, "NOT FOUND\n"..., 1023)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 10&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;read(3, ""..., 1023)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;write(1, "[whois.publicinterestregistry.net"..., 45[whois.publicinterestregistry.net]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;NOT FOUND&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;) = 45&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;exit_group(0)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = ?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And then it would exit.&amp;nbsp; So, for some reason jwhois switched from blocking sockets in v3 to non-blocking in v4.&amp;nbsp; Why?&amp;nbsp; I have no idea.&amp;nbsp; It is, after all, only going to be dealing with one IO operation at a time (non-blocking fds are usually used when you need to poll multiple "things" at the same time).&lt;br /&gt;&lt;br /&gt;Let's find out where this &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;read()&lt;/span&gt; is via &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;gdb&lt;/span&gt;:&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ gdb jwhois&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;...&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(gdb) break getsockopt&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Breakpoint 1 at 0x401c30&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(gdb) run $FOO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Starting program: /usr/bin/jwhois $FOO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;[Querying whois.publicinterestregistry.net]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Breakpoint 1, 0x0000003e2f0df1a0 in getsockopt () from /lib64/libc.so.6&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Current language:&amp;nbsp; auto; currently minimal&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(gdb) clear getsockopt&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Deleted breakpoint 1 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(gdb) break read&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Breakpoint 2 at 0x3e2f0d1470&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(gdb) c&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Continuing.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Breakpoint 2, 0x0000003e2f0d1470 in read () from /lib64/libc.so.6&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(gdb) bt&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#0&amp;nbsp; 0x0000003e2f0d1470 in read () from /lib64/libc.so.6&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#1&amp;nbsp; 0x000000000040c1b0 in read (__nbytes=&lt;value optimized="" out=""&gt;, __buf=&lt;value optimized="" out=""&gt;, __fd=&lt;value optimized="" out=""&gt;)&lt;/value&gt;&lt;/value&gt;&lt;/value&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at /usr/include/bits/unistd.h:45&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#2&amp;nbsp; whois_read (__nbytes=&lt;value optimized="" out=""&gt;, __buf=&lt;value optimized="" out=""&gt;, __fd=&lt;value optimized="" out=""&gt;) at &lt;b&gt;whois.c:127&lt;/b&gt;&lt;/value&gt;&lt;/value&gt;&lt;/value&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#3&amp;nbsp; 0x000000000040c316 in whois_query (wq=0x7fffffffe0d0, text=0x7fffffffe078) at whois.c:84&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#4&amp;nbsp; 0x000000000040bde1 in jwhois_query (wq=0x7fffffffe0d0, text=0x7fffffffe0f8) at jwhois.c:298&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#5&amp;nbsp; 0x000000000040c08e in main (argc=2, argv=0x7fffffffe218) at jwhois.c:181&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(gdb) &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Above, I decided to break on &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getsockopt()&lt;/span&gt; - it was the closest (unique) system call to the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;read()&lt;span style="font-family: inherit;"&gt;&lt;/span&gt;&lt;/span&gt; I wanted to examine.&amp;nbsp; And now we can see that whois.c, line 127 is our culprit.&amp;nbsp; I decided to stick a &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;select()&lt;/span&gt; right above the offending &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;read()&lt;/span&gt; in order to sleep until the socket was ready to be read, instead of busy-wait looping.&amp;nbsp; Here's the patch:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;diff -ur jwhois-4.0.old/src/whois.c jwhois-4.0/src/whois.c&lt;br /&gt;--- jwhois-4.0.old/src/whois.c&amp;nbsp; 2007-06-26 03:00:29.000000000 -0400&lt;br /&gt;+++ jwhois-4.0/src/whois.c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2009-04-29 11:42:56.000000000 -0400&lt;br /&gt;@@ -115,6 +115,7 @@&lt;br /&gt;&amp;nbsp;&amp;nbsp; unsigned int count, start_count;&lt;br /&gt;&amp;nbsp;&amp;nbsp; int ret;&lt;br /&gt;&amp;nbsp;&amp;nbsp; char data[MAXBUFSIZE];&lt;br /&gt;+&amp;nbsp; fd_set rfds;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; count = 0;&lt;br /&gt;&lt;br /&gt;@@ -124,7 +125,15 @@&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; do&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FD_ZERO(&amp;amp;rfds);&lt;br /&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FD_SET(fd, &amp;amp;rfds);&lt;br /&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret = select(fd + 1, &amp;amp;rfds, NULL, NULL, NULL);&lt;br /&gt;+&lt;br /&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ret &amp;lt;= 0)&lt;br /&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return -1;&lt;br /&gt;+&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret = read(fd, data, MAXBUFSIZE-1);&lt;br /&gt;+&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ret &amp;gt;= 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count += ret;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4837264360454149618-8531285526074536363?l=roysjosh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://roysjosh.blogspot.com/feeds/8531285526074536363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://roysjosh.blogspot.com/2009/10/jwhois-40-and-100-cpu-usage-on-whois.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/8531285526074536363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/8531285526074536363'/><link rel='alternate' type='text/html' href='http://roysjosh.blogspot.com/2009/10/jwhois-40-and-100-cpu-usage-on-whois.html' title='jwhois-4.0 and 100% CPU usage on whois lookups'/><author><name>Joshua Roys</name><uri>http://www.blogger.com/profile/05809636265443360857</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4837264360454149618.post-3377236535268787662</id><published>2009-01-16T23:44:00.005-05:00</published><updated>2009-01-17T00:27:53.802-05:00</updated><title type='text'>converting zmud maps to tintin++, and tintin++ with 100k rooms</title><content type='html'>The past few days I've been examining the telnet clients available for linux. There isn't too much to speak of, unfortunately. Many of them aren't under active development. However, I found a new MUD client being developed called &lt;a href="http://www.mudlet.org/"&gt;mudlet&lt;/a&gt; that has the potential to be pretty cool.&lt;br /&gt;&lt;br /&gt;I ended up using &lt;a href="http://tintin.sourceforge.net/"&gt;tintin++&lt;/a&gt;, since it had a rudimentary auto-mapper which looked interesting.  After playing around with it for a while, I wondered if there was a way I could use my &lt;a href="http://www.zuggsoft.com/zmud/zmudinfo.htm"&gt;zmud&lt;/a&gt; maps with tintin++.  I couldn't find my &lt;a href="http://www.wotmud.org/"&gt;wotmud&lt;/a&gt; maps from a long time ago, so I grabbed the ones available from &lt;a href="http://map.wotmad.org/"&gt;map.wotmad.org&lt;/a&gt;.  What follows is the rough steps it took to get them into a format tintin++ understood.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;export zmud MDB data&lt;/li&gt;&lt;li&gt;regex it into something sqlite likes&lt;/li&gt;&lt;li&gt;throw it at sqlite&lt;/li&gt;&lt;li&gt;tweak some data so tintin++ can do more things (like colors) faster/easier&lt;br /&gt;&lt;/li&gt;&lt;li&gt;grab what we need from sqlite and output tintin++'s format&lt;/li&gt;&lt;/ol&gt;What you need:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;mdbtools&lt;/li&gt;&lt;li&gt;sqlite3&lt;/li&gt;&lt;li&gt;DBD::SQLite&lt;/li&gt;&lt;li&gt;&lt;a href="http://roysjosh.googlepages.com/mdb2sqlite.pl"&gt;mdb2sqlite.pl&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://roysjosh.googlepages.com/zmudconv.pl"&gt;zmudconv.pl&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;And of course a zmud mdb file.  And now...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;$ perl ./mdb2sqlite.pl zmud.mdb&lt;br /&gt;...&lt;br /&gt;$ perl ./zmudconv.pl zmud.mdb.sqlite &gt; tintin.map&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;mdb2sqlite.pl throws some errors on MetaTbl and another at the end, but they seem to be harmless.  If you have a suggestion for a fix, I happily accept patches (or just guru-like advice too, I suppose).&lt;br /&gt;&lt;br /&gt;Also, a few more things.  My wotmud map had too many rooms for tintin++, so I wrote a &lt;a href="http://roysjosh.googlepages.com/tintin-100k-rooms.patch"&gt;little patch&lt;/a&gt; that increases the maximum (to 100k) to fix that.  It seems to work for me, but YMMV.&lt;br /&gt;&lt;br /&gt;Finally, for those of you using a distro without tintin++, but with RPM, here's a &lt;a href="http://roysjosh.googlepages.com/tintin.spec"&gt;specfile&lt;/a&gt; for you (that uses the above patch, too).  Just pull the patch into &lt;span style="font-family:courier new;"&gt;SOURCES/&lt;/span&gt; first.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;$ rpmbuild --sign -ba SPECS/tintin.spec&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;* Without the &lt;span style="font-family:courier new;"&gt;--sign&lt;/span&gt; if you don't have rpm set up to use gpg.&lt;br /&gt;&lt;br /&gt;Anyway, happy MUDding!&lt;br /&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4837264360454149618-3377236535268787662?l=roysjosh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://roysjosh.blogspot.com/feeds/3377236535268787662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://roysjosh.blogspot.com/2009/01/converting-zmud-maps-to-tintin-and.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/3377236535268787662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4837264360454149618/posts/default/3377236535268787662'/><link rel='alternate' type='text/html' href='http://roysjosh.blogspot.com/2009/01/converting-zmud-maps-to-tintin-and.html' title='converting zmud maps to tintin++, and tintin++ with 100k rooms'/><author><name>Joshua Roys</name><uri>http://www.blogger.com/profile/05809636265443360857</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry></feed>
