Added Pthread Locks To HTTP Writes

Replaced the "write_in_progress" flag in the HTTP write with an
actual pthread mutex.