Compare commits

...
16 Commits
32 ... 42
Author SHA1 Message Date
Auke Kok efeed3e83f v42. 2017-06-01 16:22:00 -07:00
Auke Kok f5542e7fbb Fetch timestamp from debuginfo server.
We trigger redownloads from the server if the timestamp of
downloaded tar files is too new. An easy way around this issue
is to request the timestamp from the server instead of using
the download time. A `touch` of the tar then assures that
the downloaded file has the same timestamp as the server has.
2017-06-01 16:19:15 -07:00
Arjan van de Ven be8a99da53 allow service to start early 2017-05-07 15:42:30 +00:00
Ikey Doherty c9304402e2 Bump v38 to resync configure + tags
Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-03-09 17:48:59 +00:00
Ikey Doherty 6e202f13f7 Bump v34
Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-03-09 17:46:10 +00:00
Ikey Doherty 6735f8f6ed nica/files: Ensure we really do break on a read error
Previously nc_copy_file would return true regardless of a source read
error, flagged in analysis. Ensure we bypass the set of ret to true and
return the correct value in all instances.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-03-09 15:44:09 +00:00
Ikey Doherty 8b3777ab99 server: Remove useless assignment of prefix
This particular assignment is never used, as if this path fails, we go to
the thread end. We then reassign prefix after we split the input string.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-03-09 15:38:29 +00:00
Ikey Doherty 84350939ef nica/hashmap: Fix signature issue & item dereference
The signature was incorrect for inserting buckets, as we used an int, not
a boolean. Another issue resolved with this change is the potential
dereferencing of a null pointer by not having checked first if item was
NULL when setting the next pointer.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-03-09 15:35:29 +00:00
Arjan van de Ven 72b1120a40 add --no-same-permissions as well 2017-03-09 14:52:37 +00:00
Auke Kok d3d5fab301 Tag v33 2016-11-01 09:20:19 -07:00
Auke Kok e377433a9d Return on error here too.
Missed a 'return' catching an error.
2016-11-01 09:15:12 -07:00
Auke Kok afa92c77b1 Add reasonable connection timeout limits.
Adds a 30second connection timeout, and a low bandwith timeout
value (at 1kb/sec over 30 seconds) where the attempt will fail.
This provides some feedback to users that network issues are
preventing debug info from being loaded.
2016-11-01 09:15:12 -07:00
Arjan van de Ven a01ce4c329 dumb down due to limited infra 2016-11-01 13:17:49 +00:00
Arjan van de Ven 1eaaac582c use http/2 2016-11-01 12:56:35 +00:00
Arjan van de Ven 935dbee3c7 use CDN urls 2016-11-01 12:53:04 +00:00
Arjan van de Ven 0065ef2670 don't spew the journal 2016-11-01 12:52:17 +00:00
7 changed files with 45 additions and 12 deletions
+1
View File
@@ -4,6 +4,7 @@ Description=Clear Linux debuginfo daemon
[Service] [Service]
Type=simple Type=simple
ExecStart=/usr/bin/clr_debug_daemon ExecStart=/usr/bin/clr_debug_daemon
DefaultDependencies=no
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
+1
View File
@@ -5,6 +5,7 @@ After=clr_debug_daemon.service
[Service] [Service]
Type=simple Type=simple
ExecStart=/usr/bin/clr_debug_fuse ExecStart=/usr/bin/clr_debug_fuse
DefaultDependencies=no
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
+1 -1
View File
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ([2.66]) AC_PREREQ([2.66])
AC_INIT(clr-debug-info, 32, arjan@linux.intel.com) AC_INIT(clr-debug-info, 42, arjan@linux.intel.com)
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects]) AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
AM_SILENT_RULES([yes]) AM_SILENT_RULES([yes])
AC_PROG_CC AC_PROG_CC
+1
View File
@@ -85,6 +85,7 @@ void try_to_get(const char *path, int pid, time_t timestamp)
if (ret == 0 && cred.pid == pid) { if (ret == 0 && cred.pid == pid) {
printf("Recursion\n"); printf("Recursion\n");
close(sockfd); close(sockfd);
return;
} }
command = NULL; command = NULL;
+1 -1
View File
@@ -113,7 +113,7 @@ bool nc_copy_file(const char *src, const char *dst, mode_t mode, bool remove_tar
while (true) { while (true) {
if ((r = read(src_fd, &buffer, sizeof(buffer))) < 0) { if ((r = read(src_fd, &buffer, sizeof(buffer))) < 0) {
ret = false; ret = false;
break; goto end;
} }
if (write(dest_fd, buffer, sizeof(buffer)) != r) { if (write(dest_fd, buffer, sizeof(buffer)) != r) {
break; break;
+7 -5
View File
@@ -123,8 +123,8 @@ static inline unsigned nc_hashmap_get_hash(NcHashmap *self, const void *key)
return hash; return hash;
} }
static bool nc_hashmap_insert_bucket(NcHashmap *self, NcHashmapEntry *buckets, int n_buckets, static int nc_hashmap_insert_bucket(NcHashmap *self, NcHashmapEntry *buckets, int n_buckets,
unsigned hash, const void *key, void *value) unsigned hash, const void *key, void *value)
{ {
NcHashmapEntry *row = &(buckets[hash % n_buckets]); NcHashmapEntry *row = &(buckets[hash % n_buckets]);
NcHashmapEntry *head = NULL; NcHashmapEntry *head = NULL;
@@ -458,10 +458,12 @@ bool nc_hashmap_iter_next(NcHashmapIter *citer, void **key, void **value)
} }
item = &(map->buckets[iter->bucket]); item = &(map->buckets[iter->bucket]);
} }
if (item && item->occ) { if (item) {
goto success; if (item->occ) {
goto success;
}
item = item->next;
} }
item = item->next;
} }
return false; return false;
+33 -5
View File
@@ -55,8 +55,8 @@
static pthread_mutex_t dupes_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t dupes_mutex = PTHREAD_MUTEX_INITIALIZER;
char *urls[2] = { "https://debuginfo.clearlinux.org/debuginfo/", char *urls[2] = { "https://cdn.download.clearlinux.org/debuginfo/",
"https://debuginfo.clearlinux.org/debuginfo/" }; "https://cdn.download.clearlinux.org/debuginfo/" };
int urlcounter = 1; int urlcounter = 1;
static NcHashmap *hash = NULL; static NcHashmap *hash = NULL;
@@ -162,6 +162,7 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
{ {
CURLcode code; CURLcode code;
long ret; long ret;
long changed;
int fd; int fd;
char filename[PATH_MAX]; char filename[PATH_MAX];
CURL *curl = NULL; CURL *curl = NULL;
@@ -189,6 +190,22 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file); curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
/*
* Some sane timeout values to prevent stalls
*
* Connect timeout is for first connection to the server.
* The low speed timeout is for slow downloads. Since many
* files are several mB large, we want to prevent them from
* taking forever. (1kB/sec avg over 30secs).
*/
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 30);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1024);
/* request timestamp of files from server */
curl_easy_setopt(curl, CURLOPT_FILETIME, 1);
if (timestamp) { if (timestamp) {
curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE); curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
@@ -217,6 +234,17 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
} }
if (ret == 200) { if (ret == 200) {
/* get timestamp, if any */
curl_easy_getinfo(curl, CURLINFO_FILETIME, &changed);
if (changed >= 0) {
struct timespec times[2];
times[0].tv_sec = (time_t)changed;
times[0].tv_nsec = 0;
times[1].tv_sec = (time_t)changed;
times[1].tv_nsec = 0;
futimens(fd, times);
}
autofree(char) *command = NULL; autofree(char) *command = NULL;
// printf("Filename is %s\n", filename); // printf("Filename is %s\n", filename);
@@ -224,7 +252,7 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
stat(filename, &statbuf); stat(filename, &statbuf);
if (statbuf.st_size > 0 && if (statbuf.st_size > 0 &&
asprintf(&command, asprintf(&command,
"tar -C /var/cache/debuginfo/%s --no-same-owner -xf %s", "tar -C /var/cache/debuginfo/%s --no-same-owner --no-same-permissions -xf %s",
prefix, prefix,
filename) >= 0) { filename) >= 0) {
if (system(command) != 0) { if (system(command) != 0) {
@@ -269,7 +297,6 @@ static void *server_thread(void *arg)
if (ret < 0) { if (ret < 0) {
goto thread_end; goto thread_end;
} }
prefix = buf;
c = strchr(buf, ':'); c = strchr(buf, ':');
if (!c) { if (!c) {
goto thread_end; goto thread_end;
@@ -322,6 +349,7 @@ static void *server_thread(void *arg)
} }
gettimeofday(&after, NULL); gettimeofday(&after, NULL);
#if 0
if (timedelta(before, after) > 0.6) if (timedelta(before, after) > 0.6)
printf("Request for %s took %5.2f seconds (%i - %i)\n", printf("Request for %s took %5.2f seconds (%i - %i)\n",
url, url,
@@ -329,7 +357,7 @@ static void *server_thread(void *arg)
(1.0 * after.tv_usec - before.tv_usec) / 1000000.0, (1.0 * after.tv_usec - before.tv_usec) / 1000000.0,
ret, ret,
(int)timestamp); (int)timestamp);
#endif
/* tell the other side we're done with the download */ /* tell the other side we're done with the download */
wr = write(fd, "ok", 3); wr = write(fd, "ok", 3);