work queue clean state, avoid busy waiting on foreman

Some fixes for foremen:

- Wait at least one second inside work_queue_wait_internal when no task has returned. This is a temporary fix, added for the case when there are tasks ready, but they cannot be scheduled. Before, we would not wait at all, which caused wq to loop without doing anything useful (other than printing the same debug messages thousand of times per second).

- Do a disconnect on reset. Before, when a master disconnected from a foreman, the state of the foreman was not completely cleaned. Some tasks remained on the queue, and unprocessed messages remained on the links. This confused a new master connecting to the foreman. This pull request fixes this with a "hard reset", which asks the foreman-workers to form the hierarchy again. We may want to revisit this with a more elegant solution.