(file) Return to AsyncOpNode.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 karl  1.42 //%2006////////////////////////////////////////////////////////////////////////
  2 mike  1.2  //
  3 karl  1.35 // 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 karl  1.33 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.35 // 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.39 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.42 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 mike  1.2  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15 chip  1.21 // 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 mike  1.2  // 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 kumpf 1.26 // 
 21 chip  1.21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 mike  1.2  // 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 chip  1.21 // 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 mike  1.2  // 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: Mike Day (mdday@us.ibm.com)
 33            //
 34 a.arora 1.34 // Modified By:  Amit K Arora, IBM (amita@in.ibm.com) for Bug#1188
 35 david.dillard 1.38 //               David Dillard, VERITAS Software Corp.
 36                    //                   (david.dillard@veritas.com)
 37 gs.keenan     1.40 //		 Sean Keenan (sean.keenan@hp.com)
 38 mike          1.2  //
 39                    //%/////////////////////////////////////////////////////////////////////////////
 40                    
 41                    #include <Pegasus/Common/AsyncOpNode.h>
 42 kumpf         1.30 #include <Pegasus/Common/InternalException.h>
 43 mike          1.2  
 44 gs.keenan     1.40 #if defined(PEGASUS_OS_VMS)
 45                    #include <stdio.h>
 46                    #endif
 47                    
 48 mike          1.2  PEGASUS_NAMESPACE_BEGIN
 49 chip          1.21 
 50 david.dillard 1.41 #if defined(PEGASUS_COMPILER_MSVC)
 51 kumpf         1.28 #define snprintf _snprintf
 52                    #endif
 53                    
 54 mday          1.32 // AsyncOpNode * AsyncOpNode::_headOfFreeList;
 55                    // const int AsyncOpNode::BLOCK_SIZE = 200;
 56                    // Mutex AsyncOpNode::_alloc_mut;
 57 mday          1.19 
 58 mday          1.32 // void * AsyncOpNode::operator new(size_t size)
 59                    // {
 60                    //    if(size != sizeof(AsyncOpNode))
 61                    //       return :: operator new(size);
 62 chip          1.21 
 63 mday          1.32 //    _alloc_mut.lock(pegasus_thread_self());
 64 chip          1.21 
 65 mday          1.32 //    AsyncOpNode *node = _headOfFreeList;
 66                    //    if(node)
 67                    //       _headOfFreeList = node->_parent;
 68                    //    else
 69                    //    {
 70                    //       AsyncOpNode * newBlock =
 71                    // 	 reinterpret_cast<AsyncOpNode *>(::operator new( BLOCK_SIZE * sizeof(AsyncOpNode)));
 72                    //       int i;
 73                    //       for( i = 1; i < BLOCK_SIZE - 1; ++i)
 74                    // 	 newBlock[i]._parent = &newBlock[i + 1];
 75                    //       newBlock[BLOCK_SIZE - 1]._parent = NULL;
 76                    //       node = newBlock;
 77                    //       _headOfFreeList = &newBlock[1];
 78                    //    }
 79                    //    _alloc_mut.unlock();
 80                    //    return node;
 81                    // }
 82 mday          1.19 
 83 mday          1.32 // void AsyncOpNode::operator delete(void *dead, size_t size)
 84                    // {
 85 mday          1.19 
 86 mday          1.32 //    if(dead == 0)
 87                    //       return;
 88                    //    if(size != sizeof(AsyncOpNode))
 89                    //    {
 90                    //       ::operator delete(dead);
 91                    //       return;
 92                    //    }
 93                    //    AsyncOpNode *node = reinterpret_cast<AsyncOpNode *>(dead);
 94                    //    _alloc_mut.lock(pegasus_thread_self());
 95                    //    node->_parent = _headOfFreeList;
 96                    //    _headOfFreeList = node;
 97                    //    _alloc_mut.unlock();
 98                    // }
 99 mday          1.19 
