File: | xlators/protocol/server/src/server-handshake.c |
Location: | line 295, column 17 |
Description: | Value stored to 'op_errno' is never read |
1 | /* |
2 | Copyright (c) 2010-2013 Red Hat, Inc. <http://www.redhat.com> |
3 | This file is part of GlusterFS. |
4 | |
5 | This file is licensed to you under your choice of the GNU Lesser |
6 | General Public License, version 3 or any later version (LGPLv3 or |
7 | later), or the GNU General Public License, version 2 (GPLv2), in all |
8 | cases as published by the Free Software Foundation. |
9 | */ |
10 | |
11 | |
12 | #ifndef _CONFIG_H |
13 | #define _CONFIG_H |
14 | #include "config.h" |
15 | #endif |
16 | |
17 | #include "server.h" |
18 | #include "server-helpers.h" |
19 | #include "glusterfs3-xdr.h" |
20 | #include "compat-errno.h" |
21 | #include "glusterfs3.h" |
22 | #include "authenticate.h" |
23 | |
24 | struct __get_xl_struct { |
25 | const char *name; |
26 | xlator_t *reply; |
27 | }; |
28 | int |
29 | gf_compare_client_version (rpcsvc_request_t *req, int fop_prognum, |
30 | int mgmt_prognum) |
31 | { |
32 | int ret = -1; |
33 | /* TODO: think.. */ |
34 | if (glusterfs3_3_fop_prog.prognum == fop_prognum) |
35 | ret = 0; |
36 | |
37 | return ret; |
38 | } |
39 | |
40 | void __check_and_set (xlator_t *each, void *data) |
41 | { |
42 | if (!strcmp (each->name, |
43 | ((struct __get_xl_struct *) data)->name)) |
44 | ((struct __get_xl_struct *) data)->reply = each; |
45 | } |
46 | |
47 | static xlator_t * |
48 | get_xlator_by_name (xlator_t *some_xl, const char *name) |
49 | { |
50 | struct __get_xl_struct get = { |
51 | .name = name, |
52 | .reply = NULL((void*)0) |
53 | }; |
54 | |
55 | xlator_foreach (some_xl, __check_and_set, &get); |
56 | |
57 | return get.reply; |
58 | } |
59 | |
60 | |
61 | int |
62 | _volfile_update_checksum (xlator_t *this, char *key, uint32_t checksum) |
63 | { |
64 | server_conf_t *conf = NULL((void*)0); |
65 | struct _volfile_ctx *temp_volfile = NULL((void*)0); |
66 | |
67 | conf = this->private; |
68 | temp_volfile = conf->volfile; |
69 | |
70 | while (temp_volfile) { |
71 | if ((NULL((void*)0) == key) && (NULL((void*)0) == temp_volfile->key)) |
72 | break; |
73 | if ((NULL((void*)0) == key) || (NULL((void*)0) == temp_volfile->key)) { |
74 | temp_volfile = temp_volfile->next; |
75 | continue; |
76 | } |
77 | if (strcmp (temp_volfile->key, key) == 0) |
78 | break; |
79 | temp_volfile = temp_volfile->next; |
80 | } |
81 | |
82 | if (!temp_volfile) { |
83 | temp_volfile = GF_CALLOC (1, sizeof (struct _volfile_ctx),__gf_calloc (1, sizeof (struct _volfile_ctx), gf_server_mt_volfile_ctx_t ) |
84 | gf_server_mt_volfile_ctx_t)__gf_calloc (1, sizeof (struct _volfile_ctx), gf_server_mt_volfile_ctx_t ); |
85 | if (!temp_volfile) |
86 | goto out; |
87 | temp_volfile->next = conf->volfile; |
88 | temp_volfile->key = (key)? gf_strdup (key): NULL((void*)0); |
89 | temp_volfile->checksum = checksum; |
90 | |
91 | conf->volfile = temp_volfile; |
92 | goto out; |
93 | } |
94 | |
95 | if (temp_volfile->checksum != checksum) { |
96 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("the volume file got modified between earlier access " "and now, this may lead to inconsistency between " "clients, advised to remount client" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 99, GF_LOG_INFO, "the volume file got modified between earlier access " "and now, this may lead to inconsistency between " "clients, advised to remount client" ); } while (0) |
97 | "the volume file got modified between earlier access "do { do { if (0) printf ("the volume file got modified between earlier access " "and now, this may lead to inconsistency between " "clients, advised to remount client" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 99, GF_LOG_INFO, "the volume file got modified between earlier access " "and now, this may lead to inconsistency between " "clients, advised to remount client" ); } while (0) |
98 | "and now, this may lead to inconsistency between "do { do { if (0) printf ("the volume file got modified between earlier access " "and now, this may lead to inconsistency between " "clients, advised to remount client" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 99, GF_LOG_INFO, "the volume file got modified between earlier access " "and now, this may lead to inconsistency between " "clients, advised to remount client" ); } while (0) |
99 | "clients, advised to remount client")do { do { if (0) printf ("the volume file got modified between earlier access " "and now, this may lead to inconsistency between " "clients, advised to remount client" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 99, GF_LOG_INFO, "the volume file got modified between earlier access " "and now, this may lead to inconsistency between " "clients, advised to remount client" ); } while (0); |
100 | temp_volfile->checksum = checksum; |
101 | } |
102 | |
103 | out: |
104 | return 0; |
105 | } |
106 | |
107 | |
108 | static size_t |
109 | getspec_build_volfile_path (xlator_t *this, const char *key, char *path, |
110 | size_t path_len) |
111 | { |
112 | int ret = -1; |
113 | int free_filename = 0; |
114 | char *filename = NULL((void*)0); |
115 | server_conf_t *conf = NULL((void*)0); |
116 | char data_key[256] = {0,}; |
117 | |
118 | conf = this->private; |
119 | |
120 | /* Inform users that this option is changed now */ |
121 | ret = dict_get_str (this->options, "client-volume-filename", |
122 | &filename); |
123 | if (ret == 0) { |
124 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 130, GF_LOG_WARNING, "option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0) |
125 | "option 'client-volume-filename' is changed to "do { do { if (0) printf ("option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 130, GF_LOG_WARNING, "option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0) |
126 | "'volume-filename.<key>' which now takes 'key' as an "do { do { if (0) printf ("option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 130, GF_LOG_WARNING, "option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0) |
127 | "option to choose/fetch different files from server. "do { do { if (0) printf ("option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 130, GF_LOG_WARNING, "option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0) |
128 | "Refer documentation or contact developers for more "do { do { if (0) printf ("option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 130, GF_LOG_WARNING, "option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0) |
129 | "info. Currently defaulting to given file '%s'",do { do { if (0) printf ("option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 130, GF_LOG_WARNING, "option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0) |
130 | filename)do { do { if (0) printf ("option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 130, GF_LOG_WARNING, "option 'client-volume-filename' is changed to " "'volume-filename.<key>' which now takes 'key' as an " "option to choose/fetch different files from server. " "Refer documentation or contact developers for more " "info. Currently defaulting to given file '%s'", filename); } while (0); |
131 | } |
132 | |
133 | if (key && !filename) { |
134 | sprintf (data_key, "volume-filename.%s", key); |
135 | ret = dict_get_str (this->options, data_key, &filename); |
136 | if (ret < 0) { |
137 | /* Make sure that key doesn't contain "../" in path */ |
138 | if ((gf_strstr (key, "/", "..")) == -1) { |
139 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("%s: invalid key", key); } while (0) ; _gf_log (this->name, "server-handshake.c", __FUNCTION__, 140, GF_LOG_ERROR, "%s: invalid key", key); } while (0) |
140 | "%s: invalid key", key)do { do { if (0) printf ("%s: invalid key", key); } while (0) ; _gf_log (this->name, "server-handshake.c", __FUNCTION__, 140, GF_LOG_ERROR, "%s: invalid key", key); } while (0); |
141 | goto out; |
142 | } |
143 | } |
144 | } |
145 | |
146 | if (!filename) { |
147 | ret = dict_get_str (this->options, |
148 | "volume-filename.default", &filename); |
149 | if (ret < 0) { |
150 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no default volume filename given, " "defaulting to %s", "/usr/local/etc/glusterfs" "/glusterfs.vol" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 152, GF_LOG_DEBUG, "no default volume filename given, " "defaulting to %s", "/usr/local/etc/glusterfs" "/glusterfs.vol" ); } while (0) |
151 | "no default volume filename given, "do { do { if (0) printf ("no default volume filename given, " "defaulting to %s", "/usr/local/etc/glusterfs" "/glusterfs.vol" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 152, GF_LOG_DEBUG, "no default volume filename given, " "defaulting to %s", "/usr/local/etc/glusterfs" "/glusterfs.vol" ); } while (0) |
152 | "defaulting to %s", DEFAULT_VOLUME_FILE_PATH)do { do { if (0) printf ("no default volume filename given, " "defaulting to %s", "/usr/local/etc/glusterfs" "/glusterfs.vol" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 152, GF_LOG_DEBUG, "no default volume filename given, " "defaulting to %s", "/usr/local/etc/glusterfs" "/glusterfs.vol" ); } while (0); |
153 | } |
154 | } |
155 | |
156 | if (!filename && key) { |
157 | ret = gf_asprintf (&filename, "%s/%s.vol", conf->conf_dir, key); |
158 | if (-1 == ret) |
159 | goto out; |
160 | |
161 | free_filename = 1; |
162 | } |
163 | if (!filename) |
164 | filename = DEFAULT_VOLUME_FILE_PATH"/usr/local/etc/glusterfs" "/glusterfs.vol"; |
165 | |
166 | ret = -1; |
167 | |
168 | if ((filename) && (path_len > strlen (filename))) { |
169 | strcpy (path, filename); |
170 | ret = strlen (filename); |
171 | } |
172 | |
173 | out: |
174 | if (free_filename) |
175 | GF_FREE (filename)__gf_free (filename); |
176 | |
177 | return ret; |
178 | } |
179 | |
180 | int |
181 | _validate_volfile_checksum (xlator_t *this, char *key, |
182 | uint32_t checksum) |
183 | { |
184 | char filename[PATH_MAX4096] = {0,}; |
185 | server_conf_t *conf = NULL((void*)0); |
186 | struct _volfile_ctx *temp_volfile = NULL((void*)0); |
187 | int ret = 0; |
188 | int fd = 0; |
189 | uint32_t local_checksum = 0; |
190 | |
191 | conf = this->private; |
192 | temp_volfile = conf->volfile; |
193 | |
194 | if (!checksum) |
195 | goto out; |
196 | |
197 | if (!temp_volfile) { |
198 | ret = getspec_build_volfile_path (this, key, filename, |
199 | sizeof (filename)); |
200 | if (ret <= 0) |
201 | goto out; |
202 | fd = open (filename, O_RDONLY00); |
203 | if (-1 == fd) { |
204 | ret = 0; |
205 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("failed to open volume file (%s) : %s" , filename, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 207, GF_LOG_INFO , "failed to open volume file (%s) : %s", filename, strerror ( (*__errno_location ()))); } while (0) |
206 | "failed to open volume file (%s) : %s",do { do { if (0) printf ("failed to open volume file (%s) : %s" , filename, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 207, GF_LOG_INFO , "failed to open volume file (%s) : %s", filename, strerror ( (*__errno_location ()))); } while (0) |
207 | filename, strerror (errno))do { do { if (0) printf ("failed to open volume file (%s) : %s" , filename, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 207, GF_LOG_INFO , "failed to open volume file (%s) : %s", filename, strerror ( (*__errno_location ()))); } while (0); |
208 | goto out; |
209 | } |
210 | get_checksum_for_file (fd, &local_checksum); |
211 | _volfile_update_checksum (this, key, local_checksum); |
212 | close (fd); |
213 | } |
214 | |
215 | temp_volfile = conf->volfile; |
216 | while (temp_volfile) { |
217 | if ((NULL((void*)0) == key) && (NULL((void*)0) == temp_volfile->key)) |
218 | break; |
219 | if ((NULL((void*)0) == key) || (NULL((void*)0) == temp_volfile->key)) { |
220 | temp_volfile = temp_volfile->next; |
221 | continue; |
222 | } |
223 | if (strcmp (temp_volfile->key, key) == 0) |
224 | break; |
225 | temp_volfile = temp_volfile->next; |
226 | } |
227 | |
228 | if (!temp_volfile) |
229 | goto out; |
230 | |
231 | if ((temp_volfile->checksum) && |
232 | (checksum != temp_volfile->checksum)) |
233 | ret = -1; |
234 | |
235 | out: |
236 | return ret; |
237 | } |
238 | |
239 | |
240 | int |
241 | server_getspec (rpcsvc_request_t *req) |
242 | { |
243 | int32_t ret = -1; |
244 | int32_t op_errno = ENOENT2; |
245 | int32_t spec_fd = -1; |
246 | size_t file_len = 0; |
247 | char filename[PATH_MAX4096] = {0,}; |
248 | struct stat stbuf = {0,}; |
249 | uint32_t checksum = 0; |
250 | char *key = NULL((void*)0); |
251 | server_conf_t *conf = NULL((void*)0); |
252 | xlator_t *this = NULL((void*)0); |
253 | gf_getspec_req args = {0,}; |
254 | gf_getspec_rsp rsp = {0,}; |
255 | |
256 | this = req->svc->mydata; |
257 | conf = this->private; |
258 | ret = xdr_to_generic (req->msg[0], &args, |
259 | (xdrproc_t)xdr_gf_getspec_req); |
260 | if (ret < 0) { |
261 | //failed to decode msg; |
262 | req->rpc_err = GARBAGE_ARGS; |
263 | op_errno = EINVAL22; |
264 | goto fail; |
265 | } |
266 | |
267 | ret = getspec_build_volfile_path (this, args.key, |
268 | filename, sizeof (filename)); |
269 | if (ret > 0) { |
270 | /* to allocate the proper buffer to hold the file data */ |
271 | ret = stat (filename, &stbuf); |
272 | if (ret < 0){ |
273 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Unable to stat %s (%s)", filename, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name , "server-handshake.c", __FUNCTION__, 275, GF_LOG_ERROR, "Unable to stat %s (%s)" , filename, strerror ((*__errno_location ()))); } while (0) |
274 | "Unable to stat %s (%s)",do { do { if (0) printf ("Unable to stat %s (%s)", filename, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name , "server-handshake.c", __FUNCTION__, 275, GF_LOG_ERROR, "Unable to stat %s (%s)" , filename, strerror ((*__errno_location ()))); } while (0) |
275 | filename, strerror (errno))do { do { if (0) printf ("Unable to stat %s (%s)", filename, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name , "server-handshake.c", __FUNCTION__, 275, GF_LOG_ERROR, "Unable to stat %s (%s)" , filename, strerror ((*__errno_location ()))); } while (0); |
276 | op_errno = errno(*__errno_location ()); |
277 | goto fail; |
278 | } |
279 | |
280 | spec_fd = open (filename, O_RDONLY00); |
281 | if (spec_fd < 0) { |
282 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Unable to open %s (%s)", filename, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name , "server-handshake.c", __FUNCTION__, 284, GF_LOG_ERROR, "Unable to open %s (%s)" , filename, strerror ((*__errno_location ()))); } while (0) |
283 | "Unable to open %s (%s)",do { do { if (0) printf ("Unable to open %s (%s)", filename, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name , "server-handshake.c", __FUNCTION__, 284, GF_LOG_ERROR, "Unable to open %s (%s)" , filename, strerror ((*__errno_location ()))); } while (0) |
284 | filename, strerror (errno))do { do { if (0) printf ("Unable to open %s (%s)", filename, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name , "server-handshake.c", __FUNCTION__, 284, GF_LOG_ERROR, "Unable to open %s (%s)" , filename, strerror ((*__errno_location ()))); } while (0); |
285 | op_errno = errno(*__errno_location ()); |
286 | goto fail; |
287 | } |
288 | ret = file_len = stbuf.st_size; |
289 | |
290 | if (conf->verify_volfile) { |
291 | get_checksum_for_file (spec_fd, &checksum); |
292 | _volfile_update_checksum (this, key, checksum); |
293 | } |
294 | } else { |
295 | op_errno = ENOENT2; |
Value stored to 'op_errno' is never read | |
296 | } |
297 | |
298 | if (file_len) { |
299 | rsp.spec = GF_CALLOC (file_len, sizeof (char),__gf_calloc (file_len, sizeof (char), gf_server_mt_rsp_buf_t) |
300 | gf_server_mt_rsp_buf_t)__gf_calloc (file_len, sizeof (char), gf_server_mt_rsp_buf_t); |
301 | if (!rsp.spec) { |
302 | ret = -1; |
303 | op_errno = ENOMEM12; |
304 | goto fail; |
305 | } |
306 | ret = read (spec_fd, rsp.spec, file_len); |
307 | } |
308 | |
309 | /* convert to XDR */ |
310 | op_errno = errno(*__errno_location ()); |
311 | fail: |
312 | if (!rsp.spec) |
313 | rsp.spec = ""; |
314 | rsp.op_errno = gf_errno_to_error (op_errno); |
315 | rsp.op_ret = ret; |
316 | |
317 | if (spec_fd != -1) |
318 | close (spec_fd); |
319 | |
320 | server_submit_reply (NULL((void*)0), req, &rsp, NULL((void*)0), 0, NULL((void*)0), |
321 | (xdrproc_t)xdr_gf_getspec_rsp); |
322 | |
323 | return 0; |
324 | } |
325 | |
326 | |
327 | int |
328 | server_setvolume (rpcsvc_request_t *req) |
329 | { |
330 | gf_setvolume_req args = {{0,},}; |
331 | gf_setvolume_rsp rsp = {0,}; |
332 | server_connection_t *conn = NULL((void*)0); |
333 | server_conf_t *conf = NULL((void*)0); |
334 | peer_info_t *peerinfo = NULL((void*)0); |
335 | dict_t *reply = NULL((void*)0); |
336 | dict_t *config_params = NULL((void*)0); |
337 | dict_t *params = NULL((void*)0); |
338 | char *name = NULL((void*)0); |
339 | char *process_uuid = NULL((void*)0); |
340 | char *clnt_version = NULL((void*)0); |
341 | xlator_t *xl = NULL((void*)0); |
342 | char *msg = NULL((void*)0); |
343 | char *volfile_key = NULL((void*)0); |
344 | xlator_t *this = NULL((void*)0); |
345 | uint32_t checksum = 0; |
346 | int32_t ret = -1; |
347 | int32_t op_ret = -1; |
348 | int32_t op_errno = EINVAL22; |
349 | int32_t fop_version = 0; |
350 | int32_t mgmt_version = 0; |
351 | uint32_t lk_version = 0; |
352 | char *buf = NULL((void*)0); |
353 | gf_boolean_t cancelled = _gf_false; |
354 | |
355 | params = dict_new (); |
356 | reply = dict_new (); |
357 | ret = xdr_to_generic (req->msg[0], &args, |
358 | (xdrproc_t)xdr_gf_setvolume_req); |
359 | if (ret < 0) { |
360 | //failed to decode msg; |
361 | req->rpc_err = GARBAGE_ARGS; |
362 | goto fail; |
363 | } |
364 | |
365 | this = req->svc->mydata; |
366 | |
367 | config_params = dict_copy_with_ref (this->options, NULL((void*)0)); |
368 | conf = this->private; |
369 | |
370 | buf = memdup (args.dict.dict_val, args.dict.dict_len); |
371 | if (buf == NULL((void*)0)) { |
372 | op_ret = -1; |
373 | op_errno = ENOMEM12; |
374 | goto fail; |
375 | } |
376 | |
377 | ret = dict_unserialize (buf, args.dict.dict_len, ¶ms); |
378 | if (ret < 0) { |
379 | ret = dict_set_str (reply, "ERROR", |
380 | "Internal error: failed to unserialize " |
381 | "request dictionary"); |
382 | if (ret < 0) |
383 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg \"%s\"", "Internal error: failed to unserialize " "request dictionary"); } while (0); _gf_log (this->name, "server-handshake.c" , __FUNCTION__, 386, GF_LOG_DEBUG, "failed to set error msg \"%s\"" , "Internal error: failed to unserialize " "request dictionary" ); } while (0) |
384 | "failed to set error msg \"%s\"",do { do { if (0) printf ("failed to set error msg \"%s\"", "Internal error: failed to unserialize " "request dictionary"); } while (0); _gf_log (this->name, "server-handshake.c" , __FUNCTION__, 386, GF_LOG_DEBUG, "failed to set error msg \"%s\"" , "Internal error: failed to unserialize " "request dictionary" ); } while (0) |
385 | "Internal error: failed to unserialize "do { do { if (0) printf ("failed to set error msg \"%s\"", "Internal error: failed to unserialize " "request dictionary"); } while (0); _gf_log (this->name, "server-handshake.c" , __FUNCTION__, 386, GF_LOG_DEBUG, "failed to set error msg \"%s\"" , "Internal error: failed to unserialize " "request dictionary" ); } while (0) |
386 | "request dictionary")do { do { if (0) printf ("failed to set error msg \"%s\"", "Internal error: failed to unserialize " "request dictionary"); } while (0); _gf_log (this->name, "server-handshake.c" , __FUNCTION__, 386, GF_LOG_DEBUG, "failed to set error msg \"%s\"" , "Internal error: failed to unserialize " "request dictionary" ); } while (0); |
387 | |
388 | op_ret = -1; |
389 | op_errno = EINVAL22; |
390 | goto fail; |
391 | } |
392 | |
393 | params->extra_free = buf; |
394 | buf = NULL((void*)0); |
395 | |
396 | ret = dict_get_str (params, "process-uuid", &process_uuid); |
397 | if (ret < 0) { |
398 | ret = dict_set_str (reply, "ERROR", |
399 | "UUID not specified"); |
400 | if (ret < 0) |
401 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 402, GF_LOG_DEBUG, "failed to set error msg"); } while (0) |
402 | "failed to set error msg")do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 402, GF_LOG_DEBUG, "failed to set error msg"); } while (0); |
403 | |
404 | op_ret = -1; |
405 | op_errno = EINVAL22; |
406 | goto fail; |
407 | } |
408 | |
409 | /*lk_verion :: [1..2^31-1]*/ |
410 | ret = dict_get_uint32 (params, "clnt-lk-version", &lk_version); |
411 | if (ret < 0) { |
412 | ret = dict_set_str (reply, "ERROR", |
413 | "lock state version not supplied"); |
414 | if (ret < 0) |
415 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 416, GF_LOG_DEBUG, "failed to set error msg"); } while (0) |
416 | "failed to set error msg")do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 416, GF_LOG_DEBUG, "failed to set error msg"); } while (0); |
417 | |
418 | op_ret = -1; |
419 | op_errno = EINVAL22; |
420 | goto fail; |
421 | } |
422 | |
423 | conn = server_connection_get (this, process_uuid); |
424 | if (!conn) { |
425 | op_ret = -1; |
426 | op_errno = ENOMEM12; |
427 | goto fail; |
428 | } |
429 | |
430 | gf_log (this->name, GF_LOG_DEBUG, "Connected to %s", conn->id)do { do { if (0) printf ("Connected to %s", conn->id); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 430, GF_LOG_DEBUG, "Connected to %s", conn->id); } while (0); |
431 | cancelled = server_cancel_conn_timer (this, conn); |
432 | if (cancelled)//Do connection_put on behalf of grace-timer-handler. |
433 | server_connection_put (this, conn, NULL((void*)0)); |
434 | if (conn->lk_version != 0 && |
435 | conn->lk_version != lk_version) { |
436 | (void) server_connection_cleanup (this, conn, |
437 | INTERNAL_LOCKS | POSIX_LOCKS); |
438 | } |
439 | |
440 | if (req->trans->xl_private != conn) |
441 | req->trans->xl_private = conn; |
442 | |
443 | ret = dict_get_int32 (params, "fops-version", &fop_version); |
444 | if (ret < 0) { |
445 | ret = dict_set_str (reply, "ERROR", |
446 | "No FOP version number specified"); |
447 | if (ret < 0) |
448 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 449, GF_LOG_DEBUG, "failed to set error msg"); } while (0) |
449 | "failed to set error msg")do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 449, GF_LOG_DEBUG, "failed to set error msg"); } while (0); |
450 | } |
451 | |
452 | ret = dict_get_int32 (params, "mgmt-version", &mgmt_version); |
453 | if (ret < 0) { |
454 | ret = dict_set_str (reply, "ERROR", |
455 | "No MGMT version number specified"); |
456 | if (ret < 0) |
457 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 458, GF_LOG_DEBUG, "failed to set error msg"); } while (0) |
458 | "failed to set error msg")do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 458, GF_LOG_DEBUG, "failed to set error msg"); } while (0); |
459 | } |
460 | |
461 | ret = gf_compare_client_version (req, fop_version, mgmt_version); |
462 | if (ret != 0) { |
463 | ret = gf_asprintf (&msg, "version mismatch: client(%d)" |
464 | " - client-mgmt(%d)", |
465 | fop_version, mgmt_version); |
466 | /* get_supported_version (req)); */ |
467 | if (-1 == ret) { |
468 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("asprintf failed while setting up error msg" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 469, GF_LOG_ERROR, "asprintf failed while setting up error msg" ); } while (0) |
469 | "asprintf failed while setting up error msg")do { do { if (0) printf ("asprintf failed while setting up error msg" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 469, GF_LOG_ERROR, "asprintf failed while setting up error msg" ); } while (0); |
470 | goto fail; |
471 | } |
472 | ret = dict_set_dynstr (reply, "ERROR", msg); |
473 | if (ret < 0) |
474 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 475, GF_LOG_DEBUG, "failed to set error msg"); } while (0) |
475 | "failed to set error msg")do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 475, GF_LOG_DEBUG, "failed to set error msg"); } while (0); |
476 | |
477 | op_ret = -1; |
478 | op_errno = EINVAL22; |
479 | goto fail; |
480 | } |
481 | |
482 | ret = dict_get_str (params, "remote-subvolume", &name); |
483 | if (ret < 0) { |
484 | ret = dict_set_str (reply, "ERROR", |
485 | "No remote-subvolume option specified"); |
486 | if (ret < 0) |
487 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 488, GF_LOG_DEBUG, "failed to set error msg"); } while (0) |
488 | "failed to set error msg")do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 488, GF_LOG_DEBUG, "failed to set error msg"); } while (0); |
489 | |
490 | op_ret = -1; |
491 | op_errno = EINVAL22; |
492 | goto fail; |
493 | } |
494 | |
495 | xl = get_xlator_by_name (this, name); |
496 | if (xl == NULL((void*)0)) { |
497 | ret = gf_asprintf (&msg, "remote-subvolume \"%s\" is not found", |
498 | name); |
499 | if (-1 == ret) { |
500 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("asprintf failed while setting error msg" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 501, GF_LOG_ERROR, "asprintf failed while setting error msg" ); } while (0) |
501 | "asprintf failed while setting error msg")do { do { if (0) printf ("asprintf failed while setting error msg" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 501, GF_LOG_ERROR, "asprintf failed while setting error msg" ); } while (0); |
502 | goto fail; |
503 | } |
504 | ret = dict_set_dynstr (reply, "ERROR", msg); |
505 | if (ret < 0) |
506 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 507, GF_LOG_DEBUG, "failed to set error msg"); } while (0) |
507 | "failed to set error msg")do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 507, GF_LOG_DEBUG, "failed to set error msg"); } while (0); |
508 | |
509 | op_ret = -1; |
510 | op_errno = ENOENT2; |
511 | goto fail; |
512 | } |
513 | |
514 | if (conf->verify_volfile) { |
515 | ret = dict_get_uint32 (params, "volfile-checksum", &checksum); |
516 | if (ret == 0) { |
517 | ret = dict_get_str (params, "volfile-key", |
518 | &volfile_key); |
519 | if (ret) |
520 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set 'volfile-key'"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 521, GF_LOG_DEBUG, "failed to set 'volfile-key'"); } while ( 0) |
521 | "failed to set 'volfile-key'")do { do { if (0) printf ("failed to set 'volfile-key'"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 521, GF_LOG_DEBUG, "failed to set 'volfile-key'"); } while ( 0); |
522 | |
523 | ret = _validate_volfile_checksum (this, volfile_key, |
524 | checksum); |
525 | if (-1 == ret) { |
526 | ret = dict_set_str (reply, "ERROR", |
527 | "volume-file checksum " |
528 | "varies from earlier " |
529 | "access"); |
530 | if (ret < 0) |
531 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 532, GF_LOG_DEBUG, "failed to set error msg"); } while (0) |
532 | "failed to set error msg")do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 532, GF_LOG_DEBUG, "failed to set error msg"); } while (0); |
533 | |
534 | op_ret = -1; |
535 | op_errno = ESTALE116; |
536 | goto fail; |
537 | } |
538 | } |
539 | } |
540 | |
541 | |
542 | peerinfo = &req->trans->peerinfo; |
543 | if (peerinfo) { |
544 | ret = dict_set_static_ptr (params, "peer-info", peerinfo); |
545 | if (ret < 0) |
546 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set peer-info"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 547, GF_LOG_DEBUG, "failed to set peer-info"); } while (0) |
547 | "failed to set peer-info")do { do { if (0) printf ("failed to set peer-info"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 547, GF_LOG_DEBUG, "failed to set peer-info"); } while (0); |
548 | } |
549 | if (conf->auth_modules == NULL((void*)0)) { |
550 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Authentication module not initialized" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 551, GF_LOG_ERROR, "Authentication module not initialized" ); } while (0) |
551 | "Authentication module not initialized")do { do { if (0) printf ("Authentication module not initialized" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 551, GF_LOG_ERROR, "Authentication module not initialized" ); } while (0); |
552 | } |
553 | |
554 | ret = dict_get_str (params, "client-version", &clnt_version); |
555 | if (ret) |
556 | gf_log (this->name, GF_LOG_INFO, "client-version not set, "do { do { if (0) printf ("client-version not set, " "may be of older version" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 557, GF_LOG_INFO, "client-version not set, " "may be of older version" ); } while (0) |
557 | "may be of older version")do { do { if (0) printf ("client-version not set, " "may be of older version" ); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__, 557, GF_LOG_INFO, "client-version not set, " "may be of older version" ); } while (0); |
558 | |
559 | ret = gf_authenticate (params, config_params, |
560 | conf->auth_modules); |
561 | |
562 | if (ret == AUTH_ACCEPT) { |
563 | |
564 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("accepted client from %s (version: %s)" , conn->id, (clnt_version) ? clnt_version : "old"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 567, GF_LOG_INFO, "accepted client from %s (version: %s)", conn ->id, (clnt_version) ? clnt_version : "old"); } while (0) |
565 | "accepted client from %s (version: %s)",do { do { if (0) printf ("accepted client from %s (version: %s)" , conn->id, (clnt_version) ? clnt_version : "old"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 567, GF_LOG_INFO, "accepted client from %s (version: %s)", conn ->id, (clnt_version) ? clnt_version : "old"); } while (0) |
566 | conn->id,do { do { if (0) printf ("accepted client from %s (version: %s)" , conn->id, (clnt_version) ? clnt_version : "old"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 567, GF_LOG_INFO, "accepted client from %s (version: %s)", conn ->id, (clnt_version) ? clnt_version : "old"); } while (0) |
567 | (clnt_version) ? clnt_version : "old")do { do { if (0) printf ("accepted client from %s (version: %s)" , conn->id, (clnt_version) ? clnt_version : "old"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 567, GF_LOG_INFO, "accepted client from %s (version: %s)", conn ->id, (clnt_version) ? clnt_version : "old"); } while (0); |
568 | op_ret = 0; |
569 | conn->bound_xl = xl; |
570 | ret = dict_set_str (reply, "ERROR", "Success"); |
571 | if (ret < 0) |
572 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 573, GF_LOG_DEBUG, "failed to set error msg"); } while (0) |
573 | "failed to set error msg")do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 573, GF_LOG_DEBUG, "failed to set error msg"); } while (0); |
574 | } else { |
575 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Cannot authenticate client from %s %s" , conn->id, (clnt_version) ? clnt_version : "old"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 578, GF_LOG_ERROR, "Cannot authenticate client from %s %s", conn->id, (clnt_version) ? clnt_version : "old"); } while (0) |
576 | "Cannot authenticate client from %s %s",do { do { if (0) printf ("Cannot authenticate client from %s %s" , conn->id, (clnt_version) ? clnt_version : "old"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 578, GF_LOG_ERROR, "Cannot authenticate client from %s %s", conn->id, (clnt_version) ? clnt_version : "old"); } while (0) |
577 | conn->id,do { do { if (0) printf ("Cannot authenticate client from %s %s" , conn->id, (clnt_version) ? clnt_version : "old"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 578, GF_LOG_ERROR, "Cannot authenticate client from %s %s", conn->id, (clnt_version) ? clnt_version : "old"); } while (0) |
578 | (clnt_version) ? clnt_version : "old")do { do { if (0) printf ("Cannot authenticate client from %s %s" , conn->id, (clnt_version) ? clnt_version : "old"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 578, GF_LOG_ERROR, "Cannot authenticate client from %s %s", conn->id, (clnt_version) ? clnt_version : "old"); } while (0); |
579 | |
580 | op_ret = -1; |
581 | op_errno = EACCES13; |
582 | ret = dict_set_str (reply, "ERROR", "Authentication failed"); |
583 | if (ret < 0) |
584 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 585, GF_LOG_DEBUG, "failed to set error msg"); } while (0) |
585 | "failed to set error msg")do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 585, GF_LOG_DEBUG, "failed to set error msg"); } while (0); |
586 | goto fail; |
587 | } |
588 | |
589 | if (conn->bound_xl == NULL((void*)0)) { |
590 | ret = dict_set_str (reply, "ERROR", |
591 | "Check volfile and handshake " |
592 | "options in protocol/client"); |
593 | if (ret < 0) |
594 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 595, GF_LOG_DEBUG, "failed to set error msg"); } while (0) |
595 | "failed to set error msg")do { do { if (0) printf ("failed to set error msg"); } while ( 0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 595, GF_LOG_DEBUG, "failed to set error msg"); } while (0); |
596 | |
597 | op_ret = -1; |
598 | op_errno = EACCES13; |
599 | goto fail; |
600 | } |
601 | |
602 | if ((conn->bound_xl != NULL((void*)0)) && |
603 | (ret >= 0) && |
604 | (conn->bound_xl->itable == NULL((void*)0))) { |
605 | /* create inode table for this bound_xl, if one doesn't |
606 | already exist */ |
607 | |
608 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("creating inode table with lru_limit=%" "d"", " "xlator=%s", conf->inode_lru_limit, conn->bound_xl ->name); } while (0); _gf_log (this->name, "server-handshake.c" , __FUNCTION__, 611, GF_LOG_TRACE, "creating inode table with lru_limit=%" "d"", " "xlator=%s", conf->inode_lru_limit, conn->bound_xl ->name); } while (0) |
609 | "creating inode table with lru_limit=%"PRId32", "do { do { if (0) printf ("creating inode table with lru_limit=%" "d"", " "xlator=%s", conf->inode_lru_limit, conn->bound_xl ->name); } while (0); _gf_log (this->name, "server-handshake.c" , __FUNCTION__, 611, GF_LOG_TRACE, "creating inode table with lru_limit=%" "d"", " "xlator=%s", conf->inode_lru_limit, conn->bound_xl ->name); } while (0) |
610 | "xlator=%s", conf->inode_lru_limit,do { do { if (0) printf ("creating inode table with lru_limit=%" "d"", " "xlator=%s", conf->inode_lru_limit, conn->bound_xl ->name); } while (0); _gf_log (this->name, "server-handshake.c" , __FUNCTION__, 611, GF_LOG_TRACE, "creating inode table with lru_limit=%" "d"", " "xlator=%s", conf->inode_lru_limit, conn->bound_xl ->name); } while (0) |
611 | conn->bound_xl->name)do { do { if (0) printf ("creating inode table with lru_limit=%" "d"", " "xlator=%s", conf->inode_lru_limit, conn->bound_xl ->name); } while (0); _gf_log (this->name, "server-handshake.c" , __FUNCTION__, 611, GF_LOG_TRACE, "creating inode table with lru_limit=%" "d"", " "xlator=%s", conf->inode_lru_limit, conn->bound_xl ->name); } while (0); |
612 | |
613 | /* TODO: what is this ? */ |
614 | conn->bound_xl->itable = inode_table_new (conf->inode_lru_limit, |
615 | conn->bound_xl); |
616 | } |
617 | |
618 | ret = dict_set_str (reply, "process-uuid", |
619 | this->ctx->process_uuid); |
620 | if (ret) |
621 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set 'process-uuid'"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 622, GF_LOG_DEBUG, "failed to set 'process-uuid'"); } while (0) |
622 | "failed to set 'process-uuid'")do { do { if (0) printf ("failed to set 'process-uuid'"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 622, GF_LOG_DEBUG, "failed to set 'process-uuid'"); } while (0); |
623 | |
624 | ret = dict_set_uint32 (reply, "clnt-lk-version", |
625 | conn->lk_version); |
626 | if (ret) |
627 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set 'clnt-lk-version'"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 628, GF_LOG_WARNING, "failed to set 'clnt-lk-version'"); } while (0) |
628 | "failed to set 'clnt-lk-version'")do { do { if (0) printf ("failed to set 'clnt-lk-version'"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 628, GF_LOG_WARNING, "failed to set 'clnt-lk-version'"); } while (0); |
629 | |
630 | ret = dict_set_uint64 (reply, "transport-ptr", |
631 | ((uint64_t) (long) req->trans)); |
632 | if (ret) |
633 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set 'transport-ptr'"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 634, GF_LOG_DEBUG, "failed to set 'transport-ptr'"); } while (0) |
634 | "failed to set 'transport-ptr'")do { do { if (0) printf ("failed to set 'transport-ptr'"); } while (0); _gf_log (this->name, "server-handshake.c", __FUNCTION__ , 634, GF_LOG_DEBUG, "failed to set 'transport-ptr'"); } while (0); |
635 | |
636 | fail: |
637 | rsp.dict.dict_len = dict_serialized_length (reply); |
638 | if (rsp.dict.dict_len < 0) { |
639 | gf_log ("server-handshake", GF_LOG_DEBUG,do { do { if (0) printf ("failed to get serialized length of reply dict" ); } while (0); _gf_log ("server-handshake", "server-handshake.c" , __FUNCTION__, 640, GF_LOG_DEBUG, "failed to get serialized length of reply dict" ); } while (0) |
640 | "failed to get serialized length of reply dict")do { do { if (0) printf ("failed to get serialized length of reply dict" ); } while (0); _gf_log ("server-handshake", "server-handshake.c" , __FUNCTION__, 640, GF_LOG_DEBUG, "failed to get serialized length of reply dict" ); } while (0); |
641 | op_ret = -1; |
642 | op_errno = EINVAL22; |
643 | rsp.dict.dict_len = 0; |
644 | } |
645 | |
646 | if (rsp.dict.dict_len) { |
647 | rsp.dict.dict_val = GF_CALLOC (1, rsp.dict.dict_len,__gf_calloc (1, rsp.dict.dict_len, gf_server_mt_rsp_buf_t) |
648 | gf_server_mt_rsp_buf_t)__gf_calloc (1, rsp.dict.dict_len, gf_server_mt_rsp_buf_t); |
649 | if (rsp.dict.dict_val) { |
650 | ret = dict_serialize (reply, rsp.dict.dict_val); |
651 | if (ret < 0) { |
652 | gf_log ("server-handshake", GF_LOG_DEBUG,do { do { if (0) printf ("failed to serialize reply dict"); } while (0); _gf_log ("server-handshake", "server-handshake.c" , __FUNCTION__, 653, GF_LOG_DEBUG, "failed to serialize reply dict" ); } while (0) |
653 | "failed to serialize reply dict")do { do { if (0) printf ("failed to serialize reply dict"); } while (0); _gf_log ("server-handshake", "server-handshake.c" , __FUNCTION__, 653, GF_LOG_DEBUG, "failed to serialize reply dict" ); } while (0); |
654 | op_ret = -1; |
655 | op_errno = -ret; |
656 | } |
657 | } |
658 | } |
659 | rsp.op_ret = op_ret; |
660 | rsp.op_errno = gf_errno_to_error (op_errno); |
661 | |
662 | /* if bound_xl is NULL or something fails, then put the connection |
663 | * back. Otherwise the connection would have been added to the |
664 | * list of connections the server is maintaining and might segfault |
665 | * during statedump when bound_xl of the connection is accessed. |
666 | */ |
667 | if (op_ret && conn && !xl) { |
668 | /* We would have set the xl_private of the transport to the |
669 | * @conn. But if we have put the connection i.e shutting down |
670 | * the connection, then we should set xl_private to NULL as it |
671 | * would be pointing to a freed memory and would segfault when |
672 | * accessed upon getting DISCONNECT. |
673 | */ |
674 | if (server_connection_put (this, conn, NULL((void*)0)) == NULL((void*)0)) |
675 | req->trans->xl_private = NULL((void*)0); |
676 | } |
677 | server_submit_reply (NULL((void*)0), req, &rsp, NULL((void*)0), 0, NULL((void*)0), |
678 | (xdrproc_t)xdr_gf_setvolume_rsp); |
679 | |
680 | |
681 | free (args.dict.dict_val); |
682 | |
683 | GF_FREE (rsp.dict.dict_val)__gf_free (rsp.dict.dict_val); |
684 | |
685 | dict_unref (params); |
686 | dict_unref (reply); |
687 | dict_unref (config_params); |
688 | |
689 | GF_FREE (buf)__gf_free (buf); |
690 | |
691 | return 0; |
692 | } |
693 | |
694 | |
695 | int |
696 | server_ping (rpcsvc_request_t *req) |
697 | { |
698 | gf_common_rsp rsp = {0,}; |
699 | |
700 | /* Accepted */ |
701 | rsp.op_ret = 0; |
702 | |
703 | server_submit_reply (NULL((void*)0), req, &rsp, NULL((void*)0), 0, NULL((void*)0), |
704 | (xdrproc_t)xdr_gf_common_rsp); |
705 | |
706 | return 0; |
707 | } |
708 | |
709 | int |
710 | server_set_lk_version (rpcsvc_request_t *req) |
711 | { |
712 | int op_ret = -1; |
713 | int op_errno = EINVAL22; |
714 | gf_set_lk_ver_req args = {0, }; |
715 | gf_set_lk_ver_rsp rsp = {0,}; |
716 | server_connection_t *conn = NULL((void*)0); |
717 | xlator_t *this = NULL((void*)0); |
718 | |
719 | this = req->svc->mydata; |
720 | //TODO: Decide on an appropriate errno for the error-path |
721 | //below |
722 | if (!this) |
723 | goto fail; |
724 | |
725 | op_ret = xdr_to_generic (req->msg[0], &args, |
726 | (xdrproc_t)xdr_gf_set_lk_ver_req); |
727 | if (op_ret < 0) { |
728 | //failed to decode msg; |
729 | req->rpc_err = GARBAGE_ARGS; |
730 | goto fail; |
731 | } |
732 | |
733 | conn = server_connection_get (this, args.uid); |
734 | conn->lk_version = args.lk_ver; |
735 | server_connection_put (this, conn, NULL((void*)0)); |
736 | |
737 | rsp.lk_ver = args.lk_ver; |
738 | |
739 | op_ret = 0; |
740 | fail: |
741 | rsp.op_ret = op_ret; |
742 | rsp.op_errno = op_errno; |
743 | server_submit_reply (NULL((void*)0), req, &rsp, NULL((void*)0), 0, NULL((void*)0), |
744 | (xdrproc_t)xdr_gf_set_lk_ver_rsp); |
745 | |
746 | free (args.uid); |
747 | |
748 | return 0; |
749 | } |
750 | |
751 | rpcsvc_actor_t gluster_handshake_actors[] = { |
752 | [GF_HNDSK_NULL] = {"NULL", GF_HNDSK_NULL, server_null, NULL((void*)0), 0}, |
753 | [GF_HNDSK_SETVOLUME] = {"SETVOLUME", GF_HNDSK_SETVOLUME, server_setvolume, NULL((void*)0), 0}, |
754 | [GF_HNDSK_GETSPEC] = {"GETSPEC", GF_HNDSK_GETSPEC, server_getspec, NULL((void*)0), 0}, |
755 | [GF_HNDSK_PING] = {"PING", GF_HNDSK_PING, server_ping, NULL((void*)0), 0}, |
756 | [GF_HNDSK_SET_LK_VER] = {"SET_LK_VER", GF_HNDSK_SET_LK_VER, server_set_lk_version, NULL((void*)0), 0}, |
757 | }; |
758 | |
759 | |
760 | struct rpcsvc_program gluster_handshake_prog = { |
761 | .progname = "GlusterFS Handshake", |
762 | .prognum = GLUSTER_HNDSK_PROGRAM14398633, |
763 | .progver = GLUSTER_HNDSK_VERSION2, |
764 | .actors = gluster_handshake_actors, |
765 | .numactors = GF_HNDSK_MAXVALUE, |
766 | }; |