Fix build for no libcurl
Break out of the hash work loops when a failure is detected instead of dropping into mt disable.
Get rid of the stage thread since all work can be asynchronously added now via hash_push anyway.

Conflicts:
	cgminer.c
Only check for the stratum clean message if we have had a valid message.
Reset the work_restart bool after the scanwork loop in case the driver flushes work synchronously.
--shares should be scaled to diff1 not absolute number of shares
Initialise the stgd lock mutex earlier to prevent dereferences when pool testing occurs before it.

Conflicts:
	cgminer.c
util.c: Decreasing reference count on allocated JSON obects to prevent memory leak
Merge pull request #1 from veox/forward-port

Forward port

Pull in changes in ckolivas/cgminer (up to commit 8fa5ddf, made on Wed Nov 13 11:57:29 2013 +0100).

This is still useful for all functionality not related to SHA256d/Scrypt mining. Obviously, ckolivas/cgminer developers are few bits more familiar with the code base.