diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-09 19:18:35 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-09 19:18:35 +0200 |
commit | f99672495aef5abeab36cbb8b1e2035edbb0491b (patch) | |
tree | 8a98ce93590755440486bf3e7acf2bde2eeefae6 /src | |
parent | fe584639fb8df52bb8be8d179e50db8f2d1020b9 (diff) |
Feeds: Wait up to 10 seconds for response
If a server doesn't respond, there is no use waiting indefinitely in a background request.
Diffstat (limited to 'src')
-rw-r--r-- | src/feeds.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/feeds.c b/src/feeds.c index c54ac945..3fb05d14 100644 --- a/src/feeds.c +++ b/src/feeds.c | |||
@@ -75,6 +75,8 @@ iBool isUnread_FeedEntry(const iFeedEntry *d) { | |||
75 | 75 | ||
76 | /*----------------------------------------------------------------------------------------------*/ | 76 | /*----------------------------------------------------------------------------------------------*/ |
77 | 77 | ||
78 | static int requestTimeoutSeconds_FeedJob_ = 10.0f; | ||
79 | |||
78 | struct Impl_FeedJob { | 80 | struct Impl_FeedJob { |
79 | iString url; | 81 | iString url; |
80 | uint32_t bookmarkId; | 82 | uint32_t bookmarkId; |
@@ -104,6 +106,10 @@ static void deinit_FeedJob(iFeedJob *d) { | |||
104 | deinit_String(&d->url); | 106 | deinit_String(&d->url); |
105 | } | 107 | } |
106 | 108 | ||
109 | static iBool isTimedOut_FeedJob_(iFeedJob *d) { | ||
110 | return elapsedSeconds_Time(&d->startTime) > requestTimeoutSeconds_FeedJob_; | ||
111 | } | ||
112 | |||
107 | iDefineTypeConstructionArgs(FeedJob, (const iBookmark *bm), bm) | 113 | iDefineTypeConstructionArgs(FeedJob, (const iBookmark *bm), bm) |
108 | 114 | ||
109 | /*----------------------------------------------------------------------------------------------*/ | 115 | /*----------------------------------------------------------------------------------------------*/ |
@@ -357,6 +363,11 @@ static iThreadResult fetch_Feeds_(iThread *thread) { | |||
357 | delete_FeedJob(work[i]); | 363 | delete_FeedJob(work[i]); |
358 | work[i] = NULL; | 364 | work[i] = NULL; |
359 | } | 365 | } |
366 | else if (isTimedOut_FeedJob_(work[i])) { | ||
367 | /* Maybe we'll get it next time! */ | ||
368 | delete_FeedJob(work[i]); | ||
369 | work[i] = NULL; | ||
370 | } | ||
360 | else { | 371 | else { |
361 | ongoing++; | 372 | ongoing++; |
362 | } | 373 | } |