Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 34546 invoked from network); 20 Jul 2006 09:44:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jul 2006 09:44:27 -0000 Received: (qmail 32198 invoked by uid 500); 20 Jul 2006 09:44:27 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 32111 invoked by uid 500); 20 Jul 2006 09:44:26 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 32055 invoked by uid 99); 20 Jul 2006 09:44:26 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Jul 2006 02:44:26 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Jul 2006 02:44:26 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 18B881A981A; Thu, 20 Jul 2006 02:44:06 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r423857 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c Date: Thu, 20 Jul 2006 09:44:05 -0000 To: harmony-commits@incubator.apache.org From: pyang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060720094406.18B881A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: pyang Date: Thu Jul 20 02:44:05 2006 New Revision: 423857 URL: http://svn.apache.org/viewvc?rev=423857&view=rev Log: Fix for HARMONY-929 ([classlib][nio]FileChannel.transforTo can use system call to improve efficiency) Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c?rev=423857&r1=423856&r2=423857&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c Thu Jul 20 02:44:05 2006 @@ -210,37 +210,35 @@ (JNIEnv *env, jobject thiz, jlong fd, jobject sd, jlong offset, jlong count) { PORT_ACCESS_FROM_ENV (env); - int length =0; - HANDLE hfile = (HANDLE)fd; - OVERLAPPED overlapped; + HANDLE hfile = (HANDLE)fd; SOCKET socket; - //TODO IPV6 - - hysocket_t hysocketP = getJavaIoFileDescriptorContentsAsPointer(env,sd); - if (!hysock_socketIsValid (hysocketP)){ - printf("not valid socket\n"); + hysocket_t hysocketP; + DWORD pos_high = 0; + DWORD pos_low = 0; + + if(0 !=(count>>31)) { + count = 0x7FFFFFFF; } - printf("hysocketP:%p\n",hysocketP); - if(hysocketP == NULL) - { - printf("Error getJavaIoFileDescriptorContentsAsPointer!\n"); - return -1;} - - socket = (SOCKET)hysocketP->ipv4; - printf("socket:%p\n",socket); - overlapped.Offset = (int)offset; - overlapped.OffsetHigh = (int)(offset>>32); - TransmitFile(socket,hfile,(int)count,0,&overlapped,NULL,0); - printf("TrasmitFile Error %d\n",GetLastError()); - if(GetOverlappedResult((HANDLE)socket,&overlapped,(LPDWORD)&length,1)) - { - return length; //OK + hysocketP = getJavaIoFileDescriptorContentsAsPointer(env,sd); + socket = (SOCKET)hysocketP->ipv4; + + pos_low = SetFilePointer(hfile,0,&pos_high,FILE_CURRENT); + if(INVALID_SET_FILE_POINTER == pos_low){ + return -1; + } + + if(INVALID_SET_FILE_POINTER == SetFilePointer(hfile,(DWORD)offset,(DWORD *)(((BYTE *)&offset)+4),FILE_BEGIN)){ + return -1; } - else - { - printf("GetOverlappedResult Error %d\n",GetLastError()); - return -1;//ERROR + + if(!TransmitFile(socket,hfile,(DWORD)count,0,NULL,NULL,0)){ + return -1; + } + + if(INVALID_SET_FILE_POINTER == SetFilePointer(hfile,pos_low,&pos_high,FILE_BEGIN)){ + return -1; } + return count; }