Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ae.c updated

  • Loading branch information...
commit e3e3cedbeb53bfb01f9c91d54ff4515917bfbcef 1 parent 9132a61
Salvatore Sanfilippo authored
Showing with 16 additions and 21 deletions.
  1. +8 −10 ae.c
  2. +1 −3 ae.h
  3. +7 −8 redis-load.c
18 ae.c
View
@@ -93,7 +93,6 @@ int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask,
fe->mask |= mask;
if (mask & AE_READABLE) fe->rfileProc = proc;
if (mask & AE_WRITABLE) fe->wfileProc = proc;
- if (mask & AE_EXCEPTION) fe->efileProc = proc;
fe->clientData = clientData;
if (fd > eventLoop->maxfd)
eventLoop->maxfd = fd;
@@ -325,18 +324,19 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags)
aeFileEvent *fe = &eventLoop->events[eventLoop->fired[j].fd];
int mask = eventLoop->fired[j].mask;
int fd = eventLoop->fired[j].fd;
+ int rfired = 0;
/* note the fe->mask & mask & ... code: maybe an already processed
* event removed an element that fired and we still didn't
* processed, so we check if the event is still valid. */
- if (fe->mask & mask & AE_READABLE)
+ if (fe->mask & mask & AE_READABLE) {
+ rfired = 1;
fe->rfileProc(eventLoop,fd,fe->clientData,mask);
- if (fe->mask & mask & AE_WRITABLE && fe->wfileProc != fe->rfileProc)
- fe->wfileProc(eventLoop,fd,fe->clientData,mask);
- if (fe->mask & mask & AE_EXCEPTION &&
- fe->efileProc != fe->wfileProc &&
- fe->efileProc != fe->rfileProc)
- fe->efileProc(eventLoop,fd,fe->clientData,mask);
+ }
+ if (fe->mask & mask & AE_WRITABLE) {
+ if (!rfired || fe->wfileProc != fe->rfileProc)
+ fe->wfileProc(eventLoop,fd,fe->clientData,mask);
+ }
processed++;
}
}
@@ -362,11 +362,9 @@ int aeWait(int fd, int mask, long long milliseconds) {
if (mask & AE_READABLE) FD_SET(fd,&rfds);
if (mask & AE_WRITABLE) FD_SET(fd,&wfds);
- if (mask & AE_EXCEPTION) FD_SET(fd,&efds);
if ((retval = select(fd+1, &rfds, &wfds, &efds, &tv)) > 0) {
if (FD_ISSET(fd,&rfds)) retmask |= AE_READABLE;
if (FD_ISSET(fd,&wfds)) retmask |= AE_WRITABLE;
- if (FD_ISSET(fd,&efds)) retmask |= AE_EXCEPTION;
return retmask;
} else {
return retval;
4 ae.h
View
@@ -41,7 +41,6 @@
#define AE_NONE 0
#define AE_READABLE 1
#define AE_WRITABLE 2
-#define AE_EXCEPTION 4
#define AE_FILE_EVENTS 1
#define AE_TIME_EVENTS 2
@@ -62,10 +61,9 @@ typedef void aeEventFinalizerProc(struct aeEventLoop *eventLoop, void *clientDat
/* File event structure */
typedef struct aeFileEvent {
- int mask; /* one of AE_(READABLE|WRITABLE|EXCEPTION) */
+ int mask; /* one of AE_(READABLE|WRITABLE) */
aeFileProc *rfileProc;
aeFileProc *wfileProc;
- aeFileProc *efileProc;
void *clientData;
} aeFileEvent;
15 redis-load.c
View
@@ -88,7 +88,7 @@ typedef struct _client {
/* Prototypes */
static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask);
-static void createMissingClients(client c);
+static void createMissingClients(void);
/* Implementation */
static long long mstime(void) {
@@ -138,7 +138,7 @@ static void checkDataIntegrity(client c) {
unsigned long datalen;
l = sdslen(c->ibuf);
- if ((l == 5 || l == 3) &&
+ if (l == 5 &&
c->ibuf[0] == '$' && c->ibuf[1] == '-' && c->ibuf[2] == '1')
return;
@@ -177,7 +177,7 @@ static void resetClient(client c) {
c->totreceived = 0;
c->state = CLIENT_SENDQUERY;
c->start = mstime();
- createMissingClients(c);
+ createMissingClients();
}
static void prepareClientForReply(client c, int type) {
@@ -264,7 +264,7 @@ static void clientDone(client c) {
prepareClientForReply(c,c->replytype);
} else {
config.liveclients--;
- createMissingClients(c);
+ createMissingClients();
config.liveclients++;
freeClient(c);
}
@@ -339,7 +339,6 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask)
c->ibuf = sdsrange(c->ibuf,(p-c->ibuf)+1,-1);
goto processdata;
} else {
- if (c->reqtype == REDIS_GET) {printf("HERE! %d %s\n",c->replytype,c->ibuf); exit(1);}
c->ibuf = sdstrim(c->ibuf,"\r\n");
clientDone(c);
return;
@@ -420,12 +419,12 @@ static client createClient(void) {
return c;
}
-static void createMissingClients(client c) {
+static void createMissingClients(void) {
while(config.liveclients < config.numclients) {
client new = createClient();
if (!new) continue;
prepareClientForQuery(new);
- prepareClientForReply(new,c->replytype);
+ prepareClientForReply(new,new->replytype);
}
}
@@ -622,7 +621,7 @@ int main(int argc, char **argv) {
c = createClient();
prepareClientForQuery(c);
prepareClientForReply(c,c->replytype);
- createMissingClients(c);
+ createMissingClients();
aeMain(config.el);
endBenchmark("Report");
printf("\n");
Please sign in to comment.
Something went wrong with that request. Please try again.