]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/glibc/glibc-rh863453.patch
dhcpcd: fix delay after dhcp down.
[ipfire-2.x.git] / src / patches / glibc / glibc-rh863453.patch
1 --- glibc-2.12-2-gc4ccff1/nscd/grpcache.c.lrgrpissue 2002-03-19 01:06:04.905969517 +0530
2 +++ glibc-2.12-2-gc4ccff1/nscd/grpcache.c 2002-03-19 01:09:46.495970850 +0530
3 @@ -207,10 +207,11 @@ cache_addgr (struct database_dyn *db, in
4 change. Allocate memory on the cache since it is likely
5 discarded anyway. If it turns out to be necessary to have a
6 new record we can still allocate real memory. */
7 - bool dataset_in_stack_or_freed = false;
8 + bool dataset_temporary = false;
9 + bool dataset_malloced = false;
10 dataset = NULL;
11
12 - if (he == NULL || ! __libc_use_alloca (alloca_used + total + n))
13 + if (he == NULL)
14 dataset = (struct dataset *) mempool_alloc (db, total + n, 1);
15
16 if (dataset == NULL)
17 @@ -218,10 +219,16 @@ cache_addgr (struct database_dyn *db, in
18 /* We cannot permanently add the result in the moment. But
19 we can provide the result as is. Store the data in some
20 temporary memory. */
21 - dataset = (struct dataset *) alloca_account (total + n, alloca_used);
22 -
23 + if (! __libc_use_alloca (alloca_used + total + n))
24 + {
25 + /* XXX What to do if malloc fails? */
26 + dataset = (struct dataset *) malloc (total + n);
27 + dataset_malloced = true;
28 + }
29 + else
30 + dataset = (struct dataset *) alloca_account (total + n, alloca_used);
31 /* We cannot add this record to the permanent database. */
32 - dataset_in_stack_or_freed = true;
33 + dataset_temporary = true;
34 }
35
36 dataset->head.allocsize = total + n;
37 @@ -276,13 +283,10 @@ cache_addgr (struct database_dyn *db, in
38 dh->timeout = dataset->head.timeout;
39 ++dh->nreloads;
40
41 - /* If the new record was not allocated on the stack, then it must
42 - be freed. Note that it can no longer be used. */
43 - if (! dataset_in_stack_or_freed)
44 - {
45 - free (dataset);
46 - dataset_in_stack_or_freed = true;
47 - }
48 + /* If the new record was allocated via malloc, then we
49 + must free it here. */
50 + if (dataset_malloced)
51 + free (dataset);
52 }
53 else
54 {
55 @@ -298,7 +302,7 @@ cache_addgr (struct database_dyn *db, in
56 key_copy = (char *) newp + (key_copy - (char *) dataset);
57
58 dataset = memcpy (newp, dataset, total + n);
59 - dataset_in_stack_or_freed = false;
60 + dataset_temporary = false;
61 }
62
63 /* Mark the old record as obsolete. */
64 @@ -313,7 +317,7 @@ cache_addgr (struct database_dyn *db, in
65 assert (fd != -1);
66
67 #ifdef HAVE_SENDFILE
68 - if (__builtin_expect (db->mmap_used, 1) && !dataset_in_stack_or_freed)
69 + if (__builtin_expect (db->mmap_used, 1) && ! dataset_temporary)
70 {
71 assert (db->wr_fd != -1);
72 assert ((char *) &dataset->resp > (char *) db->data);
73 @@ -340,7 +344,7 @@ cache_addgr (struct database_dyn *db, in
74
75 /* Add the record to the database. But only if it has not been
76 stored on the stack. */
77 - if (! dataset_in_stack_or_freed)
78 + if (! dataset_temporary)
79 {
80 /* If necessary, we also propagate the data to disk. */
81 if (db->persistent)