[memcached] plindner, r498: more fixes from Paolo

commits at code.sixapart.com commits at code.sixapart.com
Thu Apr 12 17:35:07 UTC 2007


more fixes from Paolo

U   trunk/server/ChangeLog
U   trunk/server/doc/protocol.txt
U   trunk/server/memcached.c


Modified: trunk/server/ChangeLog
===================================================================
--- trunk/server/ChangeLog	2007-04-12 14:40:18 UTC (rev 497)
+++ trunk/server/ChangeLog	2007-04-12 17:35:06 UTC (rev 498)
@@ -1,8 +1,8 @@
 2007-04-12  Paul Lindner  <lindner at mirth.inuus.com>
 
 	* Allow changes to the verbosity level of the server with a new
-	  "verbosity" command.  Patch contributed by Paolo Borelli
-	  <paolo.borelli at gmail.com>.
+	  "verbosity" command and some compiler cleanups. 
+          Patch contributed by Paolo Borelli <paolo.borelli at gmail.com>.
 
 2007-04-08  Paul Lindner  <lindner at inuus.com>
 

Modified: trunk/server/doc/protocol.txt
===================================================================
--- trunk/server/doc/protocol.txt	2007-04-12 14:40:18 UTC (rev 497)
+++ trunk/server/doc/protocol.txt	2007-04-12 17:35:06 UTC (rev 498)
@@ -399,15 +399,10 @@
 "VERSION <version>\r\n", where <version> is the version string for the
 server.
 
-"verbosity" is a command with one argument, the verbosity level:
+"verbosity" is a command with a numeric argument. It always                                                  
+succeeds, and the server sends "OK\r\n" in response. Its effect is to                                        
+set the verbosity level of the logging output.                                                               
 
-verbosity 2\r\n
-
-In response, the server sends
-
-"DONE"
-
-
 "quit" is a command with no arguments:
 
 quit\r\n

Modified: trunk/server/memcached.c
===================================================================
--- trunk/server/memcached.c	2007-04-12 14:40:18 UTC (rev 497)
+++ trunk/server/memcached.c	2007-04-12 17:35:06 UTC (rev 498)
@@ -467,10 +467,12 @@
         return;
 
     if (c->rsize > READ_BUFFER_HIGHWAT && c->rbytes < DATA_BUFFER_SIZE) {
+        char *newbuf;
+
         if (c->rcurr != c->rbuf)
             memmove(c->rbuf, c->rcurr, (size_t)c->rbytes);
 
-        char *newbuf = (char *)realloc((void *)c->rbuf, DATA_BUFFER_SIZE);
+        newbuf = (char *)realloc((void *)c->rbuf, DATA_BUFFER_SIZE);
 
         if (newbuf) {
             c->rbuf = newbuf;
@@ -653,7 +655,7 @@
 
 
 static void out_string(conn *c, const char *str) {
-    int len;
+    size_t len;
 
     assert(c != NULL);
 
@@ -667,8 +669,8 @@
         len = strlen(str);
     }
 
-    strcpy(c->wbuf, str);
-    strcpy(c->wbuf + len, "\r\n");
+    memcpy(c->wbuf, str, len);
+    memcpy(c->wbuf + len, "\r\n", 2);
     c->wbytes = len + 2;
     c->wcurr = c->wbuf;
 
@@ -1329,7 +1331,7 @@
 
     level = strtoul(tokens[1].value, NULL, 10);
     settings.verbose = level > MAX_VERBOSITY_LEVEL ? MAX_VERBOSITY_LEVEL : level;
-    out_string(c, "DONE");
+    out_string(c, "OK");
     return;
 }
 
@@ -1689,8 +1691,6 @@
  *   TRANSMIT_HARD_ERROR Can't write (c->state is set to conn_closing)
  */
 static int transmit(conn *c) {
-    int res;
-
     assert(c != NULL);
 
     if (c->msgcurr < c->msgused &&
@@ -1699,7 +1699,9 @@
         c->msgcurr++;
     }
     if (c->msgcurr < c->msgused) {
+        ssize_t res;
         struct msghdr *m = &c->msglist[c->msgcurr];
+
         res = sendmsg(c->sfd, m, 0);
         if (res > 0) {
             stats.bytes_written += res;
@@ -1754,6 +1756,7 @@
     assert(c != NULL);
 
     while (!stop) {
+
         switch(c->state) {
         case conn_listening:
             addrlen = sizeof(addr);
@@ -1776,9 +1779,8 @@
                 close(sfd);
                 break;
             }
-            conn *newc = conn_new(sfd, conn_read, EV_READ | EV_PERSIST,
-                            DATA_BUFFER_SIZE, false);
-            if (!newc) {
+            if (conn_new(sfd, conn_read, EV_READ | EV_PERSIST,
+                            DATA_BUFFER_SIZE, false) == NULL) {
                 if (settings.verbose > 0)
                     fprintf(stderr, "couldn't create new connection\n");
                 close(sfd);
@@ -2095,7 +2097,7 @@
     return sfd;
 }
 
-static int server_socket_unix(char *path) {
+static int server_socket_unix(const char *path) {
     int sfd;
     struct linger ling = {0, 0};
     struct sockaddr_un addr;




More information about the memcached-commits mailing list