aboutsummaryrefslogtreecommitdiff
path: root/comms/rxtx
diff options
context:
space:
mode:
authorSteve Price <steve@FreeBSD.org>2011-01-03 18:55:09 +0000
committerSteve Price <steve@FreeBSD.org>2011-01-03 18:55:09 +0000
commit68dd236cc95f01daeeb2d2a58df653be16cec122 (patch)
tree3f6023c770faf70a3f4fadf46c69064aa7266134 /comms/rxtx
parent6df2b5108cba1b5b1ec013282e874b68775e92c1 (diff)
downloadports-68dd236cc95f01daeeb2d2a58df653be16cec122.tar.gz
ports-68dd236cc95f01daeeb2d2a58df653be16cec122.zip
Notes
Diffstat (limited to 'comms/rxtx')
-rw-r--r--comms/rxtx/Makefile2
-rw-r--r--comms/rxtx/files/patch-SerialImp.c159
-rw-r--r--comms/rxtx/files/patch-SerialImp.cpp53
-rw-r--r--comms/rxtx/files/patch-SerialImp.h16
4 files changed, 229 insertions, 1 deletions
diff --git a/comms/rxtx/Makefile b/comms/rxtx/Makefile
index 52b91b652eb2..9e1f9516c488 100644
--- a/comms/rxtx/Makefile
+++ b/comms/rxtx/Makefile
@@ -7,7 +7,7 @@
PORTNAME= rxtx
PORTVERSION= 2.1.7r2
-PORTREVISION= 6
+PORTREVISION= 7
CATEGORIES= comms java
MASTER_SITES= ftp://jarvi.dsl.frii.com/pub/rxtx/
PKGNAMESUFFIX= -${JAVA_PORT:S/java\///}
diff --git a/comms/rxtx/files/patch-SerialImp.c b/comms/rxtx/files/patch-SerialImp.c
new file mode 100644
index 000000000000..9a7f0495b59b
--- /dev/null
+++ b/comms/rxtx/files/patch-SerialImp.c
@@ -0,0 +1,159 @@
+--- src/SerialImp.c.orig 2006-01-29 14:19:04.000000000 -0800
++++ src/SerialImp.c 2010-12-05 22:41:39.000000000 -0800
+@@ -1528,11 +1528,11 @@
+ ----------------------------------------------------------*/
+ JNIEXPORT jboolean JNICALL RXTXPort(nativeDrain)( JNIEnv *env,
+ jobject jobj, jboolean interrupted )
+ {
+ int fd = get_java_var( env, jobj,"fd","I" );
+- struct event_info_struct *eis = ( struct event_info_struct * ) get_java_var( env, jobj, "eis", "J" );
++ struct event_info_struct *eis = ( struct event_info_struct * ) get_java_varP( env, jobj, "eis", "J" ); // does not deref
+ int result, count=0;
+
+ char message[80];
+
+ ENTER( "SerialImp.c:drain()" );
+@@ -1545,16 +1545,21 @@
+
+ sprintf( message, "RXTXPort:drain() returns: %i\n", result );
+ report_verbose( message );
+ #if defined(__sun__)
+ /* FIXME: No time to test on all OS's for production */
++ deref_java_object(env, jobj);
+ return( JNI_TRUE );
+ #endif /* __sun__ */
+ LEAVE( "RXTXPort:drain()" );
+ if( result ) throw_java_exception( env, IO_EXCEPTION, "nativeDrain",
+ strerror( errno ) );
+- if( interrupted ) return( JNI_FALSE );
++ if( interrupted )
++ {
++ deref_java_object(env, jobj);
++ return( JNI_FALSE );
++ }
+ #if !defined(TIOCSERGETLSR) && !defined(WIN32)
+ if( eis && eis->writing )
+ {
+ eis->writing=JNI_FALSE;
+ eis->output_buffer_empty_flag = 0;
+@@ -1565,10 +1570,12 @@
+ struct event_info_struct myeis =
+ build_threadsafe_eis( env, &jobj, eis );
+ send_event( &myeis, SPE_OUTPUT_BUFFER_EMPTY, 1 );
+ }
+ report_time_end( );
++
++ deref_java_object(env, jobj);
+ return( JNI_FALSE );
+ }
+
+ /*----------------------------------------------------------
+ RXTXPort.sendBreak
+@@ -2937,11 +2944,11 @@
+ struct timeval tv, *tvP;
+ fd_set rset;
+ /* TRENT */
+ int flag, count = 0;
+ struct event_info_struct *eis = ( struct event_info_struct * )
+- get_java_var( env, *jobj,"eis","J" );
++ get_java_varP( env, *jobj,"eis","J" ); // does not dereference object (pointer remains valid)
+
+ report_time_start();
+ flag = eis->eventflags[SPE_DATA_AVAILABLE];
+ eis->eventflags[SPE_DATA_AVAILABLE] = 0;
+ /*
+@@ -2957,10 +2964,11 @@
+ if (timeout >= 0) {
+ now = GetTickCount();
+ if ( now-start >= timeout )
+ {
+ eis->eventflags[SPE_DATA_AVAILABLE] = flag;
++ deref_java_object( env, *jobj );
+ return bytes;
+ }
+ }
+
+ FD_ZERO(&rset);
+@@ -2983,22 +2991,25 @@
+ #endif /* WIN32 */
+ if (ret == -1){
+ report( "read_byte_array: select returned -1\n" );
+ LEAVE( "read_byte_array" );
+ eis->eventflags[SPE_DATA_AVAILABLE] = flag;
++ deref_java_object( env, *jobj );
+ return -1;
+ }
+ else if (ret > 0)
+ {
+ if ((ret = READ( fd, buffer + bytes, left )) < 0 ){
+ if (errno != EINTR && errno != EAGAIN){
+ report( "read_byte_array: read returned -1\n" );
+ LEAVE( "read_byte_array" );
+ eis->eventflags[SPE_DATA_AVAILABLE] = flag;
++ deref_java_object( env, *jobj );
+ return -1;
+ }
+ eis->eventflags[SPE_DATA_AVAILABLE] = flag;
++ deref_java_object( env, *jobj );
+ return -1;
+ }
+ else if ( ret ) {
+ bytes += ret;
+ left -= ret;
+@@ -3031,10 +3042,12 @@
+ report( msg );
+ LEAVE( "read_byte_array" );
+ report_time_end();
+ */
+ eis->eventflags[SPE_DATA_AVAILABLE] = flag;
++
++ deref_java_object( env, *jobj );
+ return bytes;
+ }
+
+ #ifdef asdf
+ int read_byte_array( JNIEnv *env,
+@@ -4898,10 +4911,43 @@
+ LEAVE( "get_java_var" );
+ */
+ return result;
+ }
+
++void deref_java_object( JNIEnv *env, jobject jobj )
++{
++ jclass jclazz = (*env)->GetObjectClass( env, jobj );
++ (*env)->DeleteLocalRef( env, jclazz );
++}
++
++void * get_java_varP( JNIEnv *env, jobject jobj, char *id, char *type )
++{
++ void * result = 0;
++ jclass jclazz = (*env)->GetObjectClass( env, jobj );
++ jfieldID jfd = (*env)->GetFieldID( env, jclazz, id, type );
++
++/*
++ ENTER( "get_java_var" );
++*/
++ if( !jfd ) {
++ (*env)->ExceptionDescribe( env );
++ (*env)->ExceptionClear( env );
++ (*env)->DeleteLocalRef( env, jclazz );
++ LEAVE( "get_java_var" );
++ return result;
++ }
++ result = (void *)( (*env)->GetObjectField( env, jobj, jfd ) );
++/* ct7 & gel * Added DeleteLocalRef */
++// (*env)->DeleteLocalRef( env, jclazz );
++ if(!strncmp( "fd",id,2) && result == 0)
++ report_error( "get_java_var: invalid file descriptor\n" );
++/*
++ LEAVE( "get_java_var" );
++*/
++ return result;
++}
++
+ /*----------------------------------------------------------
+ throw_java_exception
+
+ accept: env (keyhole to java)
+ *exc (exception class name)
diff --git a/comms/rxtx/files/patch-SerialImp.cpp b/comms/rxtx/files/patch-SerialImp.cpp
new file mode 100644
index 000000000000..0a2688dab8d3
--- /dev/null
+++ b/comms/rxtx/files/patch-SerialImp.cpp
@@ -0,0 +1,53 @@
+--- src/SerialImp.cpp.orig 2004-10-12 01:59:27.000000000 -0700
++++ src/SerialImp.cpp 2010-12-06 21:48:20.000000000 -0800
+@@ -1736,10 +1736,50 @@
+ report("invalid file descriptor\n");
+ #endif
+ return result;
+ }
+
++void deref_java_object( JNIEnv *env, jobject jobj )
++{
++ jclass jclazz = env->GetObjectClass( env, jobj );
++ env->DeleteLocalRef( env, jclazz );
++}
++
++void * get_java_varP( JNIEnv *env, jobject jobj, char *id, char *type )
++{
++
++
++ ////////////////// Open Log File /////////////////////
++ fp = fopen("RXTXOut.log", "a");
++ fprintf(fp, "Brian is inside get_java_varP\n"); // !!!
++ fclose(fp);
++ ////////////////// Close Log File ////////////////////
++
++ void * result = 0;
++ //jclass jclazz = (*env)->GetObjectClass( env, jobj );
++ jclass jclazz = env->GetObjectClass( jobj ); // !!!
++ //jfieldID jfd = (*env)->GetFieldID( env, jclazz, id, type );
++ jfieldID jfd = env->GetFieldID( jclazz, id, type ); // !!!
++
++ if( !jfd ) {
++ //(*env)->ExceptionDescribe( env );
++ env->ExceptionDescribe(); // !!!
++ //(*env)->ExceptionClear( env );
++ env->ExceptionClear(); // !!!
++ return result;
++ }
++ //result = (int)( (*env)->GetIntField( env, jobj, jfd ) );
++ result = (void *)( env->GetIntField( jobj, jfd ) ); // !!!
++/* ct7 & gel * Added DeleteLocalRef */
++ //(*env)->DeleteLocalRef( env, jclazz );
++// env->DeleteLocalRef( jclazz ); // !!!
++#ifdef DEBUG
++ if(!strncmp("fd",id,2) && result == 0)
++ report("invalid file descriptor\n");
++#endif
++ return result;
++}
+ /*----------------------------------------------------------
+ throw_java_exception
+
+ accept: env (keyhole to java)
+ *exc (exception class name)
diff --git a/comms/rxtx/files/patch-SerialImp.h b/comms/rxtx/files/patch-SerialImp.h
new file mode 100644
index 000000000000..2bc501079634
--- /dev/null
+++ b/comms/rxtx/files/patch-SerialImp.h
@@ -0,0 +1,16 @@
+--- src/SerialImp.h.orig 2005-07-05 10:47:21.000000000 -0700
++++ src/SerialImp.h 2010-12-05 21:47:42.000000000 -0800
+@@ -438,8 +438,13 @@
+ void system_does_not_unlock( const char *, int );
+ int check_group_uucp();
+ int check_lock_pid( const char *, int );
+ int printj(JNIEnv *env, wchar_t *fmt, ...);
+
++// BBB added
++void deref_java_object( JNIEnv *env, jobject jobj );
++void * get_java_varP( JNIEnv *env, jobject jobj, char *id, char *type );
++
++
+ #define UNEXPECTED_LOCK_FILE "RXTX Error: Unexpected lock file: %s\n Please report to the RXTX developers\n"
+ #define LINUX_KERNEL_VERSION_ERROR "\n\n\nRXTX WARNING: This library was compiled to run with OS release %s and you are currently running OS release %s. In some cases this can be a problem. Try recompiling RXTX if you notice strange behavior. If you just compiled RXTX make sure /usr/include/linux is a symbolic link to the include files that came with the kernel source and not an older copy.\n\n\npress enter to continue\n"
+ #define UUCP_ERROR "\n\n\nRXTX WARNING: This library requires the user running applications to be in\ngroup uucp. Please consult the INSTALL documentation. More information is\navaiable under the topic 'How can I use Lock Files with rxtx?'\n"