100                    
101 chip          1.21 AsyncOpNode::AsyncOpNode(void)
102 mike          1.42.12.1    : _client_sem(0), _request(), _response(),
103 mday          1.12           _state(0), _flags(0), _offered_count(0), _total_ops(0), _completed_ops(0),
104 mday          1.14           _user_data(0), _completion_code(0), _op_dest(0),
105 mike          1.42.12.1      _parent(0), _children(), _async_callback(0),__async_callback(0),
106 chip          1.21           _callback_node(0), _callback_response_q(0),
107                              _callback_ptr(0), _callback_parameter(0),
108                              _callback_handle(0), _callback_notify(0), _callback_request_q(0)
109 mike          1.2       {
110 mday          1.4          gettimeofday(&_start, NULL);
111 mike          1.2          memset(&_lifetime, 0x00, sizeof(struct timeval));
112                            memset(&_updated, 0x00, sizeof(struct timeval));
113 mday          1.10          _timeout_interval.tv_sec = 60;
114 mday          1.7          _timeout_interval.tv_usec = 100;
115 mike          1.2       }
116 chip          1.21      
117 mike          1.2       AsyncOpNode::~AsyncOpNode(void)
118                         {
119 mike          1.42.12.1    _request.clear();
120                            _response.clear();
121 chip          1.21      }
122                         
123 mike          1.42.12.1 void AsyncOpNode::_reset(List<AsyncOpNode,NullLock> *dst_q)
124 mike          1.2       {
125 mike          1.42.12.1    AsyncOpNode *child = _children.remove_front();
126 mike          1.2          while( child != 0 )
127                            {
128                               child->_reset(dst_q);
129 mike          1.42.12.1       child = _children.remove_front();
130 mike          1.2          }
131                         
132                            _parent = 0;
133 mike          1.42.12.1    _request.clear();
134                            _response.clear();
135 chip          1.21      
136                            //_operation_list.reset();
137                            _state = 0;
138                            _flags = 0;
139 mday          1.12         _offered_count = 0;
140 mike          1.2          _total_ops = 0;
141                            _completed_ops = 0;
142 mday          1.12         _user_data = 0;
143                            _completion_code = 0;
144 mday          1.14         _op_dest = 0;
145 mday          1.13         _async_callback = 0;
146 mday          1.19         __async_callback = 0;
147 mday          1.14         _callback_node =0;
148 chip          1.21         _callback_response_q = 0;
149 mday          1.14         _callback_ptr=0;
150 mday          1.19         _callback_parameter = 0;
151                            _callback_handle = 0;
152                            _callback_notify = 0;
153 mday          1.17         _callback_request_q = 0;
154 mike          1.42.12.1    dst_q->insert_front(this);
155 mday          1.5          while ( _client_sem.count() )
156                               _client_sem.wait();
157                            PEGASUS_ASSERT( _client_sem.count() == 0 );
158 chip          1.21      
159 mike          1.2          return;
160                         }
161                         
162 david.dillard 1.38      void AsyncOpNode::print_to_buffer(char **buf)
163 mday          1.27      {
164                            if(buf == NULL)
165                               return;
166                            
167 sage          1.29      #if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
168 david.dillard 1.36         char work_buf[512];
169 david.dillard 1.37         snprintf(work_buf, sizeof(work_buf), "AsyncOpNode %p\n" \
170 mday          1.27      	    "\trq %d; rp %d; state %d; flags %d; op_dst q %p\n" \
171                         	    "\tcallback node %p; callback rp q %p; callback ptr %p\n" \
172                         	    "\tcallback parm %p; callback handle %p; callback notify %p\n" \
173                         	    "\tcallback rq q %p; service %p; thread %p\n\n",
174 mike          1.42.12.1 	    this, _request.size(), _response.size(), 
175 mday          1.27      	    _state, _flags, _op_dest, _callback_node, _callback_response_q,
176                         	    _callback_ptr, _callback_parameter, _callback_handle, _callback_notify,
177                         	    _callback_request_q, _service_ptr, _thread_ptr);
178                            *buf = strdup(work_buf);
179 sage          1.29      #endif
180 mday          1.27         return;
181                            
182                         }
183                         
184 a.arora       1.34      String AsyncOpNode::print_to_string(void)
185 mday          1.27      {
186 david.dillard 1.36         char work_buf[512];
187 sage          1.29      #if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
188 david.dillard 1.37         snprintf(work_buf, sizeof(work_buf), "AsyncOpNode %p\n" \
189 mday          1.27      	    "\trq %d; rp %d; state %d; flags %d; op_dst q %p\n" \
190                         	    "\tcallback node %p; callback rp q %p; callback ptr %p\n" \
191                         	    "\tcallback parm %p; callback handle %p; callback notify %p\n" \
192                         	    "\tcallback rq q %p; service %p; thread %p\n\n",
193 mike          1.42.12.1 	    this, _request.size(), _response.size(), 
194 mday          1.27      	    _state, _flags, _op_dest, _callback_node, _callback_response_q,
195                         	    _callback_ptr, _callback_parameter, _callback_handle, _callback_notify,
196                         	    _callback_request_q, _service_ptr, _thread_ptr);
197 sage          1.29      #else
198 david.dillard 1.38         work_buf[0] = '\0';
199 sage          1.29      #endif
200 a.arora       1.34          
201                            return String(work_buf);
202 mday          1.27      }
203                         
204 mike          1.2       PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2