cfg.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*
  2. * Copyright (c) 2002-2005 MontaVista Software, Inc.
  3. * Copyright (c) 2006 Red Hat, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@mvista.com)
  8. *
  9. * This software licensed under BSD license, the text of which follows:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * - Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  33. * THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #include <stdio.h>
  36. #include <string.h>
  37. #include <stdlib.h>
  38. #include <unistd.h>
  39. #include <errno.h>
  40. #include <signal.h>
  41. #include <pthread.h>
  42. #include <sys/types.h>
  43. #include <sys/socket.h>
  44. #include <sys/select.h>
  45. #include <sys/un.h>
  46. #include "../include/saAis.h"
  47. #include "../include/cfg.h"
  48. #include "../include/mar_gen.h"
  49. #include "../include/ipc_gen.h"
  50. #include "../include/ipc_cfg.h"
  51. #include "util.h"
  52. struct res_overlay {
  53. mar_res_header_t header;
  54. char data[4096];
  55. };
  56. /*
  57. * Data structure for instance data
  58. */
  59. struct cfg_instance {
  60. int response_fd;
  61. int dispatch_fd;
  62. OpenaisCfgCallbacksT callbacks;
  63. SaNameT compName;
  64. int compRegistered;
  65. int finalize;
  66. pthread_mutex_t response_mutex;
  67. pthread_mutex_t dispatch_mutex;
  68. };
  69. static void cfg_handleInstanceDestructor (void *);
  70. /*
  71. * All instances in one database
  72. */
  73. static struct saHandleDatabase cfg_hdb = {
  74. .handleCount = 0,
  75. .handles = 0,
  76. .mutex = PTHREAD_MUTEX_INITIALIZER,
  77. .handleInstanceDestructor = cfg_handleInstanceDestructor
  78. };
  79. /*
  80. * Implementation
  81. */
  82. void cfg_handleInstanceDestructor (void *instance)
  83. {
  84. struct cfg_instance *cfg_instance = instance;
  85. pthread_mutex_destroy (&cfg_instance->response_mutex);
  86. pthread_mutex_destroy (&cfg_instance->dispatch_mutex);
  87. }
  88. SaAisErrorT
  89. openais_cfg_initialize (
  90. openais_cfg_handle_t *cfg_handle,
  91. const OpenaisCfgCallbacksT *cfgCallbacks)
  92. {
  93. struct cfg_instance *cfg_instance;
  94. SaAisErrorT error = SA_AIS_OK;
  95. error = saHandleCreate (&cfg_hdb, sizeof (struct cfg_instance), cfg_handle);
  96. if (error != SA_AIS_OK) {
  97. goto error_no_destroy;
  98. }
  99. error = saHandleInstanceGet (&cfg_hdb, *cfg_handle, (void *)&cfg_instance);
  100. if (error != SA_AIS_OK) {
  101. goto error_destroy;
  102. }
  103. cfg_instance->response_fd = -1;
  104. cfg_instance->dispatch_fd = -1;
  105. error = saServiceConnect (&cfg_instance->response_fd,
  106. &cfg_instance->dispatch_fd, CFG_SERVICE);
  107. if (error != SA_AIS_OK) {
  108. goto error_put_destroy;
  109. }
  110. if (cfgCallbacks) {
  111. memcpy (&cfg_instance->callbacks, cfgCallbacks, sizeof (OpenaisCfgCallbacksT));
  112. }
  113. pthread_mutex_init (&cfg_instance->response_mutex, NULL);
  114. pthread_mutex_init (&cfg_instance->dispatch_mutex, NULL);
  115. saHandleInstancePut (&cfg_hdb, *cfg_handle);
  116. return (SA_AIS_OK);
  117. error_put_destroy:
  118. saHandleInstancePut (&cfg_hdb, *cfg_handle);
  119. error_destroy:
  120. saHandleDestroy (&cfg_hdb, *cfg_handle);
  121. error_no_destroy:
  122. return (error);
  123. }
  124. SaAisErrorT
  125. openais_cfg_fd_get (
  126. openais_cfg_handle_t cfg_handle,
  127. SaSelectionObjectT *selectionObject)
  128. {
  129. struct cfg_instance *cfg_instance;
  130. SaAisErrorT error;
  131. error = saHandleInstanceGet (&cfg_hdb, cfg_handle, (void *)&cfg_instance);
  132. if (error != SA_AIS_OK) {
  133. return (error);
  134. }
  135. *selectionObject = cfg_instance->dispatch_fd;
  136. saHandleInstancePut (&cfg_hdb, cfg_handle);
  137. return (SA_AIS_OK);
  138. }
  139. SaAisErrorT
  140. openais_cfg_dispatch (
  141. openais_cfg_handle_t cfg_handle,
  142. SaDispatchFlagsT dispatchFlags)
  143. {
  144. struct pollfd ufds;
  145. int timeout = -1;
  146. SaAisErrorT error;
  147. int cont = 1; /* always continue do loop except when set to 0 */
  148. int dispatch_avail;
  149. struct cfg_instance *cfg_instance;
  150. #ifdef COMPILE_OUT
  151. struct res_lib_openais_healthcheckcallback *res_lib_openais_healthcheckcallback;
  152. struct res_lib_openais_readinessstatesetcallback *res_lib_openais_readinessstatesetcallback;
  153. struct res_lib_openais_csisetcallback *res_lib_openais_csisetcallback;
  154. struct res_lib_openais_csiremovecallback *res_lib_openais_csiremovecallback;
  155. struct res_lib_cfg_statetrackcallback *res_lib_cfg_statetrackcallback;
  156. #endif
  157. OpenaisCfgCallbacksT callbacks;
  158. struct res_overlay dispatch_data;
  159. error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
  160. (void *)&cfg_instance);
  161. if (error != SA_AIS_OK) {
  162. return (error);
  163. }
  164. /*
  165. * Timeout instantly for SA_DISPATCH_ALL
  166. */
  167. if (dispatchFlags == SA_DISPATCH_ALL) {
  168. timeout = 0;
  169. }
  170. do {
  171. /*
  172. * Read data directly from socket
  173. */
  174. ufds.fd = cfg_instance->dispatch_fd;
  175. ufds.events = POLLIN;
  176. ufds.revents = 0;
  177. error = saPollRetry (&ufds, 1, timeout);
  178. if (error != SA_AIS_OK) {
  179. goto error_nounlock;
  180. }
  181. pthread_mutex_lock (&cfg_instance->dispatch_mutex);
  182. error = saPollRetry (&ufds, 1, 0);
  183. if (error != SA_AIS_OK) {
  184. goto error_nounlock;
  185. }
  186. /*
  187. * Handle has been finalized in another thread
  188. */
  189. if (cfg_instance->finalize == 1) {
  190. error = SA_AIS_OK;
  191. pthread_mutex_unlock (&cfg_instance->dispatch_mutex);
  192. goto error_unlock;
  193. }
  194. dispatch_avail = ufds.revents & POLLIN;
  195. if (dispatch_avail == 0 && dispatchFlags == SA_DISPATCH_ALL) {
  196. pthread_mutex_unlock (&cfg_instance->dispatch_mutex);
  197. break; /* exit do while cont is 1 loop */
  198. } else
  199. if (dispatch_avail == 0) {
  200. pthread_mutex_unlock (&cfg_instance->dispatch_mutex);
  201. continue; /* next poll */
  202. }
  203. if (ufds.revents & POLLIN) {
  204. /*
  205. * Queue empty, read response from socket
  206. */
  207. error = saRecvRetry (cfg_instance->dispatch_fd, &dispatch_data.header,
  208. sizeof (mar_res_header_t));
  209. if (error != SA_AIS_OK) {
  210. goto error_unlock;
  211. }
  212. if (dispatch_data.header.size > sizeof (mar_res_header_t)) {
  213. error = saRecvRetry (cfg_instance->dispatch_fd, &dispatch_data.data,
  214. dispatch_data.header.size - sizeof (mar_res_header_t));
  215. if (error != SA_AIS_OK) {
  216. goto error_unlock;
  217. }
  218. }
  219. } else {
  220. pthread_mutex_unlock (&cfg_instance->dispatch_mutex);
  221. continue;
  222. }
  223. /*
  224. * Make copy of callbacks, message data, unlock instance, and call callback
  225. * A risk of this dispatch method is that the callback routines may
  226. * operate at the same time that cfgFinalize has been called in another thread.
  227. */
  228. memcpy (&callbacks, &cfg_instance->callbacks, sizeof (OpenaisCfgCallbacksT));
  229. pthread_mutex_unlock (&cfg_instance->dispatch_mutex);
  230. /*
  231. * Dispatch incoming response
  232. */
  233. switch (dispatch_data.header.id) {
  234. default:
  235. error = SA_AIS_ERR_LIBRARY;
  236. goto error_nounlock;
  237. break;
  238. }
  239. /*
  240. * Determine if more messages should be processed
  241. */
  242. switch (dispatchFlags) {
  243. case SA_DISPATCH_ONE:
  244. cont = 0;
  245. break;
  246. case SA_DISPATCH_ALL:
  247. break;
  248. case SA_DISPATCH_BLOCKING:
  249. break;
  250. }
  251. } while (cont);
  252. error_unlock:
  253. saHandleInstancePut (&cfg_hdb, cfg_handle);
  254. error_nounlock:
  255. return (error);
  256. }
  257. SaAisErrorT
  258. openais_cfg_finalize (
  259. openais_cfg_handle_t cfg_handle)
  260. {
  261. struct cfg_instance *cfg_instance;
  262. SaAisErrorT error;
  263. error = saHandleInstanceGet (&cfg_hdb, cfg_handle, (void *)&cfg_instance);
  264. if (error != SA_AIS_OK) {
  265. return (error);
  266. }
  267. pthread_mutex_lock (&cfg_instance->dispatch_mutex);
  268. pthread_mutex_lock (&cfg_instance->response_mutex);
  269. /*
  270. * Another thread has already started finalizing
  271. */
  272. if (cfg_instance->finalize) {
  273. pthread_mutex_unlock (&cfg_instance->response_mutex);
  274. pthread_mutex_unlock (&cfg_instance->dispatch_mutex);
  275. saHandleInstancePut (&cfg_hdb, cfg_handle);
  276. return (SA_AIS_ERR_BAD_HANDLE);
  277. }
  278. cfg_instance->finalize = 1;
  279. pthread_mutex_unlock (&cfg_instance->response_mutex);
  280. pthread_mutex_unlock (&cfg_instance->dispatch_mutex);
  281. pthread_mutex_destroy (&cfg_instance->response_mutex);
  282. pthread_mutex_destroy (&cfg_instance->dispatch_mutex);
  283. saHandleDestroy (&cfg_hdb, cfg_handle);
  284. if (cfg_instance->response_fd != -1) {
  285. shutdown (cfg_instance->response_fd, 0);
  286. close (cfg_instance->response_fd);
  287. }
  288. if (cfg_instance->dispatch_fd != -1) {
  289. shutdown (cfg_instance->dispatch_fd, 0);
  290. close (cfg_instance->dispatch_fd);
  291. }
  292. saHandleInstancePut (&cfg_hdb, cfg_handle);
  293. return (error);
  294. }
  295. SaAisErrorT
  296. openais_cfg_ring_status_get (
  297. openais_cfg_handle_t cfg_handle,
  298. char ***interface_names,
  299. char ***status,
  300. unsigned int *interface_count)
  301. {
  302. struct cfg_instance *cfg_instance;
  303. struct req_lib_cfg_ringstatusget req_lib_cfg_ringstatusget;
  304. struct res_lib_cfg_ringstatusget res_lib_cfg_ringstatusget;
  305. unsigned int i;
  306. SaAisErrorT error;
  307. error = saHandleInstanceGet (&cfg_hdb, cfg_handle, (void *)&cfg_instance);
  308. if (error != SA_AIS_OK) {
  309. return (error);
  310. }
  311. req_lib_cfg_ringstatusget.header.size = sizeof (struct req_lib_cfg_ringstatusget);
  312. req_lib_cfg_ringstatusget.header.id = MESSAGE_REQ_CFG_RINGSTATUSGET;
  313. pthread_mutex_lock (&cfg_instance->response_mutex);
  314. error = saSendReceiveReply (cfg_instance->response_fd,
  315. &req_lib_cfg_ringstatusget,
  316. sizeof (struct req_lib_cfg_ringstatusget),
  317. &res_lib_cfg_ringstatusget,
  318. sizeof (struct res_lib_cfg_ringstatusget));
  319. pthread_mutex_unlock (&cfg_instance->response_mutex);
  320. *interface_count = res_lib_cfg_ringstatusget.interface_count;
  321. *interface_names = malloc (sizeof (char *) * *interface_count);
  322. if (*interface_names == NULL) {
  323. return (SA_AIS_ERR_NO_MEMORY);
  324. }
  325. memset (*interface_names, 0, sizeof (char *) * *interface_count);
  326. *status = malloc (sizeof (char *) * *interface_count);
  327. if (*status == NULL) {
  328. error = SA_AIS_ERR_NO_MEMORY;
  329. goto error_free_interface_names;
  330. }
  331. memset (*status, 0, sizeof (char *) * *interface_count);
  332. for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
  333. (*(interface_names))[i] = strdup (res_lib_cfg_ringstatusget.interface_name[i]);
  334. if ((*(interface_names))[i] == NULL) {
  335. error = SA_AIS_ERR_NO_MEMORY;
  336. goto error_free_contents;
  337. }
  338. (*(status))[i] = strdup (res_lib_cfg_ringstatusget.interface_status[i]);
  339. if ((*(status))[i] == NULL) {
  340. error = SA_AIS_ERR_NO_MEMORY;
  341. goto error_free_contents;
  342. }
  343. }
  344. goto no_error;
  345. error_free_contents:
  346. for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
  347. if ((*(interface_names))[i]) {
  348. free ((*(interface_names))[i]);
  349. }
  350. if ((*(status))[i]) {
  351. free ((*(status))[i]);
  352. }
  353. }
  354. free (*status);
  355. error_free_interface_names:
  356. free (*interface_names);
  357. no_error:
  358. saHandleInstancePut (&cfg_hdb, cfg_handle);
  359. return (error);
  360. }
  361. SaAisErrorT
  362. openais_cfg_ring_reenable (
  363. openais_cfg_handle_t cfg_handle)
  364. {
  365. struct cfg_instance *cfg_instance;
  366. struct req_lib_cfg_ringreenable req_lib_cfg_ringreenable;
  367. struct res_lib_cfg_ringreenable res_lib_cfg_ringreenable;
  368. SaAisErrorT error;
  369. error = saHandleInstanceGet (&cfg_hdb, cfg_handle, (void *)&cfg_instance);
  370. if (error != SA_AIS_OK) {
  371. return (error);
  372. }
  373. req_lib_cfg_ringreenable.header.size = sizeof (struct req_lib_cfg_ringreenable);
  374. req_lib_cfg_ringreenable.header.id = MESSAGE_REQ_CFG_RINGREENABLE;
  375. pthread_mutex_lock (&cfg_instance->response_mutex);
  376. error = saSendReceiveReply (cfg_instance->response_fd,
  377. &req_lib_cfg_ringreenable,
  378. sizeof (struct req_lib_cfg_ringreenable),
  379. &res_lib_cfg_ringreenable,
  380. sizeof (struct res_lib_cfg_ringreenable));
  381. pthread_mutex_unlock (&cfg_instance->response_mutex);
  382. saHandleInstancePut (&cfg_hdb, cfg_handle);
  383. return (error);
  384. }
  385. SaAisErrorT
  386. openais_cfg_state_track (
  387. openais_cfg_handle_t cfg_handle,
  388. SaUint8T trackFlags,
  389. const OpenaisCfgStateNotificationT *notificationBuffer)
  390. {
  391. struct cfg_instance *cfg_instance;
  392. struct req_lib_cfg_statetrack req_lib_cfg_statetrack;
  393. struct res_lib_cfg_statetrack res_lib_cfg_statetrack;
  394. SaAisErrorT error;
  395. req_lib_cfg_statetrack.header.size = sizeof (struct req_lib_cfg_statetrack);
  396. req_lib_cfg_statetrack.header.id = MESSAGE_REQ_CFG_STATETRACKSTART;
  397. req_lib_cfg_statetrack.trackFlags = trackFlags;
  398. req_lib_cfg_statetrack.notificationBufferAddress = (OpenaisCfgStateNotificationT *)notificationBuffer;
  399. error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
  400. (void *)&cfg_instance);
  401. if (error != SA_AIS_OK) {
  402. return (error);
  403. }
  404. pthread_mutex_lock (&cfg_instance->response_mutex);
  405. error = saSendReceiveReply (cfg_instance->response_fd,
  406. &req_lib_cfg_statetrack,
  407. sizeof (struct req_lib_cfg_statetrack),
  408. &res_lib_cfg_statetrack,
  409. sizeof (struct res_lib_cfg_statetrack));
  410. pthread_mutex_unlock (&cfg_instance->response_mutex);
  411. saHandleInstancePut (&cfg_hdb, cfg_handle);
  412. return (error == SA_AIS_OK ? res_lib_cfg_statetrack.header.error : error);
  413. }
  414. SaAisErrorT
  415. openais_cfg_state_track_stop (
  416. openais_cfg_handle_t cfg_handle)
  417. {
  418. struct cfg_instance *cfg_instance;
  419. struct req_lib_cfg_statetrackstop req_lib_cfg_statetrackstop;
  420. struct res_lib_cfg_statetrackstop res_lib_cfg_statetrackstop;
  421. SaAisErrorT error;
  422. error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
  423. (void *)&cfg_instance);
  424. if (error != SA_AIS_OK) {
  425. return (error);
  426. }
  427. req_lib_cfg_statetrackstop.header.size = sizeof (struct req_lib_cfg_statetrackstop);
  428. req_lib_cfg_statetrackstop.header.id = MESSAGE_REQ_CFG_STATETRACKSTOP;
  429. pthread_mutex_lock (&cfg_instance->response_mutex);
  430. error = saSendReceiveReply (cfg_instance->response_fd,
  431. &req_lib_cfg_statetrackstop,
  432. sizeof (struct req_lib_cfg_statetrackstop),
  433. &res_lib_cfg_statetrackstop,
  434. sizeof (struct res_lib_cfg_statetrackstop));
  435. pthread_mutex_unlock (&cfg_instance->response_mutex);
  436. saHandleInstancePut (&cfg_hdb, cfg_handle);
  437. return (error == SA_AIS_OK ? res_lib_cfg_statetrackstop.header.error : error);
  438. }
  439. SaAisErrorT
  440. openais_cfg_admin_state_get (
  441. openais_cfg_handle_t cfg_handle,
  442. OpenaisCfgAdministrativeTargetT administrativeTarget,
  443. OpenaisCfgAdministrativeStateT *administrativeState)
  444. {
  445. struct cfg_instance *cfg_instance;
  446. struct req_lib_cfg_administrativestateget req_lib_cfg_administrativestateget;
  447. struct res_lib_cfg_administrativestateget res_lib_cfg_administrativestateget;
  448. SaAisErrorT error;
  449. error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
  450. (void *)&cfg_instance);
  451. if (error != SA_AIS_OK) {
  452. return (error);
  453. }
  454. req_lib_cfg_administrativestateget.header.id = MESSAGE_REQ_CFG_ADMINISTRATIVESTATEGET;
  455. req_lib_cfg_administrativestateget.header.size = sizeof (struct req_lib_cfg_administrativestateget);
  456. req_lib_cfg_administrativestateget.administrativeTarget = administrativeTarget;
  457. error = saSendReceiveReply (cfg_instance->response_fd,
  458. &req_lib_cfg_administrativestateget,
  459. sizeof (struct req_lib_cfg_administrativestateget),
  460. &res_lib_cfg_administrativestateget,
  461. sizeof (struct res_lib_cfg_administrativestateget));
  462. error = res_lib_cfg_administrativestateget.header.error;
  463. pthread_mutex_unlock (&cfg_instance->response_mutex);
  464. saHandleInstancePut (&cfg_hdb, cfg_handle);
  465. return (error == SA_AIS_OK ? res_lib_cfg_administrativestateget.header.error : error);
  466. }
  467. SaAisErrorT
  468. openais_cfg_admin_state_set (
  469. openais_cfg_handle_t cfg_handle,
  470. OpenaisCfgAdministrativeTargetT administrativeTarget,
  471. OpenaisCfgAdministrativeStateT administrativeState)
  472. {
  473. struct cfg_instance *cfg_instance;
  474. struct req_lib_cfg_administrativestateset req_lib_cfg_administrativestateset;
  475. struct res_lib_cfg_administrativestateset res_lib_cfg_administrativestateset;
  476. SaAisErrorT error;
  477. error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
  478. (void *)&cfg_instance);
  479. if (error != SA_AIS_OK) {
  480. return (error);
  481. }
  482. req_lib_cfg_administrativestateset.header.id = MESSAGE_REQ_CFG_ADMINISTRATIVESTATEGET;
  483. req_lib_cfg_administrativestateset.header.size = sizeof (struct req_lib_cfg_administrativestateset);
  484. req_lib_cfg_administrativestateset.administrativeTarget = administrativeTarget;
  485. req_lib_cfg_administrativestateset.administrativeState = administrativeState;
  486. error = saSendReceiveReply (cfg_instance->response_fd,
  487. &req_lib_cfg_administrativestateset,
  488. sizeof (struct req_lib_cfg_administrativestateset),
  489. &res_lib_cfg_administrativestateset,
  490. sizeof (struct res_lib_cfg_administrativestateset));
  491. error = res_lib_cfg_administrativestateset.header.error;
  492. pthread_mutex_unlock (&cfg_instance->response_mutex);
  493. saHandleInstancePut (&cfg_hdb, cfg_handle);
  494. return (error == SA_AIS_OK ? res_lib_cfg_administrativestateset.header.error : error);
  495. }