Skip to content

Commit 6208b3a

Browse files
committed
Non blocking replication (finally!). C-side linked lists API improved.
1 parent 40d224a commit 6208b3a

File tree

5 files changed

+171
-106
lines changed

5 files changed

+171
-106
lines changed

TODO

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
BEFORE REDIS 1.0.0-rc1
22

3+
- What happens if the saving child gets killed instead to end normally? Handle this.
34
- Fix INCRBY argument that is limited to 32bit int.
5+
- Make sinterstore / unionstore / sdiffstore returning the cardinality of the resulting set.
46
- Add a new field as INFO output: bgsaveinprogress
57
- Remove max number of args limit
68
- GETSET
7-
- network layer stresser in test in demo
9+
- network layer stresser in test in demo, make sure to set/get random streams of data and check that what we read back is byte-by-byte the same.
810
- maxclients directive
911
- check 'server.dirty' everywere
12+
- config parameter to change the name of the DB file
1013
- replication automated tests
1114
- replication non stopping master<->slave syncronization
1215
- an external tool able to perform the 'difference' between two Redis servers. It's like 'diff', but against Redis servers, and the output is the set of commands needed to turn the first server into the second, suitable to be sent via netcat.
@@ -21,6 +24,7 @@ This command should be smart and don't use too much memory, that is, take two co
2124
- Add missing commands in documentation
2225
- Document replication
2326
- Objects sharing configuration, add the directive "objectsharingpool <size>"
27+
- Make sure to confert all the fstat() calls to 64bit versions.
2428

2529
FUTURE HINTS
2630

adlist.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void listDelNode(list *list, listNode *node)
143143
}
144144

145145
/* Returns a list iterator 'iter'. After the initialization every
146-
* call to listNextElement() will return the next element of the list.
146+
* call to listNext() will return the next element of the list.
147147
*
148148
* This function can't fail. */
149149
listIter *listGetIterator(list *list, int direction)
@@ -164,6 +164,17 @@ void listReleaseIterator(listIter *iter) {
164164
zfree(iter);
165165
}
166166

167+
/* Create an iterator in the list private iterator structure */
168+
void listRewind(list *list) {
169+
list->iter.next = list->head;
170+
list->iter.direction = AL_START_HEAD;
171+
}
172+
173+
void listRewindTail(list *list) {
174+
list->iter.next = list->tail;
175+
list->iter.direction = AL_START_TAIL;
176+
}
177+
167178
/* Return the next element of an iterator.
168179
* It's valid to remove the currently returned element using
169180
* listDelNode(), but not to remove other elements.
@@ -178,7 +189,7 @@ void listReleaseIterator(listIter *iter) {
178189
* }
179190
*
180191
* */
181-
listNode *listNextElement(listIter *iter)
192+
listNode *listNext(listIter *iter)
182193
{
183194
listNode *current = iter->next;
184195

@@ -191,6 +202,11 @@ listNode *listNextElement(listIter *iter)
191202
return current;
192203
}
193204

205+
/* List Yield just call listNext() against the list private iterator */
206+
listNode *listYield(list *list) {
207+
return listNext(&list->iter);
208+
}
209+
194210
/* Duplicate the whole list. On out of memory NULL is returned.
195211
* On success a copy of the original list is returned.
196212
*
@@ -211,7 +227,7 @@ list *listDup(list *orig)
211227
copy->free = orig->free;
212228
copy->match = orig->match;
213229
iter = listGetIterator(orig, AL_START_HEAD);
214-
while((node = listNextElement(iter)) != NULL) {
230+
while((node = listNext(iter)) != NULL) {
215231
void *value;
216232

217233
if (copy->dup) {
@@ -248,7 +264,7 @@ listNode *listSearchKey(list *list, void *key)
248264
listNode *node;
249265

250266
iter = listGetIterator(list, AL_START_HEAD);
251-
while((node = listNextElement(iter)) != NULL) {
267+
while((node = listNext(iter)) != NULL) {
252268
if (list->match) {
253269
if (list->match(node->value, key)) {
254270
listReleaseIterator(iter);

adlist.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ typedef struct listNode {
3939
void *value;
4040
} listNode;
4141

42+
typedef struct listIter {
43+
listNode *next;
44+
int direction;
45+
} listIter;
46+
4247
typedef struct list {
4348
listNode *head;
4449
listNode *tail;
4550
void *(*dup)(void *ptr);
4651
void (*free)(void *ptr);
4752
int (*match)(void *ptr, void *key);
4853
unsigned int len;
54+
listIter iter;
4955
} list;
5056

51-
typedef struct listIter {
52-
listNode *next;
53-
listNode *prev;
54-
int direction;
55-
} listIter;
56-
5757
/* Functions implemented as macros */
5858
#define listLength(l) ((l)->len)
5959
#define listFirst(l) ((l)->head)
@@ -77,11 +77,14 @@ list *listAddNodeHead(list *list, void *value);
7777
list *listAddNodeTail(list *list, void *value);
7878
void listDelNode(list *list, listNode *node);
7979
listIter *listGetIterator(list *list, int direction);
80-
listNode *listNextElement(listIter *iter);
80+
listNode *listNext(listIter *iter);
8181
void listReleaseIterator(listIter *iter);
8282
list *listDup(list *orig);
8383
listNode *listSearchKey(list *list, void *key);
8484
listNode *listIndex(list *list, int index);
85+
void listRewind(list *list);
86+
void listRewindTail(list *list);
87+
listNode *listYield(list *list);
8588

8689
/* Directions for iterators */
8790
#define AL_START_HEAD 0

0 commit comments

Comments
 (0)