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
redis
Commits
019ac37e
Commit
019ac37e
authored
Oct 22, 2019
by
antirez
Browse files
Modules hooks: fix define / linker issues. Implement one test event.
parent
d5465268
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
019ac37e
...
@@ -33,9 +33,6 @@
...
@@ -33,9 +33,6 @@
#include <dlfcn.h>
#include <dlfcn.h>
#include <sys/wait.h>
#include <sys/wait.h>
#define REDISMODULE_CORE 1
#include "redismodule.h"
/* --------------------------------------------------------------------------
/* --------------------------------------------------------------------------
* Private data structures used by the modules system. Those are data
* Private data structures used by the modules system. Those are data
* structures that are never exposed to Redis Modules, if not as void
* structures that are never exposed to Redis Modules, if not as void
...
@@ -5769,7 +5766,7 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) {
...
@@ -5769,7 +5766,7 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) {
void
*
moduledata
=
NULL
;
void
*
moduledata
=
NULL
;
struct
moduleClientInfoV1
civ1
;
struct
moduleClientInfoV1
civ1
;
if
(
eid
==
REDISMODULE_EVENT_
ID_
CLIENT_CHANGE
)
{
if
(
eid
==
REDISMODULE_EVENT_CLIENT_CHANGE
)
{
modulePopulateClientInfoStructure
(
&
civ1
,
data
,
modulePopulateClientInfoStructure
(
&
civ1
,
data
,
el
->
event
.
dataver
);
el
->
event
.
dataver
);
}
}
...
...
src/networking.c
View file @
019ac37e
...
@@ -827,9 +827,11 @@ void clientAcceptHandler(connection *conn) {
...
@@ -827,9 +827,11 @@ void clientAcceptHandler(connection *conn) {
}
}
server
.
stat_numconnections
++
;
server
.
stat_numconnections
++
;
moduleFireServerEvent
(
REDISMODULE_EVENT_CLIENT_CHANGE
,
REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED
,
c
);
}
}
#define MAX_ACCEPTS_PER_CALL 1000
#define MAX_ACCEPTS_PER_CALL 1000
static
void
acceptCommonHandler
(
connection
*
conn
,
int
flags
,
char
*
ip
)
{
static
void
acceptCommonHandler
(
connection
*
conn
,
int
flags
,
char
*
ip
)
{
client
*
c
;
client
*
c
;
...
...
src/redismodule.h
View file @
019ac37e
...
@@ -163,73 +163,76 @@ typedef uint64_t RedisModuleTimerID;
...
@@ -163,73 +163,76 @@ typedef uint64_t RedisModuleTimerID;
#define REDISMODULE_OPTIONS_HANDLE_IO_ERRORS (1<<0)
#define REDISMODULE_OPTIONS_HANDLE_IO_ERRORS (1<<0)
/* Server events definitions. */
/* Server events definitions. */
#define REDISMODULE_EVENT_
ID_
REPLICATION_ROLE_CHANGED 0
#define REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED 0
#define REDISMODULE_EVENT_
ID_
PERSISTENCE 1
#define REDISMODULE_EVENT_PERSISTENCE 1
#define REDISMODULE_EVENT_
ID_
FLUSHDB 2
#define REDISMODULE_EVENT_FLUSHDB 2
#define REDISMODULE_EVENT_
ID_
LOADING 3
#define REDISMODULE_EVENT_LOADING 3
#define REDISMODULE_EVENT_
ID_
CLIENT_CHANGE 4
#define REDISMODULE_EVENT_CLIENT_CHANGE 4
#define REDISMODULE_EVENT_
ID_
SHUTDOWN 5
#define REDISMODULE_EVENT_SHUTDOWN 5
#define REDISMODULE_EVENT_
ID_
REPLICA_CHANGE 6
#define REDISMODULE_EVENT_REPLICA_CHANGE 6
#define REDISMODULE_EVENT_
ID_
MASTER_LINK_CHANGE 7
#define REDISMODULE_EVENT_MASTER_LINK_CHANGE 7
typedef
struct
RedisModuleEvent
{
typedef
struct
RedisModuleEvent
{
uint64_t
id
;
/* REDISMODULE_EVENT_
ID_
... defines. */
uint64_t
id
;
/* REDISMODULE_EVENT_... defines. */
uint64_t
dataver
;
/* Version of the structure we pass as 'data'. */
uint64_t
dataver
;
/* Version of the structure we pass as 'data'. */
}
RedisModuleEvent
;
}
RedisModuleEvent
;
RedisModuleEvent
struct
RedisModuleCtx
;
typedef
int
(
*
RedisModuleEventCallback
)(
struct
RedisModuleCtx
*
ctx
,
RedisModuleEvent
eid
,
uint64_t
subevent
,
void
*
data
);
static
RedisModuleEvent
RedisModuleEvent_ReplicationRoleChanged
=
{
RedisModuleEvent_ReplicationRoleChanged
=
{
REDISMODULE_EVENT_
ID_
REPLICATION_ROLE_CHANGED
,
REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED
,
1
1
},
},
RedisModuleEvent_Persistence
=
{
RedisModuleEvent_Persistence
=
{
REDISMODULE_EVENT_
ID_
PERSISTENCE
,
REDISMODULE_EVENT_PERSISTENCE
,
1
1
},
},
RedisModuleEvent_FlushDB
=
{
RedisModuleEvent_FlushDB
=
{
REDISMODULE_EVENT_
ID_
FLUSHDB
,
REDISMODULE_EVENT_FLUSHDB
,
1
1
},
},
RedisModuleEvent_Loading
=
{
RedisModuleEvent_Loading
=
{
REDISMODULE_EVENT_
ID_
LOADING
,
REDISMODULE_EVENT_LOADING
,
1
1
},
},
RedisModuleEvent_ClientChange
=
{
RedisModuleEvent_ClientChange
=
{
REDISMODULE_EVENT_
ID_
CLIENT_CHANGE
,
REDISMODULE_EVENT_CLIENT_CHANGE
,
1
1
},
},
RedisModuleEvent_Shutdown
=
{
RedisModuleEvent_Shutdown
=
{
REDISMODULE_EVENT_
ID_
SHUTDOWN
,
REDISMODULE_EVENT_SHUTDOWN
,
1
1
},
},
RedisModuleEvent_ReplicaChange
=
{
RedisModuleEvent_ReplicaChange
=
{
REDISMODULE_EVENT_
ID_
REPLICA_CHANGE
,
REDISMODULE_EVENT_REPLICA_CHANGE
,
1
1
},
},
RedisModuleEvent_MasterLinkChange
=
{
RedisModuleEvent_MasterLinkChange
=
{
REDISMODULE_EVENT_
ID_
MASTER_LINK_CHANGE
,
REDISMODULE_EVENT_MASTER_LINK_CHANGE
,
1
1
};
};
typedef
int
(
*
RedisModuleEventCallback
)(
struct
RedisModuleCtx
*
ctx
,
RedisModuleEvent
eid
,
uint64_t
subevent
,
void
*
data
);
/* Those are values that are used for the 'subevent' callback argument. */
/* Those are values that are used for the 'subevent' callback argument. */
#define REDISMODULE_EVENT_PERSISTENCE_RDB_START 0
#define REDISMODULE_
SUB
EVENT_PERSISTENCE_RDB_START 0
#define REDISMODULE_EVENT_PERSISTENCE_RDB_END 1
#define REDISMODULE_
SUB
EVENT_PERSISTENCE_RDB_END 1
#define REDISMODULE_EVENT_PERSISTENCE_AOF_START 2
#define REDISMODULE_
SUB
EVENT_PERSISTENCE_AOF_START 2
#define REDISMODULE_EVENT_PERSISTENCE_AOF_END 3
#define REDISMODULE_
SUB
EVENT_PERSISTENCE_AOF_END 3
#define REDISMODULE_EVENT_LOADING_START 0
#define REDISMODULE_SUBEVENT_LOADING_RDB_START 0
#define REDISMODULE_EVENT_LOADING_END 1
#define REDISMODULE_SUBEVENT_LOADING_RDB_END 1
#define REDISMODULE_SUBEVENT_LOADING_AOF_START 2
#define REDISMODULE_SUBEVENT_LOADING_AOF_END 3
#define REDISMODULE_EVENT_CLIENT_CHANGE_CONNECTED 0
#define REDISMODULE_
SUB
EVENT_CLIENT_CHANGE_CONNECTED 0
#define REDISMODULE_EVENT_CLIENT_CHANGE_DISCONNECTED 1
#define REDISMODULE_
SUB
EVENT_CLIENT_CHANGE_DISCONNECTED 1
#define REDISMODULE_EVENT_MASTER_LINK_UP 0
#define REDISMODULE_
SUB
EVENT_MASTER_LINK_UP 0
#define REDISMODULE_EVENT_MASTER_LINK_DOWN 1
#define REDISMODULE_
SUB
EVENT_MASTER_LINK_DOWN 1
#define REDISMODULE_EVENT_REPLICA_CHANGE_CONNECTED 0
#define REDISMODULE_
SUB
EVENT_REPLICA_CHANGE_CONNECTED 0
#define REDISMODULE_EVENT_REPLICA_CHANGE_DISCONNECTED 1
#define REDISMODULE_
SUB
EVENT_REPLICA_CHANGE_DISCONNECTED 1
/* RedisModuleClientInfo flags. */
/* RedisModuleClientInfo flags. */
#define REDISMODULE_CLIENTINFO_FLAG_SSL (1<<0)
#define REDISMODULE_CLIENTINFO_FLAG_SSL (1<<0)
...
...
src/server.h
View file @
019ac37e
...
@@ -68,6 +68,9 @@ typedef long long mstime_t; /* millisecond time type. */
...
@@ -68,6 +68,9 @@ typedef long long mstime_t; /* millisecond time type. */
#include "rax.h"
/* Radix tree */
#include "rax.h"
/* Radix tree */
#include "connection.h"
/* Connection abstraction */
#include "connection.h"
/* Connection abstraction */
#define REDISMODULE_CORE 1
#include "redismodule.h"
/* Redis modules API defines. */
/* Following includes allow test functions to be called from Redis main() */
/* Following includes allow test functions to be called from Redis main() */
#include "zipmap.h"
#include "zipmap.h"
#include "sha1.h"
#include "sha1.h"
...
...
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