From: Philip Homburg Date: Mon, 8 Aug 2005 15:49:16 +0000 (+0000) Subject: Fixed mq leak. X-Git-Tag: v3.1.0~398 X-Git-Url: http://zhaoyanbai.com/repos/man.named-checkconf.html?a=commitdiff_plain;h=2f56b477c0629fdeff2387d8a7374db640189ed1;p=minix.git Fixed mq leak. --- diff --git a/servers/inet/inet.c b/servers/inet/inet.c index 2b49fff0b..4c9f38762 100644 --- a/servers/inet/inet.c +++ b/servers/inet/inet.c @@ -249,6 +249,7 @@ PUBLIC void main() { /* signaled */ /* probably SIGTERM */ + mq_free(mq); } #endif else diff --git a/servers/inet/sr.c b/servers/inet/sr.c index c25457d81..1c8d0727f 100644 --- a/servers/inet/sr.c +++ b/servers/inet/sr.c @@ -103,7 +103,7 @@ FORWARD _PROTOTYPE ( int sr_put_userdata, (int fd, vir_bytes offset, FORWARD _PROTOTYPE (void sr_select_res, (int fd, unsigned ops) ); #endif FORWARD _PROTOTYPE ( int sr_repl_queue, (int proc, int ref, int operation) ); -FORWARD _PROTOTYPE ( int walk_queue, (sr_fd_t *sr_fd, mq_t *q_head, +FORWARD _PROTOTYPE ( int walk_queue, (sr_fd_t *sr_fd, mq_t **q_head_ptr, mq_t **q_tail_ptr, int type, int proc_nr, int ref, int first_flag) ); FORWARD _PROTOTYPE ( void process_req_q, (mq_t *mq, mq_t *tail, mq_t **tail_ptr) ); @@ -516,7 +516,7 @@ message *m; if (operation == CANCEL_ANY || operation == DEV_IOCTL3) #endif { - result= walk_queue(sr_fd, sr_fd->srf_ioctl_q, + result= walk_queue(sr_fd, &sr_fd->srf_ioctl_q, &sr_fd->srf_ioctl_q_tail, SR_CANCEL_IOCTL, proc_nr, ref, SFF_IOCTL_FIRST); if (result != EAGAIN) @@ -526,7 +526,7 @@ message *m; if (operation == CANCEL_ANY || operation == DEV_READ) #endif { - result= walk_queue(sr_fd, sr_fd->srf_read_q, + result= walk_queue(sr_fd, &sr_fd->srf_read_q, &sr_fd->srf_read_q_tail, SR_CANCEL_READ, proc_nr, ref, SFF_READ_FIRST); if (result != EAGAIN) @@ -536,7 +536,7 @@ message *m; if (operation == CANCEL_ANY || operation == DEV_WRITE) #endif { - result= walk_queue(sr_fd, sr_fd->srf_write_q, + result= walk_queue(sr_fd, &sr_fd->srf_write_q, &sr_fd->srf_write_q_tail, SR_CANCEL_WRITE, proc_nr, ref, SFF_WRITE_FIRST); if (result != EAGAIN) @@ -656,10 +656,11 @@ message *m; } #endif -PRIVATE int walk_queue(sr_fd, q_head, q_tail_ptr, type, proc_nr, ref, +PRIVATE int walk_queue(sr_fd, q_head_ptr, q_tail_ptr, type, proc_nr, ref, first_flag) sr_fd_t *sr_fd; -mq_t *q_head, **q_tail_ptr; +mq_t **q_head_ptr; +mq_t **q_tail_ptr; int type; int proc_nr; int ref; @@ -668,7 +669,7 @@ int first_flag; mq_t *q_ptr_prv, *q_ptr; int result; - for(q_ptr_prv= NULL, q_ptr= q_head; q_ptr; + for(q_ptr_prv= NULL, q_ptr= *q_head_ptr; q_ptr; q_ptr_prv= q_ptr, q_ptr= q_ptr->mq_next) { if (q_ptr->mq_mess.NDEV_PROC != proc_nr) @@ -685,6 +686,9 @@ int first_flag; result= (*sr_fd->srf_cancel)(sr_fd->srf_fd, type); assert(result == OK); + *q_head_ptr= q_ptr->mq_next; + mq_free(q_ptr); + assert(sr_fd->srf_flags & first_flag); sr_fd->srf_flags &= ~first_flag;