smbd: Factor out remove_stale_share_mode_entries
authorVolker Lendecke <vl@samba.org>
Mon, 2 Sep 2013 11:37:57 +0000 (11:37 +0000)
committerMichael Adam <obnox@samba.org>
Tue, 15 Oct 2013 21:46:11 +0000 (23:46 +0200)
Will be used in the next commit

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/locking/locking.c
source3/locking/proto.h
source3/locking/share_mode_lock.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)
 {
index f6ae462bac608e70179aaf40afdf84ff26f4b2f6..2c9654ce28b8a8528c818aa4b7a88b6721bfb1e1 100644 (file)
@@ -176,6 +176,7 @@ bool is_valid_share_mode_entry(const struct share_mode_entry *e);
 bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx);
 bool set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
                    uid_t uid, uint64_t mid, uint16 op_type);
+void remove_stale_share_mode_entries(struct share_mode_data *d);
 bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
 bool mark_share_mode_disconnected(struct share_mode_lock *lck,
                                  struct files_struct *fsp);
index 342f9108d6a7a9e5ff922f1018ee915b9d5a2d24..5d7a08ca4bf018232aba3a6f41dcc08967afd0f1 100644 (file)
@@ -171,26 +171,13 @@ static TDB_DATA unparse_share_modes(struct share_mode_data *d)
 {
        DATA_BLOB blob;
        enum ndr_err_code ndr_err;
-       uint32_t i;
 
        if (DEBUGLEVEL >= 10) {
                DEBUG(10, ("unparse_share_modes:\n"));
                NDR_PRINT_DEBUG(share_mode_data, d);
        }
 
-       i = 0;
-       while (i < d->num_share_modes) {
-               if (d->share_modes[i].stale) {
-                       /*
-                        * Remove the stale entries before storing
-                        */
-                       struct share_mode_entry *m = d->share_modes;
-                       m[i] = m[d->num_share_modes-1];
-                       d->num_share_modes -= 1;
-               } else {
-                       i += 1;
-               }
-       }
+       remove_stale_share_mode_entries(d);
 
        if (d->num_share_modes == 0) {
                DEBUG(10, ("No used share mode found\n"));