s3-libsmb: update libsmb to use new DLIST macros
authorAndrew Tridgell <tridge@samba.org>
Sat, 6 Feb 2010 01:40:38 +0000 (12:40 +1100)
committerJeremy Allison <jra@samba.org>
Wed, 10 Feb 2010 23:38:48 +0000 (15:38 -0800)
manipulating p->prev directly is not safe any more
(cherry picked from commit 3c650ac1e3e1cdbbabecfddcd29325f20b5dcb48)

source3/libsmb/clidfs.c
source3/libsmb/clientgen.c

index 2a39ee9b58e6d045e12b2f1b7e51a7dc70ee1681..d9e2b87d10c39898cd310ab2c5566c5c5c53cbe7 100644 (file)
@@ -351,7 +351,7 @@ static struct cli_state *cli_cm_find(struct cli_state *cli,
        }
 
        /* Search to the start of the list. */
-       for (p = cli; p; p = p->prev) {
+       for (p = cli; p; p = DLIST_PREV(p)) {
                if (strequal(server, p->desthost) &&
                                strequal(share,p->share)) {
                        return p;
index 1ea8033fc62ab2c11108dcb7b8dfd927c1aac25d..bdc06f1c74e3db2c0fdfa3beb56223f533d8a615 100644 (file)
@@ -693,29 +693,8 @@ void cli_nt_pipes_close(struct cli_state *cli)
  Shutdown a client structure.
 ****************************************************************************/
 
-void cli_shutdown(struct cli_state *cli)
+static void _cli_shutdown(struct cli_state *cli)
 {
-       if (cli->prev == NULL) {
-               /*
-                * Possible head of a DFS list,
-                * shutdown all subsidiary DFS
-                * connections.
-                */
-               struct cli_state *p, *next;
-
-               for (p = cli->next; p; p = next) {
-                       next = p->next;
-                       cli_shutdown(p);
-               }
-       } else {
-               /*
-                * We're a subsidiary connection.
-                * Just remove ourselves from the
-                * DFS list.
-                */
-               DLIST_REMOVE(cli->prev, cli);
-       }
-
        cli_nt_pipes_close(cli);
 
        /*
@@ -755,6 +734,29 @@ void cli_shutdown(struct cli_state *cli)
        TALLOC_FREE(cli);
 }
 
+void cli_shutdown(struct cli_state *cli)
+{
+       struct cli_state *cli_head;
+       DLIST_HEAD(cli, cli_head);
+       if (cli_head == cli) {
+               /*
+                * head of a DFS list, shutdown all subsidiary DFS
+                * connections.
+                */
+               struct cli_state *p, *next;
+
+               for (p = cli_head->next; p; p = next) {
+                       next = p->next;
+                       DLIST_REMOVE(cli_head, p);
+                       _cli_shutdown(p);
+               }
+       } else {
+               DLIST_REMOVE(cli_head, cli);
+       }
+
+       _cli_shutdown(cli);
+}
+
 /****************************************************************************
  Set socket options on a open connection.
 ****************************************************************************/