Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
db8b3c6c
Commit
db8b3c6c
authored
Aug 01, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: Message.Flags
parent
36f5a354
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
27 deletions
+21
-27
Message.cs
StackExchange.Redis/StackExchange/Redis/Message.cs
+21
-27
No files found.
StackExchange.Redis/StackExchange/Redis/Message.cs
View file @
db8b3c6c
...
@@ -23,7 +23,7 @@ private LoggingMessage(TextWriter log, Message tail) : base(tail.Db, tail.Flags,
...
@@ -23,7 +23,7 @@ private LoggingMessage(TextWriter log, Message tail) : base(tail.Db, tail.Flags,
{
{
this
.
log
=
log
;
this
.
log
=
log
;
this
.
tail
=
tail
;
this
.
tail
=
tail
;
Flags
Raw
=
tail
.
FlagsRaw
;
Flags
=
tail
.
Flags
;
}
}
public
override
string
CommandAndKey
=>
tail
.
CommandAndKey
;
public
override
string
CommandAndKey
=>
tail
.
CommandAndKey
;
...
@@ -75,9 +75,6 @@ internal abstract class Message : ICompletable
...
@@ -75,9 +75,6 @@ internal abstract class Message : ICompletable
|
CommandFlags
.
FireAndForget
|
CommandFlags
.
FireAndForget
|
CommandFlags
.
NoRedirect
|
CommandFlags
.
NoRedirect
|
CommandFlags
.
NoScriptCache
;
|
CommandFlags
.
NoScriptCache
;
private
CommandFlags
flags
;
internal
CommandFlags
FlagsRaw
{
get
{
return
flags
;
}
set
{
flags
=
value
;
}
}
private
ResultBox
resultBox
;
private
ResultBox
resultBox
;
private
ResultProcessor
resultProcessor
;
private
ResultProcessor
resultProcessor
;
...
@@ -112,7 +109,7 @@ protected Message(int db, CommandFlags flags, RedisCommand command)
...
@@ -112,7 +109,7 @@ protected Message(int db, CommandFlags flags, RedisCommand command)
bool
masterOnly
=
IsMasterOnly
(
command
);
bool
masterOnly
=
IsMasterOnly
(
command
);
Db
=
db
;
Db
=
db
;
this
.
command
=
command
;
this
.
command
=
command
;
this
.
f
lags
=
flags
&
UserSelectableFlags
;
F
lags
=
flags
&
UserSelectableFlags
;
if
(
masterOnly
)
SetMasterOnly
();
if
(
masterOnly
)
SetMasterOnly
();
createdDateTime
=
DateTime
.
UtcNow
;
createdDateTime
=
DateTime
.
UtcNow
;
...
@@ -122,7 +119,7 @@ protected Message(int db, CommandFlags flags, RedisCommand command)
...
@@ -122,7 +119,7 @@ protected Message(int db, CommandFlags flags, RedisCommand command)
internal
void
SetMasterOnly
()
internal
void
SetMasterOnly
()
{
{
switch
(
GetMasterSlaveFlags
(
f
lags
))
switch
(
GetMasterSlaveFlags
(
F
lags
))
{
{
case
CommandFlags
.
DemandSlave
:
case
CommandFlags
.
DemandSlave
:
throw
ExceptionFactory
.
MasterOnly
(
false
,
command
,
null
,
null
);
throw
ExceptionFactory
.
MasterOnly
(
false
,
command
,
null
,
null
);
...
@@ -132,7 +129,7 @@ internal void SetMasterOnly()
...
@@ -132,7 +129,7 @@ internal void SetMasterOnly()
case
CommandFlags
.
PreferMaster
:
case
CommandFlags
.
PreferMaster
:
case
CommandFlags
.
PreferSlave
:
case
CommandFlags
.
PreferSlave
:
default
:
// we will run this on the master, then
default
:
// we will run this on the master, then
flags
=
SetMasterSlaveFlags
(
f
lags
,
CommandFlags
.
DemandMaster
);
Flags
=
SetMasterSlaveFlags
(
F
lags
,
CommandFlags
.
DemandMaster
);
break
;
break
;
}
}
}
}
...
@@ -159,14 +156,11 @@ internal void PrepareToResend(ServerEndPoint resendTo, bool isMoved)
...
@@ -159,14 +156,11 @@ internal void PrepareToResend(ServerEndPoint resendTo, bool isMoved)
Status
=
CommandStatus
.
WaitingToBeSent
;
Status
=
CommandStatus
.
WaitingToBeSent
;
}
}
public
CommandFlags
Flags
{
get
;
internal
set
;
}
internal
CommandStatus
Status
{
get
;
private
set
;
}
internal
CommandStatus
Status
{
get
;
private
set
;
}
public
RedisCommand
Command
=>
command
;
public
RedisCommand
Command
=>
command
;
public
virtual
string
CommandAndKey
=>
Command
.
ToString
();
public
virtual
string
CommandAndKey
=>
Command
.
ToString
();
public
CommandFlags
Flags
=>
flags
;
/// <summary>
/// <summary>
/// Things with the potential to cause harm, or to reveal configuration information
/// Things with the potential to cause harm, or to reveal configuration information
/// </summary>
/// </summary>
...
@@ -200,17 +194,17 @@ public bool IsAdmin
...
@@ -200,17 +194,17 @@ public bool IsAdmin
}
}
}
}
public
bool
IsAsking
=>
(
f
lags
&
AskingFlag
)
!=
0
;
public
bool
IsAsking
=>
(
F
lags
&
AskingFlag
)
!=
0
;
internal
bool
IsScriptUnavailable
=>
(
f
lags
&
ScriptUnavailableFlag
)
!=
0
;
internal
bool
IsScriptUnavailable
=>
(
F
lags
&
ScriptUnavailableFlag
)
!=
0
;
internal
void
SetScriptUnavailable
()
internal
void
SetScriptUnavailable
()
{
{
f
lags
|=
ScriptUnavailableFlag
;
F
lags
|=
ScriptUnavailableFlag
;
}
}
public
bool
IsFireAndForget
=>
(
f
lags
&
CommandFlags
.
FireAndForget
)
!=
0
;
public
bool
IsFireAndForget
=>
(
F
lags
&
CommandFlags
.
FireAndForget
)
!=
0
;
public
bool
IsInternalCall
=>
(
f
lags
&
InternalCallFlag
)
!=
0
;
public
bool
IsInternalCall
=>
(
F
lags
&
InternalCallFlag
)
!=
0
;
public
ResultBox
ResultBox
=>
resultBox
;
public
ResultBox
ResultBox
=>
resultBox
;
...
@@ -420,7 +414,7 @@ public bool IsMasterOnly()
...
@@ -420,7 +414,7 @@ public bool IsMasterOnly()
// note that the constructor runs the switch statement above, so
// note that the constructor runs the switch statement above, so
// this will alread be true for master-only commands, even if the
// this will alread be true for master-only commands, even if the
// user specified PreferMaster etc
// user specified PreferMaster etc
return
GetMasterSlaveFlags
(
f
lags
)
==
CommandFlags
.
DemandMaster
;
return
GetMasterSlaveFlags
(
F
lags
)
==
CommandFlags
.
DemandMaster
;
}
}
/// <summary>
/// <summary>
...
@@ -434,7 +428,7 @@ public bool IsMasterOnly()
...
@@ -434,7 +428,7 @@ public bool IsMasterOnly()
/// </summary>
/// </summary>
public
void
SetInternalCall
()
public
void
SetInternalCall
()
{
{
f
lags
|=
InternalCallFlag
;
F
lags
|=
InternalCallFlag
;
}
}
public
override
string
ToString
()
public
override
string
ToString
()
...
@@ -619,7 +613,7 @@ internal void SetException(Exception exception)
...
@@ -619,7 +613,7 @@ internal void SetException(Exception exception)
internal
void
SetRequestSent
()
internal
void
SetRequestSent
()
{
{
Status
=
CommandStatus
.
Sent
;
Status
=
CommandStatus
.
Sent
;
if
((
f
lags
&
NeedsAsyncTimeoutCheckFlag
)
!=
0
)
if
((
F
lags
&
NeedsAsyncTimeoutCheckFlag
)
!=
0
)
{
{
_writeTickCount
=
Environment
.
TickCount
;
// note this might be reset if we resend a message, cluster-moved etc; I'm OK with that
_writeTickCount
=
Environment
.
TickCount
;
// note this might be reset if we resend a message, cluster-moved etc; I'm OK with that
}
}
...
@@ -628,15 +622,15 @@ internal void SetRequestSent()
...
@@ -628,15 +622,15 @@ internal void SetRequestSent()
// the time (ticks) at which this message was considered written
// the time (ticks) at which this message was considered written
private
int
_writeTickCount
;
private
int
_writeTickCount
;
private
void
SetNeedsTimeoutCheck
()
=>
f
lags
|=
NeedsAsyncTimeoutCheckFlag
;
private
void
SetNeedsTimeoutCheck
()
=>
F
lags
|=
NeedsAsyncTimeoutCheckFlag
;
internal
bool
HasAsyncTimedOut
(
int
now
,
int
timeoutMilliseconds
,
out
int
millisecondsTaken
)
internal
bool
HasAsyncTimedOut
(
int
now
,
int
timeoutMilliseconds
,
out
int
millisecondsTaken
)
{
{
if
((
f
lags
&
NeedsAsyncTimeoutCheckFlag
)
!=
0
)
if
((
F
lags
&
NeedsAsyncTimeoutCheckFlag
)
!=
0
)
{
{
millisecondsTaken
=
unchecked
(
now
-
_writeTickCount
);
// note: we can't just check "if sent < cutoff" because of wrap-aro
millisecondsTaken
=
unchecked
(
now
-
_writeTickCount
);
// note: we can't just check "if sent < cutoff" because of wrap-aro
if
(
millisecondsTaken
>=
timeoutMilliseconds
)
if
(
millisecondsTaken
>=
timeoutMilliseconds
)
{
{
f
lags
&=
~
NeedsAsyncTimeoutCheckFlag
;
// note: we don't remove it from the queue - still might need to marry it up; but: it is toast
F
lags
&=
~
NeedsAsyncTimeoutCheckFlag
;
// note: we don't remove it from the queue - still might need to marry it up; but: it is toast
return
true
;
return
true
;
}
}
}
}
...
@@ -649,23 +643,23 @@ internal bool HasAsyncTimedOut(int now, int timeoutMilliseconds, out int millise
...
@@ -649,23 +643,23 @@ internal bool HasAsyncTimedOut(int now, int timeoutMilliseconds, out int millise
internal
void
SetAsking
(
bool
value
)
internal
void
SetAsking
(
bool
value
)
{
{
if
(
value
)
f
lags
|=
AskingFlag
;
// the bits giveth
if
(
value
)
F
lags
|=
AskingFlag
;
// the bits giveth
else
f
lags
&=
~
AskingFlag
;
// and the bits taketh away
else
F
lags
&=
~
AskingFlag
;
// and the bits taketh away
}
}
internal
void
SetNoRedirect
()
internal
void
SetNoRedirect
()
{
{
f
lags
|=
CommandFlags
.
NoRedirect
;
F
lags
|=
CommandFlags
.
NoRedirect
;
}
}
internal
void
SetPreferMaster
()
internal
void
SetPreferMaster
()
{
{
flags
=
(
f
lags
&
~
MaskMasterServerPreference
)
|
CommandFlags
.
PreferMaster
;
Flags
=
(
F
lags
&
~
MaskMasterServerPreference
)
|
CommandFlags
.
PreferMaster
;
}
}
internal
void
SetPreferSlave
()
internal
void
SetPreferSlave
()
{
{
flags
=
(
f
lags
&
~
MaskMasterServerPreference
)
|
CommandFlags
.
PreferSlave
;
Flags
=
(
F
lags
&
~
MaskMasterServerPreference
)
|
CommandFlags
.
PreferSlave
;
}
}
internal
void
SetSource
(
ResultProcessor
resultProcessor
,
ResultBox
resultBox
)
internal
void
SetSource
(
ResultProcessor
resultProcessor
,
ResultBox
resultBox
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment