89 Commits

Author SHA1 Message Date
antirez
2ae6258ba7 Module: API to block clients with threading support.
Just a draft to align the main ideas, never executed code. Compiles.
2016-10-07 11:55:35 +02:00
antirez
56f2406e09 Module: Ability to get context from IO context.
It was noted by @dvirsky that it is not possible to use string functions
when writing the AOF file. This sometimes is critical since the command
rewriting may need to be built in the context of the AOF callback, and
without access to the context, and the limited types that the AOF
production functions will accept, this can be an issue.

Moreover there are other needs that we can't anticipate regarding the
ability to use Redis Modules APIs using the context in order to build
representations to emit AOF / RDB.

Because of this a new API was added that allows the user to get a
temporary context from the IO context. The context is auto released
if obtained when the RDB / AOF callback returns.

Calling multiple time the function to get the context, always returns
the same one, since it is invalid to have more than a single context.
2016-10-06 17:09:26 +02:00
antirez
8a08c7d570 Copyright notice added to module.c. 2016-10-06 08:48:21 +02:00
antirez
adcafbd283 Modules: API to save/load single precision floating point numbers.
When double precision is not needed, to take 2x space in the
serialization is not good.
2016-10-03 00:08:35 +02:00
antirez
8c561f8430 Modules: API to log from module I/O callbacks. 2016-10-02 16:51:37 +02:00
Dvir Volk
b8a375fe59 added RM_CreateStringPrintf 2016-09-21 12:30:38 +03:00
oranagra
90af5e0825 dict.c: introduce dictUnlink().
Notes by @antirez:

This patch was picked from a larger commit by Oran and adapted to change
the API a bit. The basic idea is to avoid double lookups when there is
to use the value of the deleted entry.

BEFORE:

    entry = dictFind( ... ); /* 1st lookup. */
    /* Do somethjing with the entry. */
    dictDelete(...);         /* 2nd lookup. */

AFTER:

    entry = dictUnlink( ... ); /* 1st lookup. */
    /* Do somethjing with the entry. */
    dictFreeUnlinkedEntry(entry); /* No lookups!. */
2016-09-14 12:18:59 +02:00
wyx
5d070a76ba fix memory error on module unload 2016-09-09 10:22:57 +08:00
antirez
3e711f4cfb Modules: handle NULL replies more gracefully.
After all crashing at every API misuse makes everybody's life more
complex.
2016-08-03 18:09:36 +02:00
antirez
e3cb70f2e4 Modules: initial draft for a testing module. 2016-08-03 10:23:03 +02:00
antirez
f7a8b65f3d Modules: StringAppendBuffer() and ability to retain strings.
RedisModule_StringRetain() allows, when automatic memory management is
on, to keep string objects living after the callback returns. Can also
be used in order to use Redis reference counting of objects inside
modules.

The reason why this is useful is that sometimes when implementing new
data types we want to reference RedisModuleString objects inside the
module private data structures, so those string objects must be valid
after the callback returns even if not referenced inside the Redis key
space.
2016-08-02 15:29:04 +02:00
Salvatore Sanfilippo
8e767386b7 Merge pull request #3335 from dvirsky/rm_calloc
added RM_Calloc implementation
2016-06-23 16:19:14 +02:00
antirez
641ba2fc21 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2016-06-23 16:18:57 +02:00
antirez
a450fa37a9 Actually remove static from #3331.
I forgot -a when amending in the previous commit.
2016-06-23 16:18:30 +02:00
Salvatore Sanfilippo
cea51549b8 Merge pull request #3336 from yossigo/create_string_from_string
Add RedisModule_CreateStringFromString().
2016-06-23 16:16:28 +02:00
antirez
239e8beefa Minor change to conform PR #3331 to Redis code base style.
Also avoid "static" in order to have symbols during crashes.
2016-06-23 16:14:16 +02:00
Salvatore Sanfilippo
b2a7b92991 Merge pull request #3331 from yossigo/fix_openkey_crash
Fix occasional RM_OpenKey() crashes.
2016-06-23 16:12:07 +02:00
Salvatore Sanfilippo
408b1cbd7e Merge pull request #3330 from yossigo/fix_const
Use const in Redis Module API where possible.
2016-06-23 12:29:52 +02:00
antirez
d2ace2c15a Modules: changes to logging function.
This commit changes what provided by PR #3315 (merged) in order to
let the user specify the log level as a string.

