Mon Sep 5 14:13:50 2016 UTC ()
don't forget to destroy a cv


(christos)
diff -r1.70 -r1.71 src/sys/kern/sysv_msg.c

cvs diff -r1.70 -r1.71 src/sys/kern/sysv_msg.c (expand / switch to unified diff)

--- src/sys/kern/sysv_msg.c 2015/11/06 02:26:42 1.70
+++ src/sys/kern/sysv_msg.c 2016/09/05 14:13:50 1.71
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sysv_msg.c,v 1.70 2015/11/06 02:26:42 pgoyette Exp $ */ 1/* $NetBSD: sysv_msg.c,v 1.71 2016/09/05 14:13:50 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2006, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999, 2006, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center, and by Andrew Doran. 9 * NASA Ames Research Center, and by Andrew Doran.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -40,27 +40,27 @@ @@ -40,27 +40,27 @@
40 * This system call was implemented by Daniel Boulet under contract from RTMX. 40 * This system call was implemented by Daniel Boulet under contract from RTMX.
41 * 41 *
42 * Redistribution and use in source forms, with and without modification, 42 * Redistribution and use in source forms, with and without modification,
43 * are permitted provided that this entire comment appears intact. 43 * are permitted provided that this entire comment appears intact.
44 * 44 *
45 * Redistribution in binary form may occur without any restrictions. 45 * Redistribution in binary form may occur without any restrictions.
46 * Obviously, it would be nice if you gave credit where credit is due 46 * Obviously, it would be nice if you gave credit where credit is due
47 * but requiring it would be too onerous. 47 * but requiring it would be too onerous.
48 * 48 *
49 * This software is provided ``AS IS'' without any warranties of any kind. 49 * This software is provided ``AS IS'' without any warranties of any kind.
50 */ 50 */
51 51
52#include <sys/cdefs.h> 52#include <sys/cdefs.h>
53__KERNEL_RCSID(0, "$NetBSD: sysv_msg.c,v 1.70 2015/11/06 02:26:42 pgoyette Exp $"); 53__KERNEL_RCSID(0, "$NetBSD: sysv_msg.c,v 1.71 2016/09/05 14:13:50 christos Exp $");
54 54
55#ifdef _KERNEL_OPT 55#ifdef _KERNEL_OPT
56#include "opt_sysv.h" 56#include "opt_sysv.h"
57#endif 57#endif
58 58
59#include <sys/param.h> 59#include <sys/param.h>
60#include <sys/kernel.h> 60#include <sys/kernel.h>
61#include <sys/msg.h> 61#include <sys/msg.h>
62#include <sys/sysctl.h> 62#include <sys/sysctl.h>
63#include <sys/mount.h> /* XXX for <sys/syscallargs.h> */ 63#include <sys/mount.h> /* XXX for <sys/syscallargs.h> */
64#include <sys/syscallargs.h> 64#include <sys/syscallargs.h>
65#include <sys/kauth.h> 65#include <sys/kauth.h>
66 66
@@ -185,26 +185,27 @@ msgfini(void) @@ -185,26 +185,27 @@ msgfini(void)
185/* 185/*
186 * Destroy all condvars and free the memory we're using 186 * Destroy all condvars and free the memory we're using
187 */ 187 */
188 for (i = 0; i < msginfo.msgmni; i++) { 188 for (i = 0; i < msginfo.msgmni; i++) {
189 cv_destroy(&msqs[i].msq_cv); 189 cv_destroy(&msqs[i].msq_cv);
190 } 190 }
191 sz = ALIGN(msginfo.msgmax) + 191 sz = ALIGN(msginfo.msgmax) +
192 ALIGN(msginfo.msgseg * sizeof(struct msgmap)) + 192 ALIGN(msginfo.msgseg * sizeof(struct msgmap)) +
193 ALIGN(msginfo.msgtql * sizeof(struct __msg)) + 193 ALIGN(msginfo.msgtql * sizeof(struct __msg)) +
194 ALIGN(msginfo.msgmni * sizeof(kmsq_t)); 194 ALIGN(msginfo.msgmni * sizeof(kmsq_t));
195 sz = round_page(sz); 195 sz = round_page(sz);
196 uvm_km_free(kernel_map, v, sz, UVM_KMF_WIRED); 196 uvm_km_free(kernel_map, v, sz, UVM_KMF_WIRED);
197 197
 198 cv_destroy(&msg_realloc_cv);
198 mutex_exit(&msgmutex); 199 mutex_exit(&msgmutex);
199 mutex_destroy(&msgmutex); 200 mutex_destroy(&msgmutex);
200 201
201 kern_has_sysvmsg = 0; 202 kern_has_sysvmsg = 0;
202 203
203 return 0; 204 return 0;
204} 205}
205 206
206static int 207static int
207msgrealloc(int newmsgmni, int newmsgseg) 208msgrealloc(int newmsgmni, int newmsgseg)
208{ 209{
209 struct msgmap *new_msgmaps; 210 struct msgmap *new_msgmaps;
210 struct __msg *new_msghdrs, *new_free_msghdrs; 211 struct __msg *new_msghdrs, *new_free_msghdrs;