diff options
| author | 2023-09-29 10:34:22 +0200 | |
|---|---|---|
| committer | 2023-09-29 10:34:22 +0200 | |
| commit | 60e8953a699b528a18e56be3e6a0c4f39e13feff (patch) | |
| tree | 4aa7cb149c8c42588de0cd2b687219bec18b2c10 /activitypub.c | |
| parent | Some tweaks to the logging system. (diff) | |
| download | snac2-60e8953a699b528a18e56be3e6a0c4f39e13feff.tar.gz snac2-60e8953a699b528a18e56be3e6a0c4f39e13feff.tar.xz snac2-60e8953a699b528a18e56be3e6a0c4f39e13feff.zip | |
Give more retry time to timedout connections.
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/activitypub.c b/activitypub.c index a8a570c..514bf5d 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -1798,7 +1798,7 @@ void process_user_queue_item(snac *snac, xs_dict *q_item) | |||
| 1798 | if (inbox != NULL) { | 1798 | if (inbox != NULL) { |
| 1799 | /* add to the set and, if it's not there, send message */ | 1799 | /* add to the set and, if it's not there, send message */ |
| 1800 | if (xs_set_add(&inboxes, inbox) == 1) | 1800 | if (xs_set_add(&inboxes, inbox) == 1) |
| 1801 | enqueue_output(snac, msg, inbox, 0); | 1801 | enqueue_output(snac, msg, inbox, 0, 0); |
| 1802 | } | 1802 | } |
| 1803 | else | 1803 | else |
| 1804 | snac_log(snac, xs_fmt("cannot find inbox for %s", actor)); | 1804 | snac_log(snac, xs_fmt("cannot find inbox for %s", actor)); |
| @@ -1812,7 +1812,7 @@ void process_user_queue_item(snac *snac, xs_dict *q_item) | |||
| 1812 | p = shibx; | 1812 | p = shibx; |
| 1813 | while (xs_list_iter(&p, &inbox)) { | 1813 | while (xs_list_iter(&p, &inbox)) { |
| 1814 | if (xs_set_add(&inboxes, inbox) == 1) | 1814 | if (xs_set_add(&inboxes, inbox) == 1) |
| 1815 | enqueue_output(snac, msg, inbox, 0); | 1815 | enqueue_output(snac, msg, inbox, 0, 0); |
| 1816 | } | 1816 | } |
| 1817 | } | 1817 | } |
| 1818 | 1818 | ||
| @@ -1896,6 +1896,7 @@ void process_queue_item(xs_dict *q_item) | |||
| 1896 | xs_str *seckey = xs_dict_get(q_item, "seckey"); | 1896 | xs_str *seckey = xs_dict_get(q_item, "seckey"); |
| 1897 | xs_dict *msg = xs_dict_get(q_item, "message"); | 1897 | xs_dict *msg = xs_dict_get(q_item, "message"); |
| 1898 | int retries = xs_number_get(xs_dict_get(q_item, "retries")); | 1898 | int retries = xs_number_get(xs_dict_get(q_item, "retries")); |
| 1899 | int p_status = xs_number_get(xs_dict_get(q_item, "p_status")); | ||
| 1899 | xs *payload = NULL; | 1900 | xs *payload = NULL; |
| 1900 | int p_size = 0; | 1901 | int p_size = 0; |
| 1901 | 1902 | ||
| @@ -1909,8 +1910,9 @@ void process_queue_item(xs_dict *q_item) | |||
| 1909 | return; | 1910 | return; |
| 1910 | } | 1911 | } |
| 1911 | 1912 | ||
| 1912 | /* deliver */ | 1913 | /* deliver (if previous error status was a timeout, try now longer) */ |
| 1913 | status = send_to_inbox_raw(keyid, seckey, inbox, msg, &payload, &p_size, retries == 0 ? 3 : 8); | 1914 | status = send_to_inbox_raw(keyid, seckey, inbox, msg, |
| 1915 | &payload, &p_size, p_status == 599 ? 20 : 3); | ||
| 1914 | 1916 | ||
| 1915 | if (payload) { | 1917 | if (payload) { |
| 1916 | if (p_size > 64) { | 1918 | if (p_size > 64) { |
| @@ -1934,6 +1936,11 @@ void process_queue_item(xs_dict *q_item) | |||
| 1934 | if (!valid_status(status)) { | 1936 | if (!valid_status(status)) { |
| 1935 | retries++; | 1937 | retries++; |
| 1936 | 1938 | ||
| 1939 | /* if it's not the first time it fails with a timeout, | ||
| 1940 | penalize the server by skipping one retry */ | ||
| 1941 | if (p_status == status && status == 499) | ||
| 1942 | retries++; | ||
| 1943 | |||
| 1937 | /* error sending; requeue? */ | 1944 | /* error sending; requeue? */ |
| 1938 | if (status == 400 || status == 404 || status == 410 || status < 0) | 1945 | if (status == 400 || status == 404 || status == 410 || status < 0) |
| 1939 | /* explicit error: discard */ | 1946 | /* explicit error: discard */ |
| @@ -1943,7 +1950,7 @@ void process_queue_item(xs_dict *q_item) | |||
| 1943 | srv_log(xs_fmt("output message: giving up %s %d", inbox, status)); | 1950 | srv_log(xs_fmt("output message: giving up %s %d", inbox, status)); |
| 1944 | else { | 1951 | else { |
| 1945 | /* requeue */ | 1952 | /* requeue */ |
| 1946 | enqueue_output_raw(keyid, seckey, msg, inbox, retries); | 1953 | enqueue_output_raw(keyid, seckey, msg, inbox, retries, status); |
| 1947 | srv_log(xs_fmt("output message: requeue %s #%d", inbox, retries)); | 1954 | srv_log(xs_fmt("output message: requeue %s #%d", inbox, retries)); |
| 1948 | } | 1955 | } |
| 1949 | } | 1956 | } |