[ 
https://issues.apache.org/jira/browse/LUCENE-2791?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12966497#action_12966497
 ] 

Native Policeman commented on LUCENE-2791:
------------------------------------------

bq. So bottom line: I disagree with you on everything you said.

This was not against you, but I am hacking native Windows since Win32 was 
started :-)

bq. Yes I do use it, do you understand C ?

I kill you the next time we meet. I am hacking C longer than Java. This was not 
about C it was about the MSDN docs telling something different. See my last 
comment above. Thats all. Why are you so aggresive?

{quote}
bq. Exception handling: in native read, you call throwIOException, when 
ReadFile() returns false. But 2 lines later you still call the method to copy 
the local buffer to the java byte array. JNI docs say, that after an Exception 
is in the thread's local exception, you should not call any JNI methods anymore 
(expect some allowed ones). Also the copy operation is not really needed.

I don't think you know what you are talking about!
{quote}

Sorry we seem to have a misunderstanding. I was *not* talking about the 
internal copy the JVM does. I was talking about the fact, that you should not 
call JNI functions anymore when you set the thread's exception status and exit 
the function as soon as possible. You set this status after the failed ReadFile 
with throwIOEx(). After that its no longer needed to copy the buffer[] to the 
java byte array and its risky to do it because I am not sure if this 
env->SetByteArrayRegion() is safe to be called after exception status is set - 
that all I wanted to say. I would change tha code to:

{code}
if (ReadFile((HANDLE) fd, &buffer, length, &numRead, &io)) {
  env->SetByteArrayRegion(bytes, offset, numRead, (const jbyte *) buffer);
} else {
  throwIOException(env, GetLastError());
  numRead = -1;
}       
{code}

Please note env->throwNew() always returns, it simply sets the thread's 
exception status, so the JVM thorws the Java Exceüption passed in after the 
native method returns to Java bytecode again.

Thanks,
Native Policeman

> WindowsDirectory
> ----------------
>
>                 Key: LUCENE-2791
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2791
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Store
>            Reporter: Robert Muir
>         Attachments: LUCENE-2791.patch, LUCENE-2791.patch, 
> WindowsDirectory.dll, WindowsDirectory_amd64.dll
>
>
> We can use Windows' overlapped IO to do pread() and avoid the performance 
> problems of SimpleFS/NIOFSDir.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to