Skip to content

Commit c18b290

Browse files
rootdilyanpalauzov
authored andcommitted
SerialImp.c:RXTXPort(open) - on failure release file descriptor and lock
NeuronRobotics#259
1 parent 6c1427b commit c18b290

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/c/src/SerialImp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,11 +729,16 @@ JNIEXPORT jint JNICALL RXTXPort(open)(
729729
report_error( message );
730730

731731
close(fd);
732+
UNLOCK(filename, pid);
732733
goto fail;
733734
}
734735
#endif /* OPEN_EXCL */
735736

736-
if( configure_port( fd ) ) goto fail;
737+
if( configure_port( fd ) ) {
738+
close(fd);
739+
UNLOCK(filename, pid);
740+
goto fail;
741+
}
737742
(*env)->ReleaseStringUTFChars( env, jstr, filename );
738743
snprintf( message, sizeof(message), "open: fd returned is %i\n", fd );
739744
report( message );

0 commit comments

Comments
 (0)