Branch: Tag:

2016-05-17

2016-05-17 14:53:55 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Filesystem.Monitor: Potential fix for [bug 7684 (#7684)].

Avoid recursive mutex locks from destroy() by only locking
on explicit destruct().

212:    //!    //! @param dying    //! Indicates that the @[Monitor] is being destructed. +  //! It is the destruction cause value offset by one.    protected void unregister_path(int|void dying)    { -  if (dying) { -  // We are going away permanently, so remove ourselves from -  // from the monitor_queue. -  MON_WERR("Unregistering %O from polling.\n", path); +  if (dying == 1) { +  // We are going away permanently due to explicit destruct(), +  // so remove ourselves from from the monitor_queue.    mixed key = monitor_mutex->lock(); -  +  MON_WERR("Unregistering %O from polling.\n", path);    monitor_queue->remove(this);    }    }
740:    return 0;    }    -  protected void destroy() +  protected void destroy(int cause)    { -  unregister_path(1); +  // NB: Cause #0 == DESTRUCT_EXPLICIT. +  // Any other cause and unregistering is irrelevant. +  unregister_path(1 + cause);    }   }