36 Commits

Author SHA1 Message Date
Salvatore Sanfilippo
601420cb73 Merge pull request #3828 from oranagra/sdsnewlen_pr
add SDS_NOINIT option to sdsnewlen to avoid unnecessary memsets.
2018-02-27 04:04:32 -08:00
Oran Agra
5821e8cf82 fix processing of large bulks (above 2GB)
- protocol parsing (processMultibulkBuffer) was limitted to 32big positions in the buffer
  readQueryFromClient potential overflow
- rioWriteBulkCount used int, although rioWriteBulkString gave it size_t
- several places in sds.c that used int for string length or index.
- bugfix in RM_SaveAuxField (return was 1 or -1 and not length)
- RM_SaveStringBuffer was limitted to 32bit length
2017-12-29 12:24:19 +02:00
oranagra
66f03b8340 add SDS_NOINIT option to sdsnewlen to avoid unnecessary memsets.
this commit also contains small bugfix in rdbLoadLzfStringObject
a bug that currently has no implications.
2017-02-23 03:04:08 -08:00
antirez
e88759f742 Lua debugger: use sds_malloc() to allocate eval cli array.
Redis-cli handles the debugger "eval" command in a special way since
sdssplitargs() would not be ok: we need to send the Redis debugger the
whole Lua script without any parsing. However in order to later free the
argument vector inside redis-cli using just sdsfreesplitres(), we need
to allocate the array of SDS pointers using the same allocator SDS is
using, that may differ to what Redis is using.

So now a newer version of SDS exports sds_malloc() and other allocator
functions to give access, to the program it is linked to, the allocator
used internally by SDS.
2015-11-17 15:43:23 +01:00
antirez
b1e21f503d SDS: Copyright updated further. 2015-07-25 17:41:56 +02:00
antirez
92607da7a5 SDS: changes to unify Redis SDS with antirez/sds repo. 2015-07-25 17:25:44 +02:00
antirez
9d1bde4c49 SDS: Copyright notice updated. 2015-07-25 17:08:44 +02:00
antirez
16984057e5 SDS: sdsjoinsds() call ported from antirez/sds fork. 2015-07-25 17:05:20 +02:00
antirez
c7b7769356 SDS: New sds type 5 implemented.
This is an attempt to use the refcount feature of the sds.c fork
provided in the Pull Request #2509. A new type, SDS_TYPE_5 is introduced
having a one byte header with just the string length, without
information about the available additional length at the end of the
string (this means that sdsMakeRoomFor() will be required each time
we want to append something, since the string will always report to have
0 bytes available).

More work needed in order to avoid common SDS functions will pay the
cost of this type. For example both sdscatprintf() and sdscatfmt()
should try to upgrade to SDS_TYPE_8 ASAP when appending chars.
2015-07-15 12:24:49 +02:00
Oran Agra
c498bcbc7f sds size classes - memory optimization 2015-07-14 17:17:06 +02:00
antirez
28e8878baa sdsnative() removed: New rdb.c API can load native strings. 2015-01-08 09:52:44 +01:00
Matt Stancliff
2133073bb8 Add sdsnative()
Use the existing memory space for an SDS to convert it to a regular
character buffer so we don't need to allocate duplicate space just
to extract a usable buffer for native operations.
2015-01-02 11:16:08 -05:00
Matt Stancliff
d2356d1ce7 Allow all code tests to run using Redis args
Previously, many files had individual main() functions for testing,
but each required being compiled with their own testing flags.
That gets difficult when you have 8 different flags you need
to set just to run all tests (plus, some test files required
other files to be compiled aaginst them, and it seems some didn't
build at all without including the rest of Redis).

Now all individual test main() funcions are renamed to a test
function for the file itself and one global REDIS_TEST define enables
testing across the entire codebase.

Tests can now be run with:
  - `./redis-server test <test>`

  e.g. ./redis-server test ziplist

