Sümer Cip avatar Sümer Cip committed 35e1921

few fixes are backported. out of mem and send_response code tidy is on wayyy

Comments (0)

Files changed (6)

+cd ../src/
+make
+cd ../etc/
 python scripts/run.py 'valgrind --leak-check=full --show-reachable=yes'
 sleep 10000
     // have a free slot?
     if (new) {
         // do we need new allocation for the key?
-        if (new->klen >= klen+1) {
+        if (new->klen < klen+1) {
             li_free(new->key); // free previous
             new->key = (char*)li_malloc(klen+1);
             if (!new->key) {
                 return HERROR;
             }
         }
-        strncpy(new->key, key, klen+1); // copy the last "0" byte
+        memcpy(new->key, key, klen+1); // copy the last "0" byte
         new->klen = klen;
         new->val = val;
         new->free = 0;
         if (!new->key) {
             return HERROR;
         }
-        strncpy(new->key, key, klen+1);
+        memcpy(new->key, key, klen+1);
         new->klen = klen;
         new->val = val;
         new->next = ht->_table[h]; // add to front
     set_conn_state(conn, CONN_CLOSED);
 }
 
-static void send_response(conn *conn, errors err)
+static void send_response(conn *conn, code_t code)
 {
     assert(conn->out != NULL);
 
     conn->out->resp_header.response.data_length = 0;
     conn->out->resp_header.response.opcode = conn->in->req_header.request.opcode;
-    conn->out->resp_header.response.errcode = err;
+    conn->out->resp_header.response.retcode = err;
 
     conn->out->sdata = NULL;
     conn->out->can_free = 1;
 typedef union {
     struct {
         uint8_t opcode;
-        uint8_t errcode;
+        uint8_t retcode;
         uint32_t data_length;
     } response;
     uint8_t bytes[8];
     char *rdata;
     char *rkey;
     char *rextra;
-    unsigned int rbytes; /* current index in to the receive buf */
+    unsigned int rbytes; /* current recv index */
     time_t received;
     int can_free; /* flag to indicate whether data can be freed. */
 };
     // SLAB_SIZE. This idea is being used on memcached() and proved to be well
     // on real-world.
     // TODO: !!!check below cannot return below 0.
-    cm->cache_count = (unsigned int)ceil(logbn(chunk_size_factor,
+    cm->cache_count = (unsigned int)floor(logbn(chunk_size_factor,
                                          SLAB_SIZE/MIN_SLAB_CHUNK_SIZE))-1;
     slab_stats.cache_count = cm->cache_count;
     
 #include "stdint.h"
 
 #define SLAB_SIZE (1024*1024)
-#define MIN_SLAB_CHUNK_SIZE (40)
+#define MIN_SLAB_CHUNK_SIZE (20)
 #define CHUNK_ALIGN_BYTES (8)
 
 typedef struct slab_stats_t {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.