smbd: Factor out remove_stale_share_mode_entries
[mat/samba.git] / source3 / locking / locking.c
index 7ac04a45e3fcfc7bf89da49aac43653298d9ed56..b5d4f24f346d7de6fcd9c7035643ef392d465d4e 100644 (file)
@@ -693,6 +693,22 @@ bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx)
        return true;
 }
 
+void remove_stale_share_mode_entries(struct share_mode_data *d)
+{
+       uint32_t i;
+
+       i = 0;
+       while (i < d->num_share_modes) {
+               if (d->share_modes[i].stale) {
+                       struct share_mode_entry *m = d->share_modes;
+                       m[i] = m[d->num_share_modes-1];
+                       d->num_share_modes -= 1;
+               } else {
+                       i += 1;
+               }
+       }
+}
+
 bool set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
                    uid_t uid, uint64_t mid, uint16 op_type)
 {