If REDIS_TEST is not defined, then no tests get included and no
tests are included in the final redis-server binary.
2014-12-23 09:31:03 -05:00
antirez
070ec599ba sdsformatip() removed.
Specialized single-use function. Not the best match for sds.c btw.
Also genClientPeerId() is no longer static: we need symbols.
2014-12-11 18:29:04 +01:00
Matt Stancliff
89d35a3391 Add centralized IP/Peer formatting functions
This stops us from needing to manually check against ":" to
add brackets around IPv6 addresses everywhere.
2014-12-11 10:05:35 -05:00
antirez
02b06ba8f0 Use unsigned integers in SDS header.
This raises the max string to 4GB without any downside.
2014-08-13 10:53:51 +02:00
antirez
49c543415b Use sdscatfmt() in getClientInfoString() to make it faster. 2014-04-28 16:55:43 +02:00
antirez
09662d780e Fix sdsempty() prototype in sds.h. 2013-08-12 11:38:21 +02:00
antirez
fc11a99390 sdsrange() does not need to return a value.
Actaully the string is modified in-place and a reallocation is never
needed, so there is no need to return the new sds string pointer as
return value of the function, that is now just "void".
2013-07-24 11:21:39 +02:00
antirez
de40c9df4f sds.c: new function sdsjoin() to join strings. 2013-07-04 18:30:59 +02:00
antirez
478915f6c7 sds.c: sdssplitargs_free() removed as it was a duplicate. 2013-03-06 12:38:06 +01:00
Erik Dubbelboer
bde06747b8 Added consts keyword where possible 2012-03-30 21:19:51 +02:00
antirez
c0c5a7a6cc sds.c: sdsAllocSize() function added. 2012-03-14 14:58:26 +01:00
antirez
7dbf620812 sds.c no longe pre-allocate more than 1MB of free space ahead. This fixes issue #252. 2012-01-16 10:03:38 +01:00
antirez
8201022103 Added sdscatsds() to sds.c/h 2011-11-21 15:34:00 +01:00
antirez
7c7125a370 sdsMakeRoomFor() exposed as public API. sdsIncrLen() added. Both the changes make it possible to copy stuff from a system call to an sds buffer without the need of an additional buffer and copying overhead. 2011-11-02 16:50:59 +01:00
Pieter Noordhuis
c73a656652 Re-use AOF buffer when it is small enough 2011-09-13 12:22:54 +02:00
antirez
cfd32c162f Make sure error and status replies emitted by Lua scripts can never have more than a newline, otherwise it is a protocol violation and clients will desync. 2011-05-25 12:32:50 +02:00
Pieter Noordhuis
95fe886c95 Inline sdslen and sdsavail (thanks to @bitbckt) 2011-05-05 16:25:48 +02:00
antirez
c79332ab24 initial cluster config load code 2011-04-07 12:55:02 +02:00
Pieter Noordhuis
cc8322919a Change function name to match what it does 2010-12-10 12:16:16 +01:00
Pieter Noordhuis
09586f8b7a Add generic function to grow an sds value
Move logic concerned with setting a bit in an sds to the SETBIT command
instead of keeping it in sds.c. The function to grow an sds can and will
be reused for a command to set a range within a string value.
2010-12-10 11:58:21 +01:00
Pieter Noordhuis
c139b6812d Add commands SETBIT/GETBIT 2010-12-09 16:39:33 +01:00
Pieter Noordhuis
60361e5aac Add sds function that can be called with va_list 2010-09-02 21:00:15 +02:00
antirez
cbce517145 redis cli argument splitting is general and is now moved into the sds.c lib 2010-08-05 11:36:39 +02:00
antirez
e2641e09cc redis.c split into many different C files.
networking related stuff moved into networking.c

moved more code

more work on layout of source code

SDS instantaneuos memory saving. By Pieter and Salvatore at VMware ;)

cleanly compiling again after the first split, now splitting it in more C files

moving more things around... work in progress

split replication code

splitting more

Sets split

Hash split

replication split

even more splitting

more splitting

minor change
2010-07-01 14:38:51 +02:00