Coda with some Issues

May 10th, 2007

I have to say that I love Coda from the guys at Panic. When I first saw the Panic Sans font, I was sold! It's a great tool for keeping moderate-sized web sites up to date if you're a coder, which I am. I mean, I'm not going to give this to my 10-year old daughter - she needs more graphical tools, but for me, this is a great combination of editor/preview/transfer/docs that makes this easier.

But there are some issues I found this morning in doing a major overhaul of my web site at the new host I have. They are not horrible, but just really, really annoying.

The construction tools are great. It's nice that it's all in one tool with a good editor - I've got SubEthaEdit, and like it a lot. I also like the integration with Transmit and have registered that as well. I like the preview, but I wish it would let me set the default fonts like I can with every browser on the market - this would make the preview look more accurate, but I've already sent them something on that.

No, this is about the uploading capabilities of Coda. Basically, I added a CSS style sheet to my web site and that included several graphics files - all of which were placed into one directory for ease of use. The problem was that the uploading of these files didn't respect the directory structure, and so it got "flattened" on upload and made a mess. When I had multiple files in different directories with the same name, the 'latest' one uploaded won. It was a pain to clean up, but now that I know the problems, and until I get a fix from them, I'm liable to use Cyberduck as my uploader as it doesn't make these types of mistakes. I sent them the bug report and we'll see what happens.

Tricky Little Bug

May 9th, 2007

I've been working on a very tricky little bug in a C++ server that has been pestering me for literally months. For the longest time I was convinced that the bug was not in my code, but was, in fact, in the linux kernel and it's handling of socket I/O. It was a compelling argument, and I'm not convinced yet that the kernel isn't making matters worse, but that's for later.

The problem manifested itself as this: one server process on a machine and five machines each with eight calculation processes all talking to the server process on the on 'main' machine. Things would be fine for a long time... then for no apparent reason, one of the calculation machines would have all it's calculation processes (all eight of them) stop communicating with the server process. Since each calculation process (32 in total) each connected to the server process, it seemed very unlikely that one of the calculation processes was effecting the others on the box. The Red Hat engineer agreed with me, as the processes were independent processes, and the only thing shared would be some part of the kernel on that box.

So I did a lot of debugging in the different processes, and it appeared that the problem was finally in the poll() method on the main machine. Everything pointed to this - but I had to back up a bit and then take a hard look at what I was doing and the assumptions I'd made to come to this point. Because I had the feeling that there was no way it was in poll().

What I started looking at was the possibility that it was not the discrete method calls, but that it was in the implied asynchronous functioning of the socket I/O. For example, the data was getting sent from the calculation process to the server process, but it was being done buffered. While it appeared that the write and read operations were completing, the write was really writing to a buffer, and that buffer would be sent when the kernel got around to it. Likewise, the read would be when sufficient data was received to let the kernel pass it to the process. So it might be possible for there to be a disconnect on the writing and reading.

I started looking at the serialization code and ran into the following code for serializing a vector of pointers:

    template< class T >
    void writePointers( Writer & aWriter, tList<T *> & aList )
    {
        aWriter << aList.length();
        tIterator<T *> lIterator = aList.begin();
        while (lIterator.hasNext()) {
            aWriter << *lIterator.getNext();
        }
    }

with a similar method for reading them in on the other end:

    template< class T >
    void readPointers( Reader & aReader, tList<T *> & aList )
    {
        aList.clear();
        int  lLength = 0;
        aReader >> lLength;
        for (int i = 0; i < lLength; i++) {
            T  *lNew = new T;
            aReader >> *lNew;
            aList.addBack(lNew);
        }
    }

so, in theory, we write the size and then each element, and the reader gets that size and then reads in that number. Pretty simple. Problem was, when I looked at it in light of the buffered socket I/O I realized that if the size changed after the writing of the size, then we were in trouble. Also, what about NULLs?

So, the change I made was to tag each element before transferring it. Basically, a handshaking was done within the list process - a code said "Hey, I'm sending a NULL", and that could be delt with by the receiver. Another code would be "Hey, here comes a good one", and a final code said "Hey, no more to send", and with this, I didn't have to send the size first, I could let the size be determined by the contents and not the size before the iterating.

So far, this has gotten rid of these stalls in the calculation processes. It's all about defensive programming. Assuming things really get us all into trouble.

UPDATE: unfortunately, it only took a few days and this bug popped up again. While I am happy with the change I made, it wasn't the core of the issue. Crud. Now I'm back to trying to find out why the communication is getting messed up.

Backfill of Journal

May 8th, 2007

I have been keeping a blog long before it was ever even called that. I called it my online Journal, and this morning I've been spending a little time putting in all the old entries - well... at least a good chunk of them, into MarsEdit and WordPress on my new site. It's just the more main-stream blogging software.

When I get time I'm going to put in all the entries - all the way back to 2001.

UPDATE: I loaded everything back to early Feb 2001 - which is as far back as my database journal goes. The HTML version probably goes back another year, but that's on some backup tape, and if I really get an itching to go back that far, I'll have to get the files off the tar tape and then import them by hand.

Making iSync Work on 10.4.7

June 28th, 2006

I love the Mac OS X Hints hint about getting iSync to work with the Motorola V710 phone without the USB cable. When I first got my phone, I needed the USB cable because I didn't want to manually populate my phone with all my contacts because the keyboard is a mess, etc. So I was very glad to see the hint.

