summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authorGravatar default2023-01-24 15:06:58 +0100
committerGravatar default2023-01-24 15:06:58 +0100
commitfd1e281cbae03ced989631abd400062af81c48c2 (patch)
tree6ad8e8fca29c57af3ece6b470868df6c8607fb76 /activitypub.c
parentBackport from xs. (diff)
downloadsnac2-fd1e281cbae03ced989631abd400062af81c48c2.tar.gz
snac2-fd1e281cbae03ced989631abd400062af81c48c2.tar.xz
snac2-fd1e281cbae03ced989631abd400062af81c48c2.zip
Use a shorter timeout for first output connections.
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/activitypub.c b/activitypub.c
index aab81a9..1394235 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -31,7 +31,7 @@ int activitypub_request(snac *snac, char *url, d_char **data)
31 31
32 /* get from the net */ 32 /* get from the net */
33 response = http_signed_request(snac, "GET", url, 33 response = http_signed_request(snac, "GET", url,
34 NULL, NULL, 0, &status, &payload, &p_size); 34 NULL, NULL, 0, &status, &payload, &p_size, 0);
35 35
36 if (valid_status(status)) { 36 if (valid_status(status)) {
37 /* ensure it's ActivityPub data */ 37 /* ensure it's ActivityPub data */
@@ -131,7 +131,7 @@ int timeline_request(snac *snac, char **id, d_char **wrk)
131} 131}
132 132
133 133
134int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_size) 134int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_size, int timeout)
135/* sends a message to an Inbox */ 135/* sends a message to an Inbox */
136{ 136{
137 int status; 137 int status;
@@ -139,7 +139,7 @@ int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_s
139 xs *j_msg = xs_json_dumps_pp(msg, 4); 139 xs *j_msg = xs_json_dumps_pp(msg, 4);
140 140
141 response = http_signed_request(snac, "POST", inbox, 141 response = http_signed_request(snac, "POST", inbox,
142 NULL, j_msg, strlen(j_msg), &status, payload, p_size); 142 NULL, j_msg, strlen(j_msg), &status, payload, p_size, timeout);
143 143
144 xs_free(response); 144 xs_free(response);
145 145
@@ -167,14 +167,14 @@ d_char *get_actor_inbox(snac *snac, char *actor)
167} 167}
168 168
169 169
170int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_size) 170int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_size, int timeout)
171/* sends a message to an actor */ 171/* sends a message to an actor */
172{ 172{
173 int status = 400; 173 int status = 400;
174 xs *inbox = get_actor_inbox(snac, actor); 174 xs *inbox = get_actor_inbox(snac, actor);
175 175
176 if (!xs_is_null(inbox)) 176 if (!xs_is_null(inbox))
177 status = send_to_inbox(snac, inbox, msg, payload, p_size); 177 status = send_to_inbox(snac, inbox, msg, payload, p_size, timeout);
178 178
179 return status; 179 return status;
180} 180}
@@ -1084,7 +1084,7 @@ void process_queue(snac *snac)
1084 continue; 1084 continue;
1085 1085
1086 /* deliver */ 1086 /* deliver */
1087 status = send_to_inbox(snac, inbox, msg, &payload, &p_size); 1087 status = send_to_inbox(snac, inbox, msg, &payload, &p_size, retries == 0 ? 3 : 8);
1088 1088
1089 snac_log(snac, xs_fmt("process_queue sent to inbox %s %d", inbox, status)); 1089 snac_log(snac, xs_fmt("process_queue sent to inbox %s %d", inbox, status));
1090 1090