The define could be also used, but when this happens, they must be
decoupled from the defines in the Redis core, like in the other part of
the Redis modules implementations, so that a switch statement (or a
function) remaps between the two, otherwise we are no longer free to
change the internal Redis defines.
2016-06-23 12:11:30 +02:00
Yossi Gottlieb
ee0ea33013 Add RedisModule_Log() logging API function. 2016-06-23 12:01:44 +02:00
antirez
e48fa9e73a Commit change in autoMemoryFreed(): first -> last.
It's more natural to call the last entry added as "last", the original
commet got me confused until I actually read the code.
2016-06-23 09:38:30 +02:00
antirez
7246f868be Modules: implement zig-zag scanning in autoMemoryFreed().
Most of the time to check the last element is the way to go, however
there are patterns where the contrary is the best choice. Zig-zag
scanning implemented in this commmit always checks the obvious element
first (the last added -- think at a loop where the last element
allocated gets freed again and again), and continues checking one
element in the head and one in the tail.

Thanks to @dvisrky that fixed the original implementation of the
function and proposed zig zag scanning.
2016-06-23 09:09:51 +02:00
Salvatore Sanfilippo
4cca9e08dc Merge pull request #3244 from dvirsky/optimize_autoMemoryFreed
Optimized autoMemoryFreed loop
2016-06-23 08:59:38 +02:00
Yossi Gottlieb
c7ec9f280f Add RedisModule_CreateStringFromString(). 2016-06-22 21:02:40 +03:00
Dvir Volk
fe5d678f2a added RM_Calloc implementation 2016-06-22 17:32:41 +03:00
Yossi Gottlieb
481bd1a45b Cleanup: remove zset reset function from RM_ZsetRangeStop(). 2016-06-22 07:34:14 +03:00
Yossi Gottlieb
ef4c2636ed Fix occasional RM_OpenKey() crashes. 2016-06-21 10:22:19 +03:00
Yossi Gottlieb
83a4257f72 Use const in Redis Module API where possible. 2016-06-20 23:08:06 +03:00
antirez
eddd548adf Free module context after loading.
Now that modules receive RedisModuleString objects on loading, they are
allowed to call the String API, so the context must be released
correctly.

Related to #3293.
2016-06-13 09:45:53 +02:00
antirez
911196827c Minor changes to unifor C style to Redis code base for PR #3293. 2016-06-13 09:39:44 +02:00
Salvatore Sanfilippo
cfc4f7c48a Merge pull request #3293 from yossigo/module_config
Allow passing arguments to modules on load.
2016-06-13 09:31:59 +02:00
Yossi Gottlieb
05f6c2721b Fix MODULE UNLOAD crash and/or wrong error message. 2016-06-05 13:27:38 +03:00
Yossi Gottlieb
244e273e55 Use RedisModuleString for OnLoad argv. 2016-06-05 13:18:24 +03:00
Yossi Gottlieb
03cd702372 Allow passing arguments to modules on load. 2016-06-05 11:37:24 +03:00
antirez
9deb98167b Modules: support for modules native data types. 2016-06-03 18:14:04 +02:00
Dvir Volk
f4c86ac7a0 optimized amFree even further 2016-05-19 13:51:55 +03:00
Dvir Volk
e10b9ca1ca Optimized autoMemoryFreed loop 2016-05-19 12:16:14 +03:00
antirez
75c4d79ad6 Modules: RM_HashSet() SDS ownership business clarified in comments.
Related to #3239.
2016-05-18 16:30:20 +02:00
Dvir Volk
63102f9004 fixed bad transfer of ownership in HashSet causing a potential crash 2016-05-17 16:47:36 +03:00
antirez
cae2bd9aca Modules: initial pool allocator and a LEFTPAD usage example. 2016-05-14 19:42:31 +02:00
antirez
ff44da7d45 Modules: doc layout improved. 2016-05-10 18:54:58 +02:00
antirez
1aaa60df99 RM_ZsetRangeNext()/Prev() typo in define name leading to crash fixed. 2016-05-10 06:40:11 +02:00
antirez
ab140098e5 Modules: commandFlagsFromString() top comment back to 80 cols max. 2016-05-10 06:40:11 +02:00
antirez
1d1be43de0 Trailing spaces removed from moduleCreateArgvFromUserFormat(). 2016-05-10 06:40:11 +02:00
antirez
bcdb40f18d Modules: RM_GetClientId() implemented. 2016-05-10 06:40:11 +02:00
Dvir Volk
5c4877782a fixed crash when calling CreateStringFromCallReply on array elements 2016-05-10 06:40:11 +02:00
Itamar Haber
6b2ed56359 Avoids reallocating and double String on truncate 2016-05-10 06:40:11 +02:00
Dvir Volk
3add8824d9 fixed comment formatting in RM_CreateCommand 2016-05-10 06:40:10 +02:00
Dvir Volk
65b6175c7d another small comment fix 2016-05-10 06:40:10 +02:00
Dvir Volk
2cc3a7c38f fixed comment 2016-05-10 06:40:10 +02:00