[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#644657: libmemcached: FTBFS on hurd-i386



On Sat, 2011-10-15 at 01:28 +0200, Guillem Jover wrote:
> Hi!
> 
> On Thu, 2011-10-13 at 19:00:24 +0200, Svante Signell wrote:
> > Attached is an updated patch, mainly fixing some indentation and coding
> > style issues and not limiting msghdr if there is no IOV_MAX limit
> > defined (as on GNU/Hurd).
...
> Sorry, I guess I was not clear with my comment, I meant that the
> IOV_MAX specific condition should not be honoured when there's no such
> limit, the other part of the condition is still relevant though (the
> MTU limit), and a new header should be started then.
...

Sorry to update the patch for libmemcached again, but this time it would
be OK, even for Guillem. 

New patch attached. We are looking forward to se it applied in the next
Debian release of libmemcached (and in upstream in due time).

Thanks!
diff -ur libmemcached-0.44/clients/ms_conn.c libmemcached-0.44.modified/clients/ms_conn.c
--- libmemcached-0.44/clients/ms_conn.c	2010-07-22 17:06:58.000000000 +0200
+++ libmemcached-0.44.modified/clients/ms_conn.c	2011-10-15 14:29:20.000000000 +0200
@@ -2125,8 +2125,12 @@
     limit_to_mtu= c->udp;
 
     /* We may need to start a new msghdr if this one is full. */
+#ifdef IOV_MAX
     if ((m->msg_iovlen == IOV_MAX)
         || (limit_to_mtu && (c->msgbytes >= UDP_MAX_SEND_PAYLOAD_SIZE)))
+#else
+      if (limit_to_mtu && (c->msgbytes >= UDP_MAX_SEND_PAYLOAD_SIZE))
+#endif
     {
       ms_add_msghdr(c);
       m= &c->msglist[c->msgused - 1];
diff -ur libmemcached-0.44/clients/ms_setting.c libmemcached-0.44.modified/clients/ms_setting.c
--- libmemcached-0.44/clients/ms_setting.c	2010-08-03 02:34:02.000000000 +0200
+++ libmemcached-0.44.modified/clients/ms_setting.c	2011-10-15 14:30:28.000000000 +0200
@@ -304,13 +304,17 @@
  */
 static void ms_no_config_file()
 {
-  char userpath[PATH_MAX];
+  char *userpath= NULL;
+  size_t len;
   struct passwd *usr= NULL;
   FILE *fd;
 
   usr= getpwuid(getuid());
 
-  snprintf(userpath, PATH_MAX, "%s/%s", usr->pw_dir, DEFAULT_CONFIG_NAME);
+  len= strlen(usr->pw_dir) + 1 + strlen(DEFAULT_CONFIG_NAME) + 1;
+  if ((userpath= malloc(len)) == NULL)
+      exit(1);
+  snprintf(userpath, len, "%s/%s", usr->pw_dir, DEFAULT_CONFIG_NAME);
 
   if (access (userpath, F_OK | R_OK) == 0)
     goto exit;
@@ -321,13 +325,14 @@
   {
     fprintf(stderr, "Could not create default configure file %s\n", userpath);
     perror(strerror(errno));
+    free(userpath);
     exit(1);
   }
   fprintf(fd, "%s", DEFAULT_CONGIF_STR);
   fclose(fd);
 
 exit:
-  ms_setting.cfg_file= strdup(userpath);
+  ms_setting.cfg_file= userpath;
 } /* ms_no_config_file */
 
 
--- libmemcached-0.44/tests/server.c	2010-08-03 08:30:54.000000000 +0200
+++ libmemcached-0.44.modified/tests/server.c	2011-10-15 14:31:49.000000000 +0200
@@ -117,18 +117,30 @@
           }
         }
 
-        char buffer[PATH_MAX];
-        snprintf(buffer, sizeof(buffer), PID_FILE_BASE, x);
+        char *buffer= NULL;
+        size_t len= 0;
+
+        len= strlen(PID_FILE_BASE) + sizeof(int) - 2 + 1;
+        if ((buffer= malloc(len)) == NULL)
+            assert(buffer);
+        snprintf(buffer, len, PID_FILE_BASE, x);
         kill_file(buffer);
 
         if (x == 0)
         {
-          snprintf(buffer, sizeof(buffer), "%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u -m 128",
+          len= strlen("%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u -m 128") + strlen(MEMCACHED_BINARY) + 3*sizeof(int)- 4*2 + 1;
+          if ((buffer= malloc(len)) == NULL)
+              assert(buffer);
+          snprintf(buffer, len, "%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u -m 128",
                    MEMCACHED_BINARY, x, port, port);
         }
         else
         {
-          snprintf(buffer, sizeof(buffer), "%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u",
+          len= strlen("%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u") +
+              strlen(MEMCACHED_BINARY) + 3*sizeof(int) - 4*2 + 1;
+          if ((buffer= malloc(len)) == NULL)
+              assert(buffer);
+           snprintf(buffer, len, "%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u",
                    MEMCACHED_BINARY, x, port, port);
         }
 	if (libmemcached_util_ping("localhost", port, NULL))
@@ -142,6 +154,7 @@
 	}
         count= sprintf(end_ptr, "localhost:%u,", port);
         end_ptr+= count;
+        free(buffer);
       }
       *end_ptr= 0;
 
@@ -149,9 +162,13 @@
       int *pids= calloc(construct->count, sizeof(int));
       for (uint32_t x= 0; x < construct->count; x++)
       {
-        char buffer[PATH_MAX]; /* Nothing special for number */
+        char *buffer= NULL; /* Nothing special for number */
+        size_t len= 0;
 
-        snprintf(buffer, sizeof(buffer), PID_FILE_BASE, x);
+        len= strlen(PID_FILE_BASE) + sizeof(int) - 2 + 1;
+        if ((buffer= malloc(len)) == NULL)
+          assert(buffer);
+        snprintf(buffer, len, PID_FILE_BASE, x);
 
         uint32_t counter= 3000; // Absurd, just to catch run away process
         while (pids[x] <= 0  && --counter)
@@ -198,8 +215,10 @@
             if (pids[y] > 0)
               kill(pids[y], SIGTERM);
           }
+          free(buffer);
           abort();
         }
+        free(buffer);
       }
       free(pids);
 
@@ -229,9 +248,15 @@
   {
     for (uint32_t x= 0; x < construct->count; x++)
     {
-      char file_buffer[PATH_MAX]; /* Nothing special for number */
-      snprintf(file_buffer, sizeof(file_buffer), PID_FILE_BASE, x);
+      char *file_buffer= NULL; /* Nothing special for number */
+      size_t len= 0;
+
+      len= strlen(PID_FILE_BASE) + sizeof(int) - 2 + 1;
+      if ((file_buffer= malloc(len)) == NULL)
+        assert(file_buffer);
+      snprintf(file_buffer, len, PID_FILE_BASE, x);
       kill_file(file_buffer);
+      free(file_buffer);
     }
 
     free(construct->server_list);

Reply to: