1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
// $Id$
#include "ace/Token_Request_Reply.h"
#if !defined (__ACE_INLINE__)
#include "ace/Token_Request_Reply.i"
#endif /* __ACE_INLINE__ */
#if defined (ACE_HAS_TOKENS_LIBRARY)
ACE_RCSID(ace, Token_Request_Reply, "$Id$")
// Default "do nothing" constructor.
ACE_Token_Request::ACE_Token_Request (void)
: token_name_ (0),
client_id_ (0)
{
}
// Create a ACE_Token_Request message.
ACE_Token_Request::ACE_Token_Request (int token_type,
int proxy_type,
ACE_UINT32 operation_type,
const ACE_TCHAR token_name[],
const ACE_TCHAR client_id[],
const ACE_Synch_Options &options)
{
this->token_type (token_type);
this->proxy_type (proxy_type);
this->operation_type (operation_type);
this->requeue_position (0); // to avoid Purify UMR
this->notify (0); // to avoid Purify UMR
transfer_.arg_ = 0; // to avoid Purify UMR
ACE_OS::memset (transfer_.data_, 0, sizeof transfer_.data_); // to avoid Purify UMR
this->token_name (token_name, client_id);
this->options (options);
}
// Encode the transfer buffer into network byte order
// so that it can be sent to the server.
int
ACE_Token_Request::encode (void *&buf)
{
buf = (void *) &this->transfer_;
return this->length ();
}
// Decode the transfer buffer into host byte byte order
// so that it can be used by the server.
int
ACE_Token_Request::decode (void)
{
this->token_name_ = this->transfer_.data_;
options_.set (transfer_.use_timeout_ == 1 ? ACE_Synch_Options::USE_TIMEOUT : 0,
ACE_Time_Value (transfer_.sec_, transfer_.usec_),
(void *) transfer_.arg_);
// Decode the variable-sized portion.
int token_len = ACE_OS::strlen (this->token_name_);
// Check to make sure this->tokenName_ isn't too long!
if (token_len >= ACE_MAXTOKENNAMELEN)
{
errno = ENAMETOOLONG;
return -1;
}
else // Skip this->tokenName_ + '\0' + ':'.
this->client_id_ =
&this->token_name_[(token_len + 2) * sizeof (ACE_TCHAR)];
// Fixed size header
// token_name_ plus '\0'
// ':'
// client_id_ plus '\0'
size_t data_size = ACE_TOKEN_REQUEST_HEADER_SIZE
+ ACE_OS::strlen (this->token_name_) + 1
+ ACE_OS::strlen (this->client_id_) + 1
+ 1;
// Make sure the message was correctly received and framed.
return this->length () == data_size ? 0 : -1;
}
// Print out the current values of the ACE_Token_Request.
void
ACE_Token_Request::dump (void) const
{
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("*******\nlength = %d\ntoken name = %s\nclient id = %s\n"),
this->length (), this->token_name (), this->client_id ()));
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("type = ")));
if (this->token_type () == ACE_Tokens::MUTEX)
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("MUTEX\n")));
else // == ACE_Tokens::RWLOCK
{
if (this->proxy_type () == ACE_RW_Token::READER)
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("RLOCK\n")));
else // == WRITER
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("WLOCK\n")));
}
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("operation = ")));
switch (this->operation_type ())
{
case ACE_Token_Request::ACQUIRE:
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACQUIRE\n")));
break;
case ACE_Token_Request::RELEASE:
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("RELEASE\n")));
break;
case ACE_Token_Request::RENEW:
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("RENEW\n")));
break;
default:
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("<unknown operation type> = %d\n"), this->operation_type ()));
break;
}
if (this->options ()[ACE_Synch_Options::USE_TIMEOUT] == 0)
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("blocking forever\n")));
else
{
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("waiting for %d secs and %d usecs\n"),
this->options ().timeout ().sec (), this->options ().timeout ().usec ()));
}
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
}
// ************************************************************
// ************************************************************
// ************************************************************
// Create a ACE_Token_Reply message.
ACE_Token_Reply::ACE_Token_Reply (void) // Type of reply.
{
this->arg (0);
this->errnum (0);
this->length (sizeof (Transfer));
}
// Encode the transfer buffer into network byte order
// so that it can be sent to the client.
int
ACE_Token_Reply::encode (void *&buf)
{
buf = (void *) &this->transfer_;
return this->length ();
}
// Decode the transfer buffer into host byte order
// so that it can be used by the client.
int
ACE_Token_Reply::decode (void)
{
return 0;
}
// Print out current values of the ACE_Token_Reply object.
void
ACE_Token_Reply::dump (void) const
{
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("*******\nlength = %d\nerrnum = %d"),
this->length (), this->errnum ()));
ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("arg = %d"), this->arg ()));
}
#endif /* ACE_HAS_TOKENS_LIBRARY */
|