summaryrefslogtreecommitdiff
path: root/src/rio.h
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2019-07-01 15:22:29 +0300
committerOran Agra <oran@redislabs.com>2019-07-08 15:37:48 +0300
commit2de544cfcc6d1aa7cf6d0c75a6116f7fc27b6fd6 (patch)
tree57d2e27d61fd4b5b369a7a3dfb7b8d7ce8d7ad74 /src/rio.h
parent722446510faf0debf0d309708b2ed4fe4d939319 (diff)
downloadredis-2de544cfcc6d1aa7cf6d0c75a6116f7fc27b6fd6.tar.gz
diskless replication on slave side (don't store rdb to file), plus some other related fixes
The implementation of the diskless replication was currently diskless only on the master side. The slave side was still storing the received rdb file to the disk before loading it back in and parsing it. This commit adds two modes to load rdb directly from socket: 1) when-empty 2) using "swapdb" the third mode of using diskless slave by flushdb is risky and currently not included. other changes: -------------- distinguish between aof configuration and state so that we can re-enable aof only when sync eventually succeeds (and not when exiting from readSyncBulkPayload after a failed attempt) also a CONFIG GET and INFO during rdb loading would have lied When loading rdb from the network, don't kill the server on short read (that can be a network error) Fix rdb check when performed on preamble AOF tests: run replication tests for diskless slave too make replication test a bit more aggressive Add test for diskless load swapdb
Diffstat (limited to 'src/rio.h')
-rw-r--r--src/rio.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/rio.h b/src/rio.h
index c996c54f6..beea06888 100644
--- a/src/rio.h
+++ b/src/rio.h
@@ -73,6 +73,14 @@ struct _rio {
off_t buffered; /* Bytes written since last fsync. */
off_t autosync; /* fsync after 'autosync' bytes written. */
} file;
+ /* file descriptor */
+ struct {
+ int fd; /* File descriptor. */
+ off_t pos; /* pos in buf that was returned */
+ sds buf; /* buffered data */
+ size_t read_limit; /* don't allow to buffer/read more than that */
+ size_t read_so_far; /* amount of data read from the rio (not buffered) */
+ } fd;
/* Multiple FDs target (used to write to N sockets). */
struct {
int *fds; /* File descriptors. */
@@ -126,9 +134,11 @@ static inline int rioFlush(rio *r) {
void rioInitWithFile(rio *r, FILE *fp);
void rioInitWithBuffer(rio *r, sds s);
+void rioInitWithFd(rio *r, int fd, size_t read_limit);
void rioInitWithFdset(rio *r, int *fds, int numfds);
void rioFreeFdset(rio *r);
+void rioFreeFd(rio *r, sds* out_remainingBufferedData);
size_t rioWriteBulkCount(rio *r, char prefix, long count);
size_t rioWriteBulkString(rio *r, const char *buf, size_t len);