Changeset 745 for trunk/server/source3/libsmb/libsmb_cache.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/libsmb/libsmb_cache.c
r414 r745 6 6 Copyright (C) John Terpstra 2000 7 7 Copyright (C) Tom Jansen (Ninja ISD) 2002 8 8 9 9 This program is free software; you can redistribute it and/or modify 10 10 it under the terms of the GNU General Public License as published by 11 11 the Free Software Foundation; either version 3 of the License, or 12 12 (at your option) any later version. 13 13 14 14 This program is distributed in the hope that it will be useful, 15 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 17 GNU General Public License for more details. 18 18 19 19 You should have received a copy of the GNU General Public License 20 20 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 22 22 23 23 #include "includes.h" 24 #include "libsmb/libsmb.h" 24 25 #include "libsmbclient.h" 25 26 #include "libsmb_internal.h" … … 35 36 char *username; 36 37 SMBCSRV *server; 37 38 38 39 struct smbc_server_cache *next, *prev; 39 40 }; … … 54 55 { 55 56 struct smbc_server_cache * srvcache = NULL; 56 57 57 58 if (!(srvcache = SMB_MALLOC_P(struct smbc_server_cache))) { 58 59 errno = ENOMEM; … … 60 61 return 1; 61 62 } 62 63 63 64 ZERO_STRUCTP(srvcache); 64 65 65 66 srvcache->server = newsrv; 66 67 67 68 srvcache->server_name = SMB_STRDUP(server); 68 69 if (!srvcache->server_name) { … … 70 71 goto failed; 71 72 } 72 73 73 74 srvcache->share_name = SMB_STRDUP(share); 74 75 if (!srvcache->share_name) { … … 76 77 goto failed; 77 78 } 78 79 79 80 srvcache->workgroup = SMB_STRDUP(workgroup); 80 81 if (!srvcache->workgroup) { … … 82 83 goto failed; 83 84 } 84 85 85 86 srvcache->username = SMB_STRDUP(username); 86 87 if (!srvcache->username) { … … 88 89 goto failed; 89 90 } 90 91 91 92 DLIST_ADD(context->internal->server_cache, srvcache); 92 93 return 0; 93 94 94 95 failed: 95 96 SAFE_FREE(srvcache->server_name); … … 98 99 SAFE_FREE(srvcache->username); 99 100 SAFE_FREE(srvcache); 100 101 101 102 return 1; 102 103 } … … 117 118 { 118 119 struct smbc_server_cache * srv = NULL; 119 120 120 121 /* Search the cache lines */ 121 122 for (srv = context->internal->server_cache; srv; srv = srv->next) { 122 123 123 124 if (strcmp(server,srv->server_name) == 0 && 124 125 strcmp(workgroup,srv->workgroup) == 0 && 125 126 strcmp(user, srv->username) == 0) { 126 127 127 128 /* If the share name matches, we're cool */ 128 129 if (strcmp(share, srv->share_name) == 0) { 129 130 return srv->server; 130 131 } 131 132 132 133 /* 133 134 * We only return an empty share name or the attribute … … 137 138 if (*share == '\0' || strcmp(share, "*IPC$") == 0) 138 139 continue; 139 140 140 141 /* 141 142 * Never return an empty share name or the attribute … … 145 146 strcmp(srv->share_name, "*IPC$") == 0) 146 147 continue; 147 148 148 149 /* 149 150 * If we're only allowing one share per server, then … … 152 153 */ 153 154 if (smbc_getOptionOneSharePerServer(context)) { 155 NTSTATUS status; 154 156 /* 155 157 * The currently connected share name … … 157 159 * disconnect from the current share. 158 160 */ 159 if (! cli_tdis(srv->server->cli)) { 161 status = cli_tdis(srv->server->cli); 162 if (!NT_STATUS_IS_OK(status)) { 160 163 /* Sigh. Couldn't disconnect. */ 161 164 cli_shutdown(srv->server->cli); … … 164 167 continue; 165 168 } 166 169 167 170 /* 168 171 * Save the new share name. We've … … 179 182 continue; 180 183 } 181 182 184 183 185 return srv->server; 184 186 } 185 187 } 186 188 } 187 189 188 190 return NULL; 189 191 } … … 200 202 { 201 203 struct smbc_server_cache * srv = NULL; 202 204 203 205 for (srv = context->internal->server_cache; srv; srv = srv->next) { 204 206 if (server == srv->server) { 205 207 206 208 /* remove this sucker */ 207 209 DLIST_REMOVE(context->internal->server_cache, srv); … … 229 231 struct smbc_server_cache * next; 230 232 int could_not_purge_all = 0; 231 233 232 234 for (srv = context->internal->server_cache, 233 235 next = (srv ? srv->next :NULL); … … 235 237 srv = next, 236 238 next = (srv ? srv->next : NULL)) { 237 239 238 240 if (SMBC_remove_unused_server(context, srv->server)) { 239 241 /* could not be removed */
Note:
See TracChangeset
for help on using the changeset viewer.