 
     sync_filesystem: (cb) =>
         @is_active = true
+
+        if @_client_sync_lock # or Math.random() <= .5 # (for testing)
+            winston.debug("sync_filesystem -- hit client sync lock")
+            cb?("cannot sync with filesystem while syncing with clients")
+            return
+        if @_filesystem_sync_lock
+            winston.debug("sync_filesystem -- hit filesystem sync lock")
+            cb?("cannot sync with filesystem; already syncing")
+            return
+
+
         before = @content
         if not @diffsync_fileclient?
             cb?("filesystem sync object (@diffsync_fileclient) no longer defined")
             return
+
+        @_filesystem_sync_lock = true
         @diffsync_fileclient.sync (err) =>
             if err
                 # Example error: 'reset -- checksum mismatch (29089 != 28959)'

            else
                resp = message.success(id:mesg.id)
            socket.write_mesg('json', resp)


    read_from_disk: (socket, mesg) =>
        fs.readFile @path, (err, data) =>

        @write_mesg('diffsync_ready')


# TODO:
class CodeMirrorSession
    constructor: (mesg, cb) ->
        @path = mesg.path
