Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 4936 invoked from network); 14 Dec 2009 07:08:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Dec 2009 07:08:18 -0000 Received: (qmail 71135 invoked by uid 500); 14 Dec 2009 07:08:18 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 71006 invoked by uid 500); 14 Dec 2009 07:08:17 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 70997 invoked by uid 99); 14 Dec 2009 07:08:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Dec 2009 07:08:17 +0000 X-ASF-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Dec 2009 07:08:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 136F523889D1; Mon, 14 Dec 2009 07:07:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r890200 - in /commons/sandbox/runtime/trunk/src/main/native/os/win32: mmap.c shm.c Date: Mon, 14 Dec 2009 07:07:54 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091214070755.136F523889D1@eris.apache.org> Author: mturk Date: Mon Dec 14 07:07:54 2009 New Revision: 890200 URL: http://svn.apache.org/viewvc?rev=890200&view=rev Log: Do not close descriptors twice Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c?rev=890200&r1=890199&r2=890200&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c Mon Dec 14 07:07:54 2009 @@ -56,7 +56,7 @@ static int mmap_cleanup(void *map, int type, unsigned int flags) { - int rc = 0; + int rc = ACR_EBADF; acr_mmap_t *m = (acr_mmap_t *)map; if (type != ACR_DT_MMAP) { @@ -65,14 +65,25 @@ if (IS_VALID_MEMORY(m->base)) { if (!UnmapViewOfFile(m->base)) rc = ACR_GET_OS_ERROR(); + else + rc = ACR_SUCCESS; + m->base = NULL; } - if (!CloseHandle(m->mh)) - rc = ACR_GET_OS_ERROR(); - if ((flags & MMAP_OWNS_FILE)) { + if (IS_VALID_HANDLE(m->mh)) { + if (!CloseHandle(m->mh)) + rc = rc ? rc : ACR_GET_OS_ERROR(); + else + rc = rc ? rc : ACR_SUCCESS; + m->mh = INVALID_HANDLE_VALUE; + } + if ((flags & MMAP_OWNS_FILE) && IS_VALID_HANDLE(m->fd)) { /* Since we have opended the file close it. */ if (!CloseHandle(m->fd)) - rc = ACR_GET_OS_ERROR(); + rc = rc ? rc : ACR_GET_OS_ERROR(); + else + rc = rc ? rc : ACR_SUCCESS; + m->fd = INVALID_HANDLE_VALUE; } if (flags & ACR_IOH_CLEAR) x_free(m); Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c?rev=890200&r1=890199&r2=890200&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c Mon Dec 14 07:07:54 2009 @@ -59,17 +59,25 @@ static int shm_cleanup(void *shm, int type, unsigned int flags) { - int rc = 0; + int rc = ACR_EBADF; acr_shm_t *m = (acr_shm_t *)shm; if (type != ACR_DT_SHM) { return ACR_EFTYPE; } - if (m->memblk && !UnmapViewOfFile(m->memblk)) { - rc = ACR_GET_OS_ERROR(); - } - if (!CloseHandle(m->hmap) && rc == 0) { - rc = ACR_GET_OS_ERROR(); + if (IS_VALID_HANDLE(m->memblk)) { + if (!UnmapViewOfFile(m->memblk)) + rc = ACR_GET_OS_ERROR(); + else + rc = ACR_SUCCESS; + m->memblk = NULL; + } + if (IS_VALID_HANDLE(m->hmap)) { + if (!CloseHandle(m->hmap)) + rc = rc ? rc : ACR_GET_OS_ERROR(); + else + rc = rc ? rc : ACR_SUCCESS; + m->hmap = NULL; } if (m->filename) { /* Remove file if file backed. @@ -80,14 +88,11 @@ x_free((void *)(m->filename)); m->filename = NULL; } - m->memblk = NULL; - m->hmap = NULL; if (flags & ACR_IOH_CLEAR) x_free(m); return rc; } - ACR_DECLARE(int) ACR_ShmClose(JNIEnv *_E, int shm) { int rc;