Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
437eea80
Commit
437eea80
authored
Nov 01, 2010
by
Pieter Noordhuis
Browse files
Make error ptr accessible from async context
parent
4e3bd789
Changes
2
Hide whitespace changes
Inline
Side-by-side
async.c
View file @
437eea80
...
...
@@ -40,9 +40,18 @@ static redisAsyncContext *redisAsyncInitialize(redisContext *c) {
return
ac
;
}
/* We want the error field to be accessible directly instead of requiring
* an indirection to the redisContext struct. */
static
void
__redisAsyncCopyError
(
redisAsyncContext
*
ac
)
{
redisContext
*
c
=
&
(
ac
->
c
);
if
(
c
->
error
!=
NULL
)
ac
->
error
=
c
->
error
;
}
redisAsyncContext
*
redisAsyncConnect
(
const
char
*
ip
,
int
port
)
{
redisContext
*
c
=
redisConnectNonBlock
(
ip
,
port
);
redisAsyncContext
*
ac
=
redisAsyncInitialize
(
c
);
__redisAsyncCopyError
(
ac
);
return
ac
;
}
...
...
@@ -78,7 +87,8 @@ static void __redisAsyncDisconnect(redisAsyncContext *ac) {
if
(
ac
->
evCleanup
)
ac
->
evCleanup
(
ac
->
data
);
/* Execute callback with proper status */
status
=
(
c
->
error
==
NULL
)
?
REDIS_OK
:
REDIS_ERR
;
__redisAsyncCopyError
(
ac
);
status
=
(
ac
->
error
==
NULL
)
?
REDIS_OK
:
REDIS_ERR
;
if
(
ac
->
onDisconnect
)
ac
->
onDisconnect
(
ac
,
status
);
/* Cleanup self */
...
...
async.h
View file @
437eea80
...
...
@@ -54,6 +54,9 @@ typedef struct redisAsyncContext {
/* Hold the regular context, so it can be realloc'ed. */
redisContext
c
;
/* Hold a reference to the error object so it can be used directly. */
char
*
error
;
/* Called when the library expects to start reading/writing.
* The supplied functions should be idempotent. */
void
(
*
evAddRead
)(
void
*
privdata
);
...
...
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