diff -u memcached-1.4.13/debian/changelog memcached-1.4.13/debian/changelog --- memcached-1.4.13/debian/changelog +++ memcached-1.4.13/debian/changelog @@ -1,3 +1,12 @@ +memcached (1.4.13-0ubuntu2) precise; urgency=low + + * Fix FTBFS due to racey test case: + - d/patches/50_fix_racey_test.patch: Cherry picked patch from + upstream bug tracker which endeavours to avoid the race condition. + Thanks to Clint Byrum for this fix. + + -- James Page Wed, 04 Apr 2012 17:21:16 +0100 + memcached (1.4.13-0ubuntu1) precise; urgency=low * New upstream release. diff -u memcached-1.4.13/debian/patches/series memcached-1.4.13/debian/patches/series --- memcached-1.4.13/debian/patches/series +++ memcached-1.4.13/debian/patches/series @@ -4,0 +5 @@ +60_fix_racey_test.patch only in patch2: unchanged: --- memcached-1.4.13.orig/debian/patches/60_fix_racey_test.patch +++ memcached-1.4.13/debian/patches/60_fix_racey_test.patch @@ -0,0 +1,32 @@ +Description: Avoid race condition in test by re-trying up to 5 times +Author: Clint Byrum +Origin: http://code.google.com/p/memcached/issues/detail?id=252 + +Index: memcached/testapp.c +=================================================================== +--- memcached.orig/testapp.c 2012-04-04 17:19:28.610145255 +0100 ++++ memcached/testapp.c 2012-04-04 17:29:03.231682461 +0100 +@@ -382,8 +382,8 @@ + if (daemon) { + /* loop and wait for the pid file.. There is a potential race + * condition that the server just created the file but isn't +- * finished writing the content, but I'll take the chance.... +- */ ++ * finished writing the content, so we loop a few times ++ * reading as well */ + while (access(pid_file, F_OK) == -1) { + usleep(10); + } +@@ -394,7 +394,11 @@ + strerror(errno)); + assert(false); + } +- assert(fgets(buffer, sizeof(buffer), fp) != NULL); ++ ++ /* Avoid race by retrying 20 times */ ++ for (int x = 0; x < 20 && fgets(buffer, sizeof(buffer), fp) == NULL; x++) { ++ usleep(10); ++ } + fclose(fp); + + int32_t val;