testamf1.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /*
  2. * Copyright (c) 2002-2003 MontaVista Software, Inc.
  3. * Copyright (c) 2006 Ericsson AB.
  4. * Copyright (c) 2006 Sun Microsystems, Inc.
  5. *
  6. * All rights reserved.
  7. *
  8. * Author: Steven Dake (sdake@mvista.com)
  9. * Hans Feldt
  10. *
  11. * This software licensed under BSD license, the text of which follows:
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * - Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  22. * contributors may be used to endorse or promote products derived from this
  23. * software without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  29. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  30. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  32. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  33. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  35. * THE POSSIBILITY OF SUCH DAMAGE.
  36. */
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40. #include <errno.h>
  41. #include <signal.h>
  42. #include <unistd.h>
  43. #include <sys/types.h>
  44. #include <sys/socket.h>
  45. #include <sys/un.h>
  46. #include <sched.h>
  47. #include <sys/stat.h>
  48. #include <fcntl.h>
  49. #include <stdarg.h>
  50. #include "saAis.h"
  51. #include "saAmf.h"
  52. SaAmfHandleT handle;
  53. SaAmfHealthcheckKeyT keyAmfInvoked = {
  54. .key = "amfInvoked",
  55. .keyLen = 10
  56. };
  57. SaAmfHealthcheckKeyT keyCompInvoked = {
  58. .key = "compInvoked",
  59. .keyLen = 11
  60. };
  61. SaNameT compNameGlobal;
  62. int good_health = 0;
  63. int good_health_limit = 0;
  64. enum {
  65. FINALIZE = 0,
  66. UNREGISTER,
  67. ERROR_REPORT
  68. };
  69. #define die(format, args...) _die (__FILE__, __LINE__, format, ##args)
  70. static void _die (char *file, int line, char *format, ...) __attribute__((format(printf, 3, 4)));
  71. static void _die (char *file, int line, char *format, ...)
  72. {
  73. char buf[1024];
  74. va_list ap;
  75. sprintf (buf, "%d - %s:#%d - Error: '%s', exiting...\n",
  76. getpid(), file, line, format);
  77. va_start (ap, format);
  78. vfprintf (stderr, buf, ap);
  79. va_end(ap);
  80. exit (-1);
  81. }
  82. static void response (
  83. SaAmfHandleT handle, SaInvocationT invocation, SaAisErrorT error)
  84. {
  85. SaAisErrorT result;
  86. do {
  87. result = saAmfResponse (handle, invocation, error);
  88. if (result == SA_AIS_ERR_TRY_AGAIN) {
  89. fprintf(stderr, "%d: TRY_AGAIN received\n", getpid());
  90. usleep (100000);
  91. }
  92. } while (result == SA_AIS_ERR_TRY_AGAIN);
  93. if (result != SA_AIS_OK) {
  94. die ("saAmfResponse failed %d", result);
  95. }
  96. }
  97. void printSaNameT (SaNameT *name)
  98. {
  99. int i;
  100. for (i = 0; i < name->length; i++) {
  101. printf ("%c", name->value[i]);
  102. }
  103. }
  104. void setSanameT (SaNameT *name, char *str) {
  105. name->length = strlen (str);
  106. memcpy (name->value, str, name->length);
  107. }
  108. static unsigned int healthcheck_no = 0;
  109. int stop = 0;
  110. void HealthcheckCallback (SaInvocationT invocation,
  111. const SaNameT *compName,
  112. SaAmfHealthcheckKeyT *healthcheckKey)
  113. {
  114. SaAisErrorT res;
  115. if( !good_health && healthcheck_no++);
  116. if (healthcheck_no == good_health_limit ) {
  117. response (handle, invocation, SA_AIS_OK);
  118. res = saAmfHealthcheckStop (handle,
  119. &compNameGlobal,
  120. &keyAmfInvoked);
  121. printf ("healthcheck stop result %d (should be %d)\n", res, SA_AIS_OK);
  122. printf ("COMPONENT REPORTING ERROR %s\n", compNameGlobal.value);
  123. saAmfComponentErrorReport (handle, compName, 0, SA_AMF_COMPONENT_RESTART, 0);
  124. printf ("COMPONENT DONE REPORTING ERROR\n");
  125. } else {
  126. response (handle, invocation, SA_AIS_OK);
  127. }
  128. }
  129. void ComponentTerminateCallback (
  130. SaInvocationT invocation,
  131. const SaNameT *compName)
  132. {
  133. printf ("ComponentTerminateCallback\n");
  134. response (handle, invocation, SA_AIS_OK);
  135. exit (0);
  136. }
  137. #if 0
  138. #include <sys/time.h>
  139. #define TRU "%d"
  140. #define TRS "%s"
  141. #define TR(format,x) do { \
  142. struct timeval t;\
  143. gettimeofday(&t,NULL); \
  144. printf("%s:%d: %s : %d : %u: %u :%s : " format "\n",\
  145. __FILE__,__LINE__,__FUNCTION__, \
  146. (int)getpid(),(int)t.tv_sec, (int)t.tv_usec,#x,x); \
  147. }while(0)
  148. #else
  149. #define TRU "%d"
  150. #define TRS "%s"
  151. #define TR(format,x)
  152. #endif
  153. void CSISetCallback (
  154. SaInvocationT invocation,
  155. const SaNameT *compName,
  156. SaAmfHAStateT haState,
  157. SaAmfCSIDescriptorT *csiDescriptor)
  158. {
  159. SaAmfHAStateT state;
  160. int res;
  161. int i;
  162. switch (haState) {
  163. case SA_AMF_HA_ACTIVE:
  164. printf ("%d: Component '%s' requested to enter hastate SA_AMF_ACTIVE"
  165. " for \n\tCSI '%s'\n",
  166. (int)getpid(), compName->value, csiDescriptor->csiName.value);
  167. response (handle, invocation, SA_AIS_OK);
  168. res = saAmfHAStateGet (handle, compName, &csiDescriptor->csiName, &state);
  169. if (res != SA_AIS_OK || haState != state) {
  170. fprintf (stderr, "saAmfHAStateGet failed: %d\n", res);
  171. exit (-1);
  172. }
  173. TR(TRU, csiDescriptor->csiAttr.number);
  174. for(i=0; i<csiDescriptor->csiAttr.number; i++) {
  175. if( strcmp((char*)csiDescriptor->csiAttr.attr[i].attrName, "good_health_limit") == 0){
  176. good_health = strcmp((char*)csiDescriptor->csiAttr.attr[i].attrValue, "0") ? 0 : 1;
  177. good_health_limit = atoi((char*)csiDescriptor->csiAttr.attr[i].attrValue);
  178. }
  179. #if 0
  180. TR(TRS,csiDescriptor->csiAttr.attr[i].attrName);
  181. TR(TRS, csiDescriptor->csiAttr.attr[i].attrValue);
  182. #endif
  183. }
  184. TR(TRU, csiDescriptor->csiFlags);
  185. printSaNameT((SaNameT*) &csiDescriptor->csiStateDescriptor.activeDescriptor.activeCompName);
  186. TR(TRU, csiDescriptor->csiStateDescriptor.activeDescriptor.transitionDescriptor);
  187. break;
  188. case SA_AMF_HA_STANDBY:
  189. printf ("%d: Component '%s' requested to enter hastate SA_AMF_STANDBY "
  190. "for \n\tCSI '%s'\n",
  191. (int)getpid(), compName->value, csiDescriptor->csiName.value);
  192. response (handle, invocation, SA_AIS_OK);
  193. TR(TRU,csiDescriptor->csiAttr.number);
  194. for(i=0; i<csiDescriptor->csiAttr.number; i++) {
  195. if(!strcmp((char*)csiDescriptor->csiAttr.attr[i].attrName, "good_health") &&
  196. !strcmp((char*)csiDescriptor->csiAttr.attr[i].attrValue, "true")){
  197. good_health = 1;
  198. }
  199. TR(TRS,csiDescriptor->csiAttr.attr[i].attrName);
  200. TR(TRS,csiDescriptor->csiAttr.attr[i].attrValue);
  201. }
  202. TR(TRU,csiDescriptor->csiFlags);
  203. printSaNameT((SaNameT*) &csiDescriptor->csiStateDescriptor.standbyDescriptor.activeCompName);
  204. TR(TRU,csiDescriptor->csiStateDescriptor.standbyDescriptor.standbyRank);
  205. break;
  206. case SA_AMF_HA_QUIESCED:
  207. printf ("%d: Component '%s' requested to enter hastate SA_AMF_HA_QUIESCED "
  208. "for \n\tCSI '%s'\n",
  209. (int)getpid(), compName->value, csiDescriptor->csiName.value);
  210. response (handle, invocation, SA_AIS_OK);
  211. break;
  212. case SA_AMF_HA_QUIESCING:
  213. break;
  214. default:
  215. break;
  216. }
  217. }
  218. void CSIRemoveCallback (
  219. SaInvocationT invocation,
  220. const SaNameT *compName,
  221. const SaNameT *csiName,
  222. SaAmfCSIFlagsT csiFlags)
  223. {
  224. printf ("CSIRemoveCallback for component '");
  225. printSaNameT ((SaNameT *)compName);
  226. printf ("' in CSI '");
  227. printSaNameT ((SaNameT *)csiName);
  228. printf ("'\n");
  229. response (handle, invocation, SA_AIS_OK);
  230. }
  231. #ifdef COMPILE_OUT
  232. void ProtectionGroupTrackCallback (
  233. const SaNameT *csiName,
  234. SaAmfProtectionGroupNotificationT *notificationBuffer,
  235. SaUint32T numberOfItems,
  236. SaUint32T numberOfMembers,
  237. SaAisErrorT error)
  238. {
  239. int i;
  240. printf ("ProtectionGroupTrackCallback items %d members %d\n", (int)numberOfItems, (int)numberOfMembers);
  241. printf ("buffer is %p\n", notificationBuffer);
  242. for (i = 0; i < numberOfItems; i++) {
  243. printf ("component name");
  244. printSaNameT (&notificationBuffer[i].member.compName);
  245. printf ("\n");
  246. printf ("\treadiness state is %d\n", notificationBuffer[i].member.readinessState);
  247. printf ("\thastate %d\n", notificationBuffer[i].member.haState);
  248. printf ("\tchange is %d\n", notificationBuffer[i].change);
  249. }
  250. }
  251. #endif
  252. SaAmfCallbacksT amfCallbacks = {
  253. .saAmfHealthcheckCallback = HealthcheckCallback,
  254. .saAmfComponentTerminateCallback = ComponentTerminateCallback,
  255. .saAmfCSISetCallback = CSISetCallback,
  256. .saAmfCSIRemoveCallback = CSIRemoveCallback,
  257. };
  258. SaAmfCallbacksT amfCallbacks;
  259. SaVersionT version = { 'B', 1, 1 };
  260. #if ! defined(TS_CLASS) && (defined(OPENAIS_BSD) || defined(OPENAIS_LINUX) || defined(OPENAIS_SOLARIS))
  261. static struct sched_param sched_param;
  262. #endif
  263. void sigintr_handler (int signum) {
  264. stop = FINALIZE;
  265. }
  266. void sigusr1_handler (int signum) {
  267. stop = UNREGISTER;
  268. }
  269. void sigusr2_handler (int signum) {
  270. stop = ERROR_REPORT;
  271. }
  272. void write_pid (void) {
  273. char pid[256];
  274. char filename[256];
  275. int fd;
  276. int res;
  277. sprintf (filename, "/var/run/openais_cleanup_%s", compNameGlobal.value);
  278. fd = open (filename, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
  279. if (fd == -1) {
  280. printf("%d: Failed using /var/run for pid file, using /tmp\n", (int)getpid());
  281. sprintf (filename, "/tmp/openais_cleanup_%s", compNameGlobal.value);
  282. fd = open (filename, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
  283. }
  284. sprintf (pid, "%d", (int)getpid());
  285. res = write (fd, pid, strlen (pid));
  286. close (fd);
  287. }
  288. static SaSelectionObjectT comp_init ()
  289. {
  290. char *name;
  291. char *env;
  292. int result;
  293. SaSelectionObjectT select_fd;
  294. name = getenv ("SA_AMF_COMPONENT_NAME");
  295. if (name == NULL) {
  296. die ("SA_AMF_COMPONENT_NAME missing");
  297. }
  298. if (strstr (name, "safComp=") == NULL ||
  299. strstr (name, "safSu=") == NULL ||
  300. strstr (name, "safSg=") == NULL ||
  301. strstr (name, "safApp=") == NULL) {
  302. die ("SA_AMF_COMPONENT_NAME value wrong");
  303. }
  304. printf("%d: Hello world from %s\n", (int)getpid(), name);
  305. env = getenv ("var1");
  306. if (env == NULL) {
  307. die ("var1 missing");
  308. }
  309. if (strcmp (env, "val1") != 0) {
  310. die ("var1 value wrong");
  311. }
  312. env = getenv ("var2");
  313. if (env == NULL) {
  314. die ("var2 wrong");
  315. }
  316. if (strcmp (env, "val2") != 0) {
  317. die ("var2 value wrong");
  318. }
  319. signal (SIGINT, sigintr_handler);
  320. signal (SIGUSR1, sigusr1_handler);
  321. signal (SIGUSR2, sigusr2_handler);
  322. #if ! defined(TS_CLASS) && (defined(OPENAIS_BSD) || defined(OPENAIS_LINUX) || defined(OPENAIS_SOLARIS))
  323. sched_param.sched_priority = sched_get_priority_max(SCHED_RR);
  324. if (sched_param.sched_priority == -1) {
  325. fprintf (stderr, "%d: couldn't retrieve the maximum scheduling " \
  326. "priority supported by the Round-Robin class (%s)\n",
  327. (int)getpid(), strerror(errno));
  328. } else {
  329. result = sched_setscheduler (0, SCHED_RR, &sched_param);
  330. if (result == -1) {
  331. fprintf (stderr, "%d: couldn't set sched priority (%s)\n",
  332. (int)getpid(), strerror(errno));
  333. }
  334. }
  335. #endif
  336. do {
  337. result = saAmfInitialize (&handle, &amfCallbacks, &version);
  338. if (result == SA_AIS_ERR_TRY_AGAIN) {
  339. printf("%d: TRY_AGAIN received\n", getpid());
  340. usleep (100000);
  341. }
  342. } while (result == SA_AIS_ERR_TRY_AGAIN);
  343. if (result != SA_AIS_OK) {
  344. die ("saAmfInitialize result is %d", result);
  345. }
  346. do {
  347. result = saAmfSelectionObjectGet (handle, &select_fd);
  348. if (result == SA_AIS_ERR_TRY_AGAIN) {
  349. printf("%d: TRY_AGAIN received\n", getpid());
  350. usleep (100000);
  351. }
  352. } while (result == SA_AIS_ERR_TRY_AGAIN);
  353. if (result != SA_AIS_OK) {
  354. die ("saAmfSelectionObjectGet failed %d", result);
  355. }
  356. do {
  357. result = saAmfComponentNameGet (handle, &compNameGlobal);
  358. if (result == SA_AIS_ERR_TRY_AGAIN) {
  359. printf("%d: TRY_AGAIN received\n", getpid());
  360. usleep (100000);
  361. }
  362. } while (result == SA_AIS_ERR_TRY_AGAIN);
  363. if (result != SA_AIS_OK) {
  364. die ("saAmfComponentNameGet failed %d", result);
  365. }
  366. write_pid ();
  367. do {
  368. result = saAmfHealthcheckStart (handle,
  369. &compNameGlobal,
  370. &keyAmfInvoked,
  371. SA_AMF_HEALTHCHECK_AMF_INVOKED,
  372. SA_AMF_COMPONENT_FAILOVER);
  373. if (result == SA_AIS_ERR_TRY_AGAIN) {
  374. printf("%d: TRY_AGAIN received\n", getpid());
  375. usleep (100000);
  376. }
  377. } while (result == SA_AIS_ERR_TRY_AGAIN);
  378. if (result != SA_AIS_OK) {
  379. die ("saAmfHealthcheckStart failed %d", result);
  380. }
  381. do {
  382. result = saAmfHealthcheckStart (handle,
  383. &compNameGlobal,
  384. &keyCompInvoked,
  385. SA_AMF_HEALTHCHECK_COMPONENT_INVOKED,
  386. SA_AMF_COMPONENT_FAILOVER);
  387. if (result == SA_AIS_ERR_TRY_AGAIN) {
  388. printf("%d: TRY_AGAIN received\n", getpid());
  389. usleep (100000);
  390. }
  391. } while (result == SA_AIS_ERR_TRY_AGAIN);
  392. if (result != SA_AIS_OK) {
  393. die ("saAmfHealthcheckStart failed %d", result);
  394. }
  395. {
  396. SaNameT badname;
  397. strcpy ((char*)badname.value, "badname");
  398. badname.length = 7;
  399. do {
  400. result = saAmfComponentRegister (handle, &badname, NULL);
  401. if (result == SA_AIS_ERR_TRY_AGAIN) {
  402. printf("%d: TRY_AGAIN received\n", getpid());
  403. usleep (100000);
  404. }
  405. } while (result == SA_AIS_ERR_TRY_AGAIN);
  406. if (result != SA_AIS_ERR_INVALID_PARAM) {
  407. die ("saAmfComponentRegister failed %d", result);
  408. }
  409. }
  410. do {
  411. result = saAmfComponentRegister (handle, &compNameGlobal, NULL);
  412. if (result == SA_AIS_ERR_TRY_AGAIN) {
  413. printf("%d: TRY_AGAIN received\n", getpid());
  414. usleep (100000);
  415. }
  416. } while (result == SA_AIS_ERR_TRY_AGAIN);
  417. if (result != SA_AIS_OK) {
  418. die ("saAmfComponentRegister failed %d", result);
  419. }
  420. /*
  421. * Test already started healthcheck
  422. */
  423. do {
  424. result = saAmfHealthcheckStart (handle,
  425. &compNameGlobal,
  426. &keyAmfInvoked,
  427. SA_AMF_HEALTHCHECK_AMF_INVOKED,
  428. SA_AMF_COMPONENT_FAILOVER);
  429. if (result == SA_AIS_ERR_TRY_AGAIN) {
  430. printf("%d: TRY_AGAIN received\n", getpid());
  431. usleep (100000);
  432. }
  433. } while (result == SA_AIS_ERR_TRY_AGAIN);
  434. if (result != SA_AIS_ERR_EXIST) {
  435. die ("saAmfHealthcheckStart failed %d", result);
  436. }
  437. return select_fd;
  438. }
  439. static void handle_intr (void)
  440. {
  441. SaAisErrorT result;
  442. switch (stop) {
  443. case FINALIZE:
  444. result = saAmfFinalize (handle);
  445. if (result != SA_AIS_OK) {
  446. die ("saAmfFinalize failed %d", result);
  447. }
  448. fprintf(stderr, "%d: %s exiting\n",
  449. getpid(), compNameGlobal.value);
  450. exit (EXIT_SUCCESS);
  451. break;
  452. case UNREGISTER:
  453. fprintf(stderr, "%d: %s unregistering\n",
  454. getpid(), compNameGlobal.value);
  455. result = saAmfComponentUnregister (
  456. handle, &compNameGlobal, NULL);
  457. if (result != SA_AIS_OK) {
  458. die ("saAmfComponentUnregister failed %d", result);
  459. }
  460. fprintf(stderr, "%d: waiting after unregister\n", getpid());
  461. while (1) {
  462. sleep (100000000);
  463. }
  464. break;
  465. case ERROR_REPORT:
  466. fprintf(stderr, "%d: %s error reporting\n",
  467. getpid(), compNameGlobal.value);
  468. result = saAmfComponentErrorReport (
  469. handle, &compNameGlobal, 0, SA_AMF_COMPONENT_RESTART, 0);
  470. if (result != SA_AIS_OK) {
  471. die ("saAmfComponentErrorReport failed %d", result);
  472. }
  473. fprintf(stderr, "%d: waiting after error report\n", getpid());
  474. while (1) {
  475. sleep (100000000);
  476. }
  477. break;
  478. default:
  479. die ("unknown %d", stop);
  480. break;
  481. }
  482. }
  483. int main (int argc, char **argv)
  484. {
  485. int result;
  486. SaSelectionObjectT select_fd;
  487. fd_set read_fds;
  488. struct timeval tv;
  489. select_fd = comp_init();
  490. FD_ZERO (&read_fds);
  491. do {
  492. tv.tv_sec = 2; /* related to value in amf.conf! */
  493. tv.tv_usec = 0;
  494. FD_SET (select_fd, &read_fds);
  495. result = select (select_fd + 1, &read_fds, 0, 0, &tv);
  496. if (result == -1) {
  497. if (errno == EINTR) {
  498. handle_intr ();
  499. } else {
  500. die ("select failed - %s", strerror (errno));
  501. }
  502. } else if (result > 0) {
  503. do {
  504. result = saAmfDispatch (handle, SA_DISPATCH_ALL);
  505. if (result == SA_AIS_ERR_TRY_AGAIN) {
  506. fprintf(stderr, "%d: TRY_AGAIN received\n", getpid());
  507. usleep (100000);
  508. }
  509. } while (result == SA_AIS_ERR_TRY_AGAIN);
  510. if (result != SA_AIS_OK) {
  511. die ("saAmfDispatch failed %d", result);
  512. }
  513. } else {
  514. /* timeout */
  515. do {
  516. result = saAmfHealthcheckConfirm (handle, &compNameGlobal,
  517. &keyCompInvoked, SA_AIS_OK);
  518. if (result == SA_AIS_ERR_TRY_AGAIN) {
  519. fprintf(stderr, "%d: TRY_AGAIN received\n", getpid());
  520. usleep (100000);
  521. }
  522. } while (result == SA_AIS_ERR_TRY_AGAIN);
  523. if (result != SA_AIS_OK) {
  524. die ("saAmfHealthcheckConfirm failed %d", result);
  525. }
  526. }
  527. } while (stop == 0);
  528. fprintf(stderr, "%d: exiting...\n", getpid());
  529. exit (EXIT_SUCCESS);
  530. }