Use nanosleep() instead of sleep() in job thread

sleep() saves/restores the signal mask because nanosleep() might be
interrupted by a signal.  This isn't a problem for the job thread, so just
use nanosleep() directly; for good measure, if that happens, just use
sleep().

This may eventually move to the main thread and then use the epoll timeout.
Use the new caching in freegeoip sample app

This fixes a race condition that would happen between querying SQLite
and adding it to memcache. Now the caching stuff handles all that.
Fix potential memory leak in strbuf

(Found with clang static analyzer)
The critical status aborts the program

But Clang static analyzer does not know that