1 karl 1.6 //%2006////////////////////////////////////////////////////////////////////////
|
2 kumpf 1.1 //
|
3 karl 1.3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 kumpf 1.1 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.3 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.4 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.6 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 kumpf 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
33 //
34 kumpf 1.1 // Modified By:
35 //
36 //%/////////////////////////////////////////////////////////////////////////////
37
|
38 kumpf 1.2 #include <string.h> // for memcpy()
|
39 kumpf 1.1 #include <Pegasus/Common/Tracer.h>
40
41 #include "CIMOMHandleRep.h"
42
43 PEGASUS_NAMESPACE_BEGIN
44
45 CIMOMHandleRep::CIMOMHandleRep()
46 : _pendingOperations(0),
47 _providerUnloadProtect(0)
48 {
49 gettimeofday(&_idleTime, NULL);
50 }
51
52 CIMOMHandleRep::~CIMOMHandleRep()
53 {
54 }
55
56 void CIMOMHandleRep::disallowProviderUnload()
57 {
58 PEG_METHOD_ENTER(TRC_CIMOM_HANDLE,
59 "CIMOMHandleRep::disallowProviderUnload");
60 kumpf 1.1
61 try
62 {
63 AutoMutex lock(_providerUnloadProtectMutex);
64 _providerUnloadProtect++;
65 }
66 catch (...)
67 {
68 // There's not much a provider could do with this exception. Since
69 // this is just a hint, our best bet is to just ignore it.
70 PEG_TRACE_STRING(TRC_CIMOM_HANDLE, Tracer::LEVEL3,
71 "Caught unexpected exception");
72 }
73
74 PEG_METHOD_EXIT();
75 }
76
77 void CIMOMHandleRep::allowProviderUnload()
78 {
79 PEG_METHOD_ENTER(TRC_CIMOM_HANDLE,
80 "CIMOMHandleRep::allowProviderUnload");
81 kumpf 1.1
82 try
83 {
84 AutoMutex lock(_providerUnloadProtectMutex);
85 if (_providerUnloadProtect > 0)
86 {
87 _providerUnloadProtect--;
88 }
89 }
90 catch (...)
91 {
92 // There's not much a provider could do with this exception. Since
93 // this is just a hint, our best bet is to just ignore it.
94 PEG_TRACE_STRING(TRC_CIMOM_HANDLE, Tracer::LEVEL3,
95 "Caught unexpected exception");
96 }
97
98 PEG_METHOD_EXIT();
99 }
100
101 void CIMOMHandleRep::get_idle_timer(struct timeval *tv)
102 kumpf 1.1 {
103 if (tv == 0)
104 {
105 return;
106 }
107
108 try
109 {
110 AutoMutex lock(_idleTimeMutex);
111 memcpy(tv, &_idleTime, sizeof(struct timeval));
112 }
113 catch (...)
114 {
115 gettimeofday(tv, NULL);
116 }
117 }
118
119 void CIMOMHandleRep::update_idle_timer()
120 {
121 try
122 {
123 kumpf 1.1 AutoMutex lock(_idleTimeMutex);
124 gettimeofday(&_idleTime, NULL);
125 }
126 catch (...)
127 {
128 }
129 }
130
131 Boolean CIMOMHandleRep::pending_operation()
132 {
|
133 mike 1.5 if (_pendingOperations.get())
|
134 kumpf 1.1 {
135 return true;
136 }
137 return false;
138 }
139
140 Boolean CIMOMHandleRep::unload_ok()
141 {
|
142 mike 1.5 if (_pendingOperations.get())
|
143 kumpf 1.1 {
144 return false;
145 }
146
147 Boolean unloadable = true;
148
149 AutoMutex lock(_providerUnloadProtectMutex);
150 if (_providerUnloadProtect > 0)
151 {
152 unloadable = false;
153 }
154
155 return (unloadable);
156 }
157
158 PEGASUS_NAMESPACE_END
|