Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/libsmb/libsmb_cache.c

    r414 r745  
    66   Copyright (C) John Terpstra 2000
    77   Copyright (C) Tom Jansen (Ninja ISD) 2002
    8    
     8
    99   This program is free software; you can redistribute it and/or modify
    1010   it under the terms of the GNU General Public License as published by
    1111   the Free Software Foundation; either version 3 of the License, or
    1212   (at your option) any later version.
    13    
     13
    1414   This program is distributed in the hope that it will be useful,
    1515   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1717   GNU General Public License for more details.
    18    
     18
    1919   You should have received a copy of the GNU General Public License
    2020   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2222
    2323#include "includes.h"
     24#include "libsmb/libsmb.h"
    2425#include "libsmbclient.h"
    2526#include "libsmb_internal.h"
     
    3536        char *username;
    3637        SMBCSRV *server;
    37        
     38
    3839        struct smbc_server_cache *next, *prev;
    3940};
     
    5455{
    5556        struct smbc_server_cache * srvcache = NULL;
    56        
     57
    5758        if (!(srvcache = SMB_MALLOC_P(struct smbc_server_cache))) {
    5859                errno = ENOMEM;
     
    6061                return 1;
    6162        }
    62        
     63
    6364        ZERO_STRUCTP(srvcache);
    64        
     65
    6566        srvcache->server = newsrv;
    66        
     67
    6768        srvcache->server_name = SMB_STRDUP(server);
    6869        if (!srvcache->server_name) {
     
    7071                goto failed;
    7172        }
    72        
     73
    7374        srvcache->share_name = SMB_STRDUP(share);
    7475        if (!srvcache->share_name) {
     
    7677                goto failed;
    7778        }
    78        
     79
    7980        srvcache->workgroup = SMB_STRDUP(workgroup);
    8081        if (!srvcache->workgroup) {
     
    8283                goto failed;
    8384        }
    84        
     85
    8586        srvcache->username = SMB_STRDUP(username);
    8687        if (!srvcache->username) {
     
    8889                goto failed;
    8990        }
    90        
     91
    9192        DLIST_ADD(context->internal->server_cache, srvcache);
    9293        return 0;
    93        
     94
    9495failed:
    9596        SAFE_FREE(srvcache->server_name);
     
    9899        SAFE_FREE(srvcache->username);
    99100        SAFE_FREE(srvcache);
    100        
     101
    101102        return 1;
    102103}
     
    117118{
    118119        struct smbc_server_cache * srv = NULL;
    119        
     120
    120121        /* Search the cache lines */
    121122        for (srv = context->internal->server_cache; srv; srv = srv->next) {
    122                
     123
    123124                if (strcmp(server,srv->server_name)  == 0 &&
    124125                    strcmp(workgroup,srv->workgroup) == 0 &&
    125126                    strcmp(user, srv->username)  == 0) {
    126                        
     127
    127128                        /* If the share name matches, we're cool */
    128129                        if (strcmp(share, srv->share_name) == 0) {
    129130                                return srv->server;
    130131                        }
    131                        
     132
    132133                        /*
    133134                         * We only return an empty share name or the attribute
     
    137138                        if (*share == '\0' || strcmp(share, "*IPC$") == 0)
    138139                                continue;
    139                        
     140
    140141                        /*
    141142                         * Never return an empty share name or the attribute
     
    145146                            strcmp(srv->share_name, "*IPC$") == 0)
    146147                                continue;
    147                        
     148
    148149                        /*
    149150                         * If we're only allowing one share per server, then
     
    152153                         */
    153154                        if (smbc_getOptionOneSharePerServer(context)) {
     155                                NTSTATUS status;
    154156                                /*
    155157                                 * The currently connected share name
     
    157159                                 * disconnect from the current share.
    158160                                 */
    159                                 if (! cli_tdis(srv->server->cli)) {
     161                                status = cli_tdis(srv->server->cli);
     162                                if (!NT_STATUS_IS_OK(status)) {
    160163                                        /* Sigh. Couldn't disconnect. */
    161164                                        cli_shutdown(srv->server->cli);
     
    164167                                        continue;
    165168                                }
    166                                
     169
    167170                                /*
    168171                                 * Save the new share name.  We've
     
    179182                                        continue;
    180183                                }
    181                                
    182                                
     184
    183185                                return srv->server;
    184186                        }
    185187                }
    186188        }
    187        
     189
    188190        return NULL;
    189191}
     
    200202{
    201203        struct smbc_server_cache * srv = NULL;
    202        
     204
    203205        for (srv = context->internal->server_cache; srv; srv = srv->next) {
    204206                if (server == srv->server) {
    205                        
     207
    206208                        /* remove this sucker */
    207209                        DLIST_REMOVE(context->internal->server_cache, srv);
     
    229231        struct smbc_server_cache * next;
    230232        int could_not_purge_all = 0;
    231        
     233
    232234        for (srv = context->internal->server_cache,
    233235                     next = (srv ? srv->next :NULL);
     
    235237             srv = next,
    236238                     next = (srv ? srv->next : NULL)) {
    237                
     239
    238240                if (SMBC_remove_unused_server(context, srv->server)) {
    239241                        /* could not be removed */
Note: See TracChangeset for help on using the changeset viewer.