This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
drawer.patch
228 lines (213 loc) · 6.68 KB
/
drawer.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
From 8ba1b6d9123d2f1883160dd3f7b15d6e2763d6a2 Mon Sep 17 00:00:00 2001
From: Arne Coucheron <arco68@gmail.com>
Date: Sat, 25 Aug 2012 07:09:14 +0200
Subject: [PATCH] Revert "Avoid multiple dns lookups for the same query"
This is causing issues with the notification drawer, and at least an
issue with BetterBatteryStats getting stuck on "Computing". I suspect
it might be causing other weird issues as well.
For a description of the notification drawer issue, refer to issue 6040
in the issue tracker: http://kan.gd/1qlb
Screenshot of the issue: http://i46.tinypic.com/24g9lhy.png
This reverts commit f3a96b95d3d48f7d8b8a622858942f9c8c530221.
Change-Id: I41c55e1fead7eb2e47d74095c15cd1685b3337fe
---
libc/netbsd/resolv/res_cache.c | 127 +---------------------------------------
libc/netbsd/resolv/res_send.c | 3 -
libc/private/resolv_cache.h | 6 --
3 files changed, 1 insertion(+), 135 deletions(-)
diff --git a/libc/netbsd/resolv/res_cache.c b/libc/netbsd/resolv/res_cache.c
index 2dcb164..284ca2f 100644
--- a/libc/netbsd/resolv/res_cache.c
+++ b/libc/netbsd/resolv/res_cache.c
@@ -1159,15 +1159,6 @@ entry_equals( const Entry* e1, const Entry* e2 )
* inlined in the Entry structure.
*/
-/* Maximum time for a thread to wait for an pending request */
-#define PENDING_REQUEST_TIMEOUT 20;
-
-typedef struct pending_req_info {
- unsigned int hash;
- pthread_cond_t cond;
- struct pending_req_info* next;
-} PendingReqInfo;
-
typedef struct resolv_cache {
int max_entries;
int num_entries;
@@ -1176,7 +1167,6 @@ typedef struct resolv_cache {
unsigned generation;
int last_id;
Entry* entries;
- PendingReqInfo pending_requests;
} Cache;
typedef struct resolv_cache_info {
@@ -1191,107 +1181,6 @@ typedef struct resolv_cache_info {
#define HTABLE_VALID(x) ((x) != NULL && (x) != HTABLE_DELETED)
static void
-_cache_flush_pending_requests_locked( struct resolv_cache* cache )
-{
- struct pending_req_info *ri, *tmp;
- if (cache) {
- ri = cache->pending_requests.next;
-
- while (ri) {
- tmp = ri;
- ri = ri->next;
- pthread_cond_broadcast(&tmp->cond);
-
- pthread_cond_destroy(&tmp->cond);
- free(tmp);
- }
-
- cache->pending_requests.next = NULL;
- }
-}
-
-/* return 0 if no pending request is found matching the key
- * if a matching request is found the calling thread will wait
- * and return 1 when released */
-static int
-_cache_check_pending_request_locked( struct resolv_cache* cache, Entry* key )
-{
- struct pending_req_info *ri, *prev;
- int exist = 0;
-
- if (cache && key) {
- ri = cache->pending_requests.next;
- prev = &cache->pending_requests;
- while (ri) {
- if (ri->hash == key->hash) {
- exist = 1;
- break;
- }
- prev = ri;
- ri = ri->next;
- }
-
- if (!exist) {
- ri = calloc(1, sizeof(struct pending_req_info));
- if (ri) {
- ri->hash = key->hash;
- pthread_cond_init(&ri->cond, NULL);
- prev->next = ri;
- }
- } else {
- struct timespec ts = {0,0};
- ts.tv_sec = _time_now() + PENDING_REQUEST_TIMEOUT;
- int rv = pthread_cond_timedwait(&ri->cond, &cache->lock, &ts);
- }
- }
-
- return exist;
-}
-
-/* notify any waiting thread that waiting on a request
- * matching the key has been added to the cache */
-static void
-_cache_notify_waiting_tid_locked( struct resolv_cache* cache, Entry* key )
-{
- struct pending_req_info *ri, *prev;
-
- if (cache && key) {
- ri = cache->pending_requests.next;
- prev = &cache->pending_requests;
- while (ri) {
- if (ri->hash == key->hash) {
- pthread_cond_broadcast(&ri->cond);
- break;
- }
- prev = ri;
- ri = ri->next;
- }
-
- // remove item from list and destroy
- if (ri) {
- prev->next = ri->next;
- pthread_cond_destroy(&ri->cond);
- free(ri);
- }
- }
-}
-
-/* notify the cache that the query failed */
-void
-_resolv_cache_query_failed( struct resolv_cache* cache,
- const void* query,
- int querylen)
-{
- Entry key[1];
-
- if (cache && entry_init_key(key, query, querylen)) {
- pthread_mutex_lock(&cache->lock);
- _cache_notify_waiting_tid_locked(cache, key);
- pthread_mutex_unlock(&cache->lock);
- }
-}
-
-static void
_cache_flush_locked( Cache* cache )
{
int nn;
@@ -1308,9 +1197,6 @@ _cache_flush_locked( Cache* cache )
}
}
- // flush pending request
- _cache_flush_pending_requests_locked(cache);
-
cache->mru_list.mru_next = cache->mru_list.mru_prev = &cache->mru_list;
cache->num_entries = 0;
cache->last_id = 0;
@@ -1584,17 +1470,7 @@ _resolv_cache_lookup( struct resolv_cache* cache,
if (e == NULL) {
XLOG( "NOT IN CACHE");
- // calling thread will wait if an outstanding request is found
- // that matching this query
- if (!_cache_check_pending_request_locked(cache, key)) {
- goto Exit;
- } else {
- lookup = _cache_lookup_p(cache, key);
- e = *lookup;
- if (e == NULL) {
- goto Exit;
- }
- }
+ goto Exit;
}
now = _time_now();
@@ -1697,7 +1573,6 @@ _resolv_cache_add( struct resolv_cache* cache,
_cache_dump_mru(cache);
#endif
Exit:
- _cache_notify_waiting_tid_locked(cache, key);
pthread_mutex_unlock( &cache->lock );
}
diff --git a/libc/netbsd/resolv/res_send.c b/libc/netbsd/resolv/res_send.c
index aab7e8f..582c41f 100644
--- a/libc/netbsd/resolv/res_send.c
+++ b/libc/netbsd/resolv/res_send.c
@@ -649,9 +649,6 @@ res_nsend(res_state statp,
errno = terrno;
return (-1);
fail:
-#if USE_RESOLV_CACHE
- _resolv_cache_query_failed(cache, buf, buflen);
-#endif
res_nclose(statp);
return (-1);
}
diff --git a/libc/private/resolv_cache.h b/libc/private/resolv_cache.h
index 1dcc53f..2a54453 100644
--- a/libc/private/resolv_cache.h
+++ b/libc/private/resolv_cache.h
@@ -95,10 +95,4 @@ _resolv_cache_add( struct resolv_cache* cache,
const void* answer,
int answerlen );
-/* Notify the cache a request failed */
-extern void
-_resolv_cache_query_failed( struct resolv_cache* cache,
- const void* query,
- int querylen);
-
#endif /* _RESOLV_CACHE_H_ */
--
1.7.9.5