]> git.saurik.com Git - redis.git/commitdiff
Merge remote branch 'pietern/networking-perf'
authorantirez <antirez@gmail.com>
Thu, 16 Sep 2010 10:02:18 +0000 (12:02 +0200)
committerantirez <antirez@gmail.com>
Thu, 16 Sep 2010 10:02:18 +0000 (12:02 +0200)
1  2 
src/networking.c

diff --combined src/networking.c
index 96ce5a99712ec3f21a655cd49cb77af2650b5386,26a6a4c0408d2df8d40eeaaad622e63620447c6c..aefbc2d7e050ffe6f1d12db9659f1331a034c2c9
@@@ -11,24 -11,12 +11,20 @@@ int listMatchObjects(void *a, void *b) 
  }
  
  redisClient *createClient(int fd) {
-     redisClient *c;
-     /* Allocate more space to hold a static write buffer. */
-     c = zmalloc(sizeof(redisClient)+REDIS_REPLY_CHUNK_BYTES);
-     c->buflen = REDIS_REPLY_CHUNK_BYTES;
+     redisClient *c = zmalloc(sizeof(redisClient));
      c->bufpos = 0;
  
      anetNonBlock(NULL,fd);
      anetTcpNoDelay(NULL,fd);
      if (!c) return NULL;
 +    if (aeCreateFileEvent(server.el,fd,AE_READABLE,
 +        readQueryFromClient, c) == AE_ERR)
 +    {
 +        close(fd);
 +        zfree(c);
 +        return NULL;
 +    }
 +
      selectDb(c,0);
      c->fd = fd;
      c->querybuf = sdsempty();
      c->pubsub_patterns = listCreate();
      listSetFreeMethod(c->pubsub_patterns,decrRefCount);
      listSetMatchMethod(c->pubsub_patterns,listMatchObjects);
 -    if (aeCreateFileEvent(server.el, c->fd, AE_READABLE,
 -        readQueryFromClient, c) == AE_ERR) {
 -        freeClient(c);
 -        return NULL;
 -    }
      listAddNodeTail(server.clients,c);
      initClientMultiState(c);
      return c;
@@@ -87,7 -80,7 +83,7 @@@ robj *dupLastObjectIfNeeded(list *reply
  }
  
  int _addReplyToBuffer(redisClient *c, char *s, size_t len) {
-     size_t available = c->buflen-c->bufpos;
+     size_t available = sizeof(c->buf)-c->bufpos;
  
      /* If there already are entries in the reply list, we cannot
       * add anything more to the static buffer. */