/[classpath]/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
ViewVC logotype

Diff of /classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by rsdio, Sat Jul 30 20:40:30 2005 UTC revision 1.24 by mark, Sun Jul 31 16:00:43 2005 UTC
# Line 851  Java_gnu_java_nio_channels_FileChannelIm Line 851  Java_gnu_java_nio_channels_FileChannelIm
851    flock.l_type = shared ? F_RDLCK : F_WRLCK;    flock.l_type = shared ? F_RDLCK : F_WRLCK;
852    flock.l_whence = SEEK_SET;    flock.l_whence = SEEK_SET;
853    flock.l_start = (off_t) position;    flock.l_start = (off_t) position;
854    flock.l_len = (off_t) size;    /* Long.MAX_VALUE means lock everything possible starting at pos. */
855      if (size == 9223372036854775807LL)
856        flock.l_len = 0;
857      else
858        flock.l_len = (off_t) size;
859    
860    ret = fcntl (fd, cmd, &flock);    ret = fcntl (fd, cmd, &flock);
861      /* fprintf(stderr, "fd %d, wait %d, shared %d, ret %d, position %lld, size %lld, l_start %ld, l_len %ld\n", fd, wait, shared,ret, position, size, (long) flock.l_start, (long) flock.l_len); */
862    if (ret)    if (ret)
863      {      {
864        /* Linux man pages for fcntl state that errno might be either        /* Linux man pages for fcntl state that errno might be either
865           EACCES or EAGAIN if we try F_SETLK, and another process has           EACCES or EAGAIN if we try F_SETLK, and another process has
866           an overlapping lock. */           an overlapping lock. We should not get an unexpected errno. */
867        if (errno != EACCES && errno != EAGAIN)        if (errno != EACCES && errno != EAGAIN)
868          {          {
869            JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));            JCL_ThrowException (env, "java/lang/InternalError",
870                                  strerror (errno));
871          }          }
872        return JNI_FALSE;        return JNI_FALSE;
873      }      }
# Line 892  Java_gnu_java_nio_channels_FileChannelIm Line 898  Java_gnu_java_nio_channels_FileChannelIm
898    flock.l_type = F_UNLCK;    flock.l_type = F_UNLCK;
899    flock.l_whence = SEEK_SET;    flock.l_whence = SEEK_SET;
900    flock.l_start = (off_t) position;    flock.l_start = (off_t) position;
901    flock.l_len = (off_t) length;    /* Long.MAX_VALUE means unlock everything possible starting at pos. */
902      if (length == 9223372036854775807LL)
903        flock.l_len = 0;
904      else
905        flock.l_len = (off_t) length;
906    
907    ret = fcntl (fd, F_SETLK, &flock);    ret = fcntl (fd, F_SETLK, &flock);
908    if (ret)    if (ret)
909      {      {
910        JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));        JCL_ThrowException (env, "java/lang/InternalError",
911                              strerror (errno));
912      }      }
913  #else  #else
914    (void) obj;    (void) obj;

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26