1 thilo.boehm 1.1 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 thilo.boehm 1.1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //////////////////////////////////////////////////////////////////////////
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef WaitForTCPIP_zOS_h
33 #define WaitForTCPIP_zOS_h
34
35 #include <errno.h>
36 #include <unistd.h>
37
38 PEGASUS_NAMESPACE_BEGIN
39
40 /**
41 * Check if the TCP/IP stack is available.
42 * And if not, wait 30 seconds and try again.
43 thilo.boehm 1.1 *
44 */
45
46 void startupWaitForTCPIP( void )
47 {
48
49 bool sendTcpipMsg = true;
50 int rc;
51 char hostname[PEGASUS_MAXHOSTNAMELEN + 1];
52
53 while(1)
54 {
55 rc = 0;
56 hostname[0] = 0;
57 rc = gethostname(hostname, sizeof(hostname));
58
59 if (rc == 0)
60 {
61 // The gethostname was successful.
62 return;
63
64 thilo.boehm 1.1 }
65
66 // Resource Temporarily unavailable.
67 if (errno == EAGAIN)
68 {
69 // The program should wait for transport layer to become ready.
70 if (sendTcpipMsg)
71 {
72 Logger::put_l(
73 Logger::STANDARD_LOG,System::CIMSERVER,Logger::INFORMATION,
74 MessageLoaderParms(
75 "src.Service.WaitForTCPIP_zOS.WAIT_FOR_TCPIP",
76 "CIM server startup delayed, "
77 "waiting for TCP/IP to start."));
78 sendTcpipMsg = false;
79 }
80 System::sleep(30);
81 }
82 else
83 {
84 Logger::put_l(
85 thilo.boehm 1.1 Logger::ERROR_LOG, System::CIMSERVER, Logger::FATAL,
86 MessageLoaderParms(
87 "src.Service.WaitForTCPIP_zOS.GETHOSTNAME_FAILED",
88 "Stopping CIM Server startup. "
89 "Failed to retrieve system's hostname: $0",
90 PEGASUS_SYSTEM_NETWORK_ERRORMSG_NLS));
91 exit(1);
92 }
93 }
94 };
95
96
97 PEGASUS_NAMESPACE_END
98
99 #endif
100
101
|