Alert if _timeline_find_fn() finds more than one file.

This commit is contained in:
default 2022-10-05 12:08:17 +02:00
parent cea390bdab
commit 3e2cfa48d9
3 changed files with 12 additions and 6 deletions

8
data.c
View File

@ -266,13 +266,19 @@ d_char *_timeline_find_fn(snac *snac, char *id)
xs *spec = xs_fmt("%s/timeline/" "*-%s.json", snac->basedir, md5); xs *spec = xs_fmt("%s/timeline/" "*-%s.json", snac->basedir, md5);
xs *list = NULL; xs *list = NULL;
d_char *fn = NULL; d_char *fn = NULL;
int l;
list = xs_glob(spec, 0, 0); list = xs_glob(spec, 0, 0);
l = xs_list_len(list);
/* if there is something, get the first one */ /* if there is something, get the first one */
if (xs_list_len(list) > 0) if (l > 0) {
fn = xs_str_new(xs_list_get(list, 0)); fn = xs_str_new(xs_list_get(list, 0));
if (l > 1)
snac_log(snac, xs_fmt("**ALERT** _timeline_find_fn %d > 1", l));
}
return fn; return fn;
} }

View File

@ -29,11 +29,11 @@ static size_t _header_callback(char *buffer, size_t size,
xs_tolower(xs_list_get(knv, 0)); xs_tolower(xs_list_get(knv, 0));
headers = xs_dict_append(headers, xs_list_get(knv, 0), xs_list_get(knv, 1)); headers = xs_dict_set(headers, xs_list_get(knv, 0), xs_list_get(knv, 1));
} }
else else
if (xs_startswith(l, "HTTP/")) if (xs_startswith(l, "HTTP/"))
headers = xs_dict_append(headers, "_proto", l); headers = xs_dict_set(headers, "_proto", l);
*userdata = headers; *userdata = headers;

View File

@ -82,10 +82,10 @@ FILE *xs_socket_accept(int rs)
/* accepts an incoming connection */ /* accepts an incoming connection */
{ {
int cs = -1; int cs = -1;
struct sockaddr_in host; struct sockaddr_storage addr;
socklen_t l = sizeof(host); socklen_t l = sizeof(addr);
cs = accept(rs, (struct sockaddr *)&host, &l); cs = accept(rs, (struct sockaddr *)&addr, &l);
return cs == -1 ? NULL : fdopen(cs, "r+"); return cs == -1 ? NULL : fdopen(cs, "r+");
} }