mirror of
https://github.com/fluencelabs/redis
synced 2025-06-22 21:41:32 +00:00
Diskless replication: rio fdset target new supports buffering.
To perform a socket write() for each RDB rio API write call was extremely unefficient, so now rio has minimal buffering capabilities. Writes are accumulated into a buffer and only when a given limit is reacehd are actually wrote to the N slaves FDs. Trivia: rio lacked support for buffering since our targets were: 1) Memory buffers. 2) C standard I/O. Both were buffered already.
This commit is contained in:
@ -43,6 +43,7 @@ struct _rio {
|
||||
size_t (*read)(struct _rio *, void *buf, size_t len);
|
||||
size_t (*write)(struct _rio *, const void *buf, size_t len);
|
||||
off_t (*tell)(struct _rio *);
|
||||
int (*flush)(struct _rio *);
|
||||
/* The update_cksum method if not NULL is used to compute the checksum of
|
||||
* all the data that was read or written so far. The method should be
|
||||
* designed so that can be called with the current checksum, and the buf
|
||||
@ -78,6 +79,7 @@ struct _rio {
|
||||
int *state; /* Error state of each fd. 0 (if ok) or errno. */
|
||||
int numfds;
|
||||
off_t pos;
|
||||
sds buf;
|
||||
} fdset;
|
||||
} io;
|
||||
};
|
||||
@ -118,6 +120,10 @@ static inline off_t rioTell(rio *r) {
|
||||
return r->tell(r);
|
||||
}
|
||||
|
||||
static inline int rioFlush(rio *r) {
|
||||
return r->flush(r);
|
||||
}
|
||||
|
||||
void rioInitWithFile(rio *r, FILE *fp);
|
||||
void rioInitWithBuffer(rio *r, sds s);
|
||||
void rioInitWithFdset(rio *r, int *fds, int numfds);
|
||||
|
Reference in New Issue
Block a user