With 10.4.7, Apple has once again undone this wonderful hint and I had to re-apply it. Worried that one day the link might vanish, I decided to add it here, so that I'd always be assured a copy exists that I can find. So here it is.

In a terminal window type:

  cd /Applications/iSync.app/Contents/PlugIns/ApplePhoneConduit.syncdevice/
      Contents/PlugIns/PhoneModelsSync.phoneplugin/Contents/Resources

it's all one line, but it's a biggie, so be careful. Then edit the file: MetaClasses.plist and look for the tag:

	<key>com.motorola.V710</key>

and then the text needs to be:

	<key>InheritsFrom</key><array><string>com.motorola.usb-bt.0x22B8/0x2A62</string></array>

Simply make sure that's the value and save the file. It'll work with iSync now.

Finding Open Socket Processes

June 27th, 2006

OK, this is a pain I've run into several times so I wanted to jot it down here. Basically, if you have a process that is holding on to a socket the easiest way to find out what that is (on linux) is the fuser command:

  fuser -u -v -n tcp 6024

This will get all the processes that have the port 6024 open. No rocket science, but it's nice to have.

People are Funny

June 23rd, 2006

I work with some funny people, and by that I'm not talking only about the laugh-out-loud funny, I'm talking about the what-on-earth-are-you-doing funny. The other day I was talking to someone about some design changes they were interested in making. While I had nothing against the changes, I saw the opportunity to help this person see beyond their initial belief that the design was broken and see how to fix it. Nothing major, and the change might have been really good, but it was a nice to see if this person could see into the problem and see how to fix it.

So, I ask if they see how to fix this. No response. So I explained my idea, and say that it's not necessary, but just a different way of doing the same thing. I'm told it's not the same thing... it's adding another thread. Hmmm... No, it's not, and therein starts my explanation that it's basically the same thing at a high level. Instead I get an argument and insults.

You'd think that someone making as much as these folks would have the common sense that even if they didn't have the intelligence to know the right answer, they'd have the common sense to not insult someone in a professional setting.

I've learned all I need to know about these people. Funny, they probably were trying to enlighten me on the threading issue, but they told me so much more.

Passion

May 10th, 2006

I was reading the web this morning and real a great article at CNET about SGI filing Chapter 11. The guy got it right on target - it's about the passion and belief that you're working for something that will change the world. There's something that reminds me of grad school when you're working on something that you're convinced is going to set the world on fire. It's sad to see SGI not survive. I'll never get rid of my SGI, that's for sure.

Great to be Back

May 8th, 2006

This weekend I finally got to move back into my office after the construction work sent me packing more than two weeks ago. Needless to say, I was very happy about getting things started again and having all the services I use day-to-day back and on-line.

I had moved the cable modem and broadband router to the bedroom and hooked up them in a minimal configuration with the wireless access point in the bedroom - so I've had access to email, etc. but not really access to my office. All covered in plastic and turned off. It was a very profound silence to me.

But it's back and thankfully everything came back. I'm still planning on retiring opus this summer - he's just as old as he can be, and to count on him for CVS and database is just pushing my luck these days. I can get a cheap little machine that will do a much better job for next to nothing.

Anyway... it's great to be back!

Got CKit to 64-bit

February 27th, 2006

I have been having to move many of my applications at work to 64-bit address space because of the memory limitations on the default 32-bit. As a consequence, I've had to port CKit to 64-bit and I have to say, I like the way I've handled the build. Rather than have a multi-pass build from scratch like SQLAPI++, I've decided to have .o and .o64 files and have them built side-by-side. This means that we still use make and the dependency tool and that means rebuilds are faster. Not earth shattering, but nice and clean.

Dual-Head Solaris with Xinerama

February 15th, 2006

OK, I spent some time getting a dual-head system going on a sun box I have at work. It's nothing fancy, but it makes development a little nicer. The trick was in knowing what needed to be done to get things set up right. So here are the steps so that I don't have to figure it out again.

I installed a second XVR-100 video card in the box and did a simple boot -r to get Solaris to see the device. Then I needed to configure the two devices so they were the same. The devices ended up being /dev/fbs/pfb0 and /dev/fbs/pfb1.

  fbconfig -dev pfb0 -res 1280x1024x60
  fbconfig -dev pfb1 -res 1280x1024x60
  fbconfig -dev pfb0 -depth 24
  fbconfig -dev pfb1 -depth 24
  fbconfig -dev pfb0 -fake8 enable
  fbconfig -dev pfb1 -fake8 enable

and you can check the configuration with:

  fbconfig -dev pfb0 -propt

Now you need to change the Xservers file to have both devices and xinerama mode. To do this you need to make sure that /usr/dt/config/Xservers points to /etc/dt/config/Xservers and that there's a like that looks a lot like this in it:

  :0  Local local_uid@console root /usr/openwin/bin/Xsun +xinerama
     -dev /dev/fbs/pfb0 -dev /dev/fbs/pfb1 left -nobanner

...all on one line, of course. Now reboot. The CDE login screen should come up on one display but the mouse should move seamlessly between the two.

Now fix WindowMaker - the trick is knowing that xinit can allow you to completly specify the X server to use. So I made an alias to start WindowMaker like this:

  alias wm 'xinit ~/.xinitrc-wmaker -- /usr/openwin/bin/Xsun
     +xinerama -dev /dev/fbs/pfb0 -dev /dev/fbs/pfb1 left >>&! /dev/null'

with this, I can start it easily and get both heads working as they should.