]> git.pld-linux.org Git - packages/squid.git/blob - squid-2.5.STABLE1-aufs.patch
4560a1f09fec829e1c76bce436d464f3 squid-2.5.STABLE1-acl_leak.patch
[packages/squid.git] / squid-2.5.STABLE1-aufs.patch
1 Index: squid/src/fs/aufs/aiops.c
2 diff -c squid/src/fs/aufs/aiops.c:1.12.2.1 squid/src/fs/aufs/aiops.c:1.12.2.2
3 *** squid/src/fs/aufs/aiops.c:1.12.2.1  Sat Jul 20 18:30:03 2002
4 --- squid/src/fs/aufs/aiops.c   Sat Nov  9 03:42:36 2002
5 ***************
6 *** 185,191 ****
7       return p;
8   }
9   
10 ! static void *
11   squidaio_xmalloc(int size)
12   {
13       void *p;
14 --- 185,191 ----
15       return p;
16   }
17   
18 ! void *
19   squidaio_xmalloc(int size)
20   {
21       void *p;
22 ***************
23 *** 211,217 ****
24       return p;
25   }
26   
27 ! static void
28   squidaio_xfree(void *p, int size)
29   {
30       MemPool *pool;
31 --- 211,217 ----
32       return p;
33   }
34   
35 ! void
36   squidaio_xfree(void *p, int size)
37   {
38       MemPool *pool;
39 ***************
40 *** 523,531 ****
41         squidaio_xstrfree(requestp->path);
42         break;
43       case _AIO_OP_READ:
44 -       if (!cancelled && requestp->ret > 0)
45 -           xmemcpy(requestp->bufferp, requestp->tmpbufp, requestp->ret);
46 -       squidaio_xfree(requestp->tmpbufp, requestp->buflen);
47         break;
48       case _AIO_OP_WRITE:
49         squidaio_xfree(requestp->tmpbufp, requestp->buflen);
50 --- 523,528 ----
51 ***************
52 *** 596,602 ****
53       requestp = memPoolAlloc(squidaio_request_pool);
54       requestp->fd = fd;
55       requestp->bufferp = bufp;
56 -     requestp->tmpbufp = (char *) squidaio_xmalloc(bufs);
57       requestp->buflen = bufs;
58       requestp->offset = offset;
59       requestp->whence = whence;
60 --- 593,598 ----
61 ***************
62 *** 613,619 ****
63   squidaio_do_read(squidaio_request_t * requestp)
64   {
65       lseek(requestp->fd, requestp->offset, requestp->whence);
66 !     requestp->ret = read(requestp->fd, requestp->tmpbufp, requestp->buflen);
67       requestp->err = errno;
68   }
69   
70 --- 609,615 ----
71   squidaio_do_read(squidaio_request_t * requestp)
72   {
73       lseek(requestp->fd, requestp->offset, requestp->whence);
74 !     requestp->ret = read(requestp->fd, requestp->bufferp, requestp->buflen);
75       requestp->err = errno;
76   }
77   
78 Index: squid/src/fs/aufs/async_io.c
79 diff -c squid/src/fs/aufs/async_io.c:1.10.2.2 squid/src/fs/aufs/async_io.c:1.10.2.4
80 *** squid/src/fs/aufs/async_io.c:1.10.2.2       Fri Aug 23 16:31:53 2002
81 --- squid/src/fs/aufs/async_io.c        Sun Nov 10 05:06:07 2002
82 ***************
83 *** 53,58 ****
84 --- 53,59 ----
85       AIOCB *done_handler;
86       void *done_handler_data;
87       squidaio_result_t result;
88 +     int len;
89       char *bufp;
90       FREE *free_func;
91       dlink_node node;
92 ***************
93 *** 147,153 ****
94   void
95   aioCancel(int fd)
96   {
97 !     squidaio_ctrl_t *curr;
98       AIOCB *done_handler;
99       void *their_data;
100       dlink_node *m, *next;
101 --- 148,154 ----
102   void
103   aioCancel(int fd)
104   {
105 !     squidaio_ctrl_t *ctrlp;
106       AIOCB *done_handler;
107       void *their_data;
108       dlink_node *m, *next;
109 ***************
110 *** 156,178 ****
111       squidaio_counts.cancel++;
112       for (m = used_list.head; m; m = next) {
113         next = m->next;
114 !       curr = m->data;
115 !       if (curr->fd != fd)
116             continue;
117   
118 !       squidaio_cancel(&curr->result);
119   
120 !       if ((done_handler = curr->done_handler)) {
121 !           their_data = curr->done_handler_data;
122 !           curr->done_handler = NULL;
123 !           curr->done_handler_data = NULL;
124 !           debug(32, 2) ("this be aioCancel\n");
125             if (cbdataValid(their_data))
126 !               done_handler(fd, their_data, -2, -2);
127             cbdataUnlock(their_data);
128         }
129         dlinkDelete(m, &used_list);
130 !       memPoolFree(squidaio_ctrl_pool, curr);
131       }
132   }
133   
134 --- 157,185 ----
135       squidaio_counts.cancel++;
136       for (m = used_list.head; m; m = next) {
137         next = m->next;
138 !       ctrlp = m->data;
139 !       if (ctrlp->fd != fd)
140             continue;
141   
142 !       squidaio_cancel(&ctrlp->result);
143   
144 !       if ((done_handler = ctrlp->done_handler)) {
145 !           their_data = ctrlp->done_handler_data;
146 !           ctrlp->done_handler = NULL;
147 !           ctrlp->done_handler_data = NULL;
148 !           debug(32, 0) ("this be aioCancel. Danger ahead!\n");
149             if (cbdataValid(their_data))
150 !               done_handler(fd, their_data, NULL, -2, -2);
151             cbdataUnlock(their_data);
152 +           /* free data if requested to aioWrite() */
153 +           if (ctrlp->free_func)
154 +               ctrlp->free_func(ctrlp->bufp);
155 +           /* free temporary read buffer */
156 +           if (ctrlp->operation == _AIO_READ)
157 +               squidaio_xfree(ctrlp->bufp, ctrlp->len);
158         }
159         dlinkDelete(m, &used_list);
160 !       memPoolFree(squidaio_ctrl_pool, ctrlp);
161       }
162   }
163   
164 ***************
165 *** 206,212 ****
166   
167   
168   void
169 ! aioRead(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callback_data)
170   {
171       squidaio_ctrl_t *ctrlp;
172       int seekmode;
173 --- 213,219 ----
174   
175   
176   void
177 ! aioRead(int fd, int offset, int len, AIOCB * callback, void *callback_data)
178   {
179       squidaio_ctrl_t *ctrlp;
180       int seekmode;
181 ***************
182 *** 218,223 ****
183 --- 225,232 ----
184       ctrlp->done_handler = callback;
185       ctrlp->done_handler_data = callback_data;
186       ctrlp->operation = _AIO_READ;
187 +     ctrlp->len = len;
188 +     ctrlp->bufp = squidaio_xmalloc(len);
189       if (offset >= 0)
190         seekmode = SEEK_SET;
191       else {
192 ***************
193 *** 226,232 ****
194       }
195       cbdataLock(callback_data);
196       ctrlp->result.data = ctrlp;
197 !     squidaio_read(fd, bufp, len, offset, seekmode, &ctrlp->result);
198       dlinkAdd(ctrlp, &ctrlp->node, &used_list);
199       return;
200   }                             /* aioRead */
201 --- 235,241 ----
202       }
203       cbdataLock(callback_data);
204       ctrlp->result.data = ctrlp;
205 !     squidaio_read(fd, ctrlp->bufp, len, offset, seekmode, &ctrlp->result);
206       dlinkAdd(ctrlp, &ctrlp->node, &used_list);
207       return;
208   }                             /* aioRead */
209 ***************
210 *** 309,322 ****
211             ctrlp->done_handler_data = NULL;
212             if (cbdataValid(their_data)) {
213                 retval = 1;     /* Return that we've actually done some work */
214 !               done_handler(ctrlp->fd, their_data,
215                     ctrlp->result.aio_return, ctrlp->result.aio_errno);
216             }
217             cbdataUnlock(their_data);
218         }
219         /* free data if requested to aioWrite() */
220         if (ctrlp->free_func)
221             ctrlp->free_func(ctrlp->bufp);
222         if (ctrlp->operation == _AIO_CLOSE)
223             aioFDWasClosed(ctrlp->fd);
224         memPoolFree(squidaio_ctrl_pool, ctrlp);
225 --- 318,341 ----
226             ctrlp->done_handler_data = NULL;
227             if (cbdataValid(their_data)) {
228                 retval = 1;     /* Return that we've actually done some work */
229 !               done_handler(ctrlp->fd, their_data, ctrlp->bufp,
230                     ctrlp->result.aio_return, ctrlp->result.aio_errno);
231 +           } else {
232 +               if (ctrlp->operation == _AIO_OPEN) {
233 +                   /* The open operation was aborted.. */
234 +                   int fd = ctrlp->result.aio_return;
235 +                   if (fd >= 0)
236 +                       aioClose(fd);
237 +               }
238             }
239             cbdataUnlock(their_data);
240         }
241         /* free data if requested to aioWrite() */
242         if (ctrlp->free_func)
243             ctrlp->free_func(ctrlp->bufp);
244 +       /* free temporary read buffer */
245 +       if (ctrlp->operation == _AIO_READ)
246 +           squidaio_xfree(ctrlp->bufp, ctrlp->len);
247         if (ctrlp->operation == _AIO_CLOSE)
248             aioFDWasClosed(ctrlp->fd);
249         memPoolFree(squidaio_ctrl_pool, ctrlp);
250 Index: squid/src/fs/aufs/store_asyncufs.h
251 diff -c squid/src/fs/aufs/store_asyncufs.h:1.9 squid/src/fs/aufs/store_asyncufs.h:1.9.2.1
252 *** squid/src/fs/aufs/store_asyncufs.h:1.9      Fri Aug 24 08:29:35 2001
253 --- squid/src/fs/aufs/store_asyncufs.h  Sat Nov  9 03:42:36 2002
254 ***************
255 *** 34,40 ****
256   
257   typedef struct _squidaio_result_t squidaio_result_t;
258   
259 ! typedef void AIOCB(int fd, void *, int aio_return, int aio_errno);
260   
261   int squidaio_cancel(squidaio_result_t *);
262   int squidaio_open(const char *, int, mode_t, squidaio_result_t *);
263 --- 34,40 ----
264   
265   typedef struct _squidaio_result_t squidaio_result_t;
266   
267 ! typedef void AIOCB(int fd, void *cbdata, const char *buf, int aio_return, int aio_errno);
268   
269   int squidaio_cancel(squidaio_result_t *);
270   int squidaio_open(const char *, int, mode_t, squidaio_result_t *);
271 ***************
272 *** 49,54 ****
273 --- 49,56 ----
274   int squidaio_operations_pending(void);
275   int squidaio_sync(void);
276   int squidaio_get_queue_len(void);
277 + void *squidaio_xmalloc(int size);
278 + void squidaio_xfree(void *p, int size);
279   
280   void aioInit(void);
281   void aioDone(void);
282 ***************
283 *** 56,62 ****
284   void aioOpen(const char *, int, mode_t, AIOCB *, void *);
285   void aioClose(int);
286   void aioWrite(int, int offset, char *, int size, AIOCB *, void *, FREE *);
287 ! void aioRead(int, int offset, char *, int size, AIOCB *, void *);
288   void aioStat(char *, struct stat *, AIOCB *, void *);
289   void aioUnlink(const char *, AIOCB *, void *);
290   void aioTruncate(const char *, off_t length, AIOCB *, void *);
291 --- 58,64 ----
292   void aioOpen(const char *, int, mode_t, AIOCB *, void *);
293   void aioClose(int);
294   void aioWrite(int, int offset, char *, int size, AIOCB *, void *, FREE *);
295 ! void aioRead(int, int offset, int size, AIOCB *, void *);
296   void aioStat(char *, struct stat *, AIOCB *, void *);
297   void aioUnlink(const char *, AIOCB *, void *);
298   void aioTruncate(const char *, off_t length, AIOCB *, void *);
299 ***************
300 *** 83,89 ****
301         unsigned int read_kicking:1;
302         unsigned int inreaddone:1;
303       } flags;
304 !     const char *read_buf;
305       link_list *pending_writes;
306       link_list *pending_reads;
307   };
308 --- 85,91 ----
309         unsigned int read_kicking:1;
310         unsigned int inreaddone:1;
311       } flags;
312 !     char *read_buf;
313       link_list *pending_writes;
314       link_list *pending_reads;
315   };
316 Index: squid/src/fs/aufs/store_io_aufs.c
317 diff -c squid/src/fs/aufs/store_io_aufs.c:1.15.2.5 squid/src/fs/aufs/store_io_aufs.c:1.15.2.9
318 *** squid/src/fs/aufs/store_io_aufs.c:1.15.2.5  Sun Aug 11 17:14:35 2002
319 --- squid/src/fs/aufs/store_io_aufs.c   Thu Nov 14 23:33:25 2002
320 ***************
321 *** 18,24 ****
322   #endif
323   static void storeAufsIOCallback(storeIOState * sio, int errflag);
324   static AIOCB storeAufsOpenDone;
325 ! static int storeAufsSomethingPending(storeIOState *);
326   static int storeAufsKickWriteQueue(storeIOState * sio);
327   static CBDUNL storeAufsIOFreeEntry;
328   
329 --- 18,24 ----
330   #endif
331   static void storeAufsIOCallback(storeIOState * sio, int errflag);
332   static AIOCB storeAufsOpenDone;
333 ! static int storeAufsNeedCompletetion(storeIOState *);
334   static int storeAufsKickWriteQueue(storeIOState * sio);
335   static CBDUNL storeAufsIOFreeEntry;
336   
337 ***************
338 *** 141,147 ****
339       squidaiostate_t *aiostate = (squidaiostate_t *) sio->fsstate;
340       debug(79, 3) ("storeAufsClose: dirno %d, fileno %08X, FD %d\n",
341         sio->swap_dirn, sio->swap_filen, aiostate->fd);
342 !     if (storeAufsSomethingPending(sio)) {
343         aiostate->flags.close_request = 1;
344         return;
345       }
346 --- 141,147 ----
347       squidaiostate_t *aiostate = (squidaiostate_t *) sio->fsstate;
348       debug(79, 3) ("storeAufsClose: dirno %d, fileno %08X, FD %d\n",
349         sio->swap_dirn, sio->swap_filen, aiostate->fd);
350 !     if (storeAufsNeedCompletetion(sio)) {
351         aiostate->flags.close_request = 1;
352         return;
353       }
354 ***************
355 *** 168,173 ****
356 --- 168,174 ----
357         q->offset = offset;
358         q->callback = callback;
359         q->callback_data = callback_data;
360 +       cbdataLock(q->callback_data);
361         linklistPush(&(aiostate->pending_reads), q);
362         return;
363       }
364 ***************
365 *** 180,186 ****
366       sio->offset = offset;
367       aiostate->flags.reading = 1;
368   #if ASYNC_READ
369 !     aioRead(aiostate->fd, offset, buf, size, storeAufsReadDone, sio);
370   #else
371       file_read(aiostate->fd, buf, size, offset, storeAufsReadDone, sio);
372   #endif
373 --- 181,187 ----
374       sio->offset = offset;
375       aiostate->flags.reading = 1;
376   #if ASYNC_READ
377 !     aioRead(aiostate->fd, offset, size, storeAufsReadDone, sio);
378   #else
379       file_read(aiostate->fd, buf, size, offset, storeAufsReadDone, sio);
380   #endif
381 ***************
382 *** 262,274 ****
383         return 0;
384       debug(79, 3) ("storeAufsKickReadQueue: reading queued request of %ld bytes\n",
385         (long int) q->size);
386 !     storeAufsRead(INDEXSD(sio->swap_dirn), sio, q->buf, q->size, q->offset, q->callback, q->callback_data);
387       memPoolFree(aufs_qread_pool, q);
388       return 1;
389   }
390   
391   static void
392 ! storeAufsOpenDone(int unused, void *my_data, int fd, int errflag)
393   {
394       storeIOState *sio = my_data;
395       squidaiostate_t *aiostate = (squidaiostate_t *) sio->fsstate;
396 --- 263,277 ----
397         return 0;
398       debug(79, 3) ("storeAufsKickReadQueue: reading queued request of %ld bytes\n",
399         (long int) q->size);
400 !     if (cbdataValid(q->callback_data))
401 !       storeAufsRead(INDEXSD(sio->swap_dirn), sio, q->buf, q->size, q->offset, q->callback, q->callback_data);
402 !     cbdataUnlock(q->callback_data);
403       memPoolFree(aufs_qread_pool, q);
404       return 1;
405   }
406   
407   static void
408 ! storeAufsOpenDone(int unused, void *my_data, const char *unused2, int fd, int errflag)
409   {
410       storeIOState *sio = my_data;
411       squidaiostate_t *aiostate = (squidaiostate_t *) sio->fsstate;
412 ***************
413 *** 289,295 ****
414       if (FILE_MODE(sio->mode) == O_WRONLY) {
415         if (storeAufsKickWriteQueue(sio))
416             return;
417 !     } else if (FILE_MODE(sio->mode) == O_RDONLY) {
418         if (storeAufsKickReadQueue(sio))
419             return;
420       }
421 --- 292,298 ----
422       if (FILE_MODE(sio->mode) == O_WRONLY) {
423         if (storeAufsKickWriteQueue(sio))
424             return;
425 !     } else if ((FILE_MODE(sio->mode) == O_RDONLY) && !aiostate->flags.close_request) {
426         if (storeAufsKickReadQueue(sio))
427             return;
428       }
429 ***************
430 *** 300,306 ****
431   
432   #if ASYNC_READ
433   static void
434 ! storeAufsReadDone(int fd, void *my_data, int len, int errflag)
435   #else
436   static void
437   storeAufsReadDone(int fd, const char *buf, int len, int errflag, void *my_data)
438 --- 303,309 ----
439   
440   #if ASYNC_READ
441   static void
442 ! storeAufsReadDone(int fd, void *my_data, const char *buf, int len, int errflag)
443   #else
444   static void
445   storeAufsReadDone(int fd, const char *buf, int len, int errflag, void *my_data)
446 ***************
447 *** 311,316 ****
448 --- 314,320 ----
449       STRCB *callback = sio->read.callback;
450       void *their_data = sio->read.callback_data;
451       ssize_t rlen;
452 +     int inreaddone = aiostate->flags.inreaddone;      /* Protect from callback loops */
453       debug(79, 3) ("storeAufsReadDone: dirno %d, fileno %08X, FD %d, len %d\n",
454         sio->swap_dirn, sio->swap_filen, fd, len);
455       aiostate->flags.inreaddone = 1;
456 ***************
457 *** 337,347 ****
458       assert(their_data);
459       sio->read.callback = NULL;
460       sio->read.callback_data = NULL;
461 !     if (cbdataValid(their_data))
462         callback(their_data, aiostate->read_buf, rlen);
463       cbdataUnlock(their_data);
464       aiostate->flags.inreaddone = 0;
465 !     if (aiostate->flags.close_request)
466         storeAufsIOCallback(sio, errflag);
467   }
468   
469 --- 341,356 ----
470       assert(their_data);
471       sio->read.callback = NULL;
472       sio->read.callback_data = NULL;
473 !     if (!aiostate->flags.close_request && cbdataValid(their_data)) {
474 ! #if ASYNC_READ
475 !       if (rlen > 0)
476 !           memcpy(aiostate->read_buf, buf, rlen);
477 ! #endif
478         callback(their_data, aiostate->read_buf, rlen);
479 +     }
480       cbdataUnlock(their_data);
481       aiostate->flags.inreaddone = 0;
482 !     if (aiostate->flags.close_request && !inreaddone)
483         storeAufsIOCallback(sio, errflag);
484   }
485   
486 ***************
487 *** 403,438 ****
488       debug(79, 3) ("storeAufsIOCallback: errflag=%d\n", errflag);
489       sio->callback = NULL;
490       sio->callback_data = NULL;
491 !     debug(79, 3) ("%s:%d\n", __FILE__, __LINE__);
492       if (callback)
493         if (NULL == their_data || cbdataValid(their_data))
494             callback(their_data, errflag, sio);
495 !     debug(79, 3) ("%s:%d\n", __FILE__, __LINE__);
496       cbdataUnlock(their_data);
497       aiostate->fd = -1;
498       cbdataFree(sio);
499       if (fd < 0)
500         return;
501 !     debug(79, 3) ("%s:%d\n", __FILE__, __LINE__);
502       aioClose(fd);
503       fd_close(fd);
504       store_open_disk_fd--;
505 !     debug(79, 3) ("%s:%d\n", __FILE__, __LINE__);
506   }
507   
508   
509   static int
510 ! storeAufsSomethingPending(storeIOState * sio)
511   {
512       squidaiostate_t *aiostate = (squidaiostate_t *) sio->fsstate;
513 !     if (aiostate->flags.reading)
514 !       return 1;
515       if (aiostate->flags.writing)
516         return 1;
517 !     if (aiostate->flags.opening)
518         return 1;
519       if (aiostate->flags.inreaddone)
520         return 1;
521       return 0;
522   }
523   
524 --- 412,451 ----
525       debug(79, 3) ("storeAufsIOCallback: errflag=%d\n", errflag);
526       sio->callback = NULL;
527       sio->callback_data = NULL;
528 !     debug(79, 9) ("%s:%d\n", __FILE__, __LINE__);
529       if (callback)
530         if (NULL == their_data || cbdataValid(their_data))
531             callback(their_data, errflag, sio);
532 !     debug(79, 9) ("%s:%d\n", __FILE__, __LINE__);
533       cbdataUnlock(their_data);
534       aiostate->fd = -1;
535       cbdataFree(sio);
536 +     if (aiostate->flags.opening)
537 +       Opening_FD--;
538       if (fd < 0)
539         return;
540 !     debug(79, 9) ("%s:%d\n", __FILE__, __LINE__);
541       aioClose(fd);
542       fd_close(fd);
543       store_open_disk_fd--;
544 !     debug(79, 9) ("%s:%d\n", __FILE__, __LINE__);
545   }
546   
547   
548   static int
549 ! storeAufsNeedCompletetion(storeIOState * sio)
550   {
551       squidaiostate_t *aiostate = (squidaiostate_t *) sio->fsstate;
552
553       if (aiostate->flags.writing)
554         return 1;
555 !     if (aiostate->flags.opening && FILE_MODE(sio->mode) == O_WRONLY)
556 !       return 1;
557 !     if (aiostate->flags.reading)
558         return 1;
559       if (aiostate->flags.inreaddone)
560         return 1;
561
562       return 0;
563   }
564   
565 ***************
566 *** 443,449 ****
567    * to bother with that.
568    */
569   static void
570 ! storeAufsIOFreeEntry(void *sio)
571   {
572 !     memPoolFree(squidaio_state_pool, ((storeIOState *) sio)->fsstate);
573   }
574 --- 456,479 ----
575    * to bother with that.
576    */
577   static void
578 ! storeAufsIOFreeEntry(void *siop)
579   {
580 !     storeIOState *sio = (storeIOState *) siop;
581 !     squidaiostate_t *aiostate = (squidaiostate_t *) sio->fsstate;
582 !     struct _queued_write *qw;
583 !     struct _queued_read *qr;
584 !     while ((qw = linklistShift(&aiostate->pending_writes))) {
585 !       if (qw->free_func)
586 !           qw->free_func(qw->buf);
587 !       memPoolFree(aufs_qwrite_pool, qw);
588 !     }
589 !     while ((qr = linklistShift(&aiostate->pending_reads))) {
590 !       cbdataUnlock(qr->callback_data);
591 !       memPoolFree(aufs_qread_pool, qr);
592 !     }
593 !     if (sio->read.callback_data)
594 !       cbdataUnlock(sio->read.callback_data);
595 !     if (sio->callback_data)
596 !       cbdataUnlock(sio->callback_data);
597 !     memPoolFree(squidaio_state_pool, aiostate);
598   }
This page took 0.074123 seconds and 3 git commands to generate.