Skip to content

Commit 491ca47

Browse files
ValerioNeriGitandreabac3
authored andcommitted
Fixed BAD File descriptor in memory mapping
1 parent 8aa7db4 commit 491ca47

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

gopher_log_file.txt

+3
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ L-> FileName: /opt/local_projects/gopher-project/windows/keep.sh 172 Byte IP
5050
L-> FileName: /opt/local_projects/gopher-project/windows/keep.sh 172 Byte IP Client: 127.0.0.1 cloud.valerioneri.com Port: 7080
5151
L-> FileName: /opt/local_projects/gopher-project/windows/keep.sh 172 Byte IP Client: 127.0.0.1 cloud.valerioneri.com Port: 7080
5252
L-> FileName: /opt/local_projects/gopher-project/windows/keep.sh 172 Byte IP Client: 127.0.0.1 cloud.valerioneri.com Port: 7080
53+
L-> FileName: /opt/local_projects/gopher-project/windows/keep.sh 172 Byte IP Client: 127.0.0.1 cloud.valerioneri.com Port: 7080
54+
L-> FileName: /opt/local_projects/gopher-project/windows/keep.sh 172 Byte IP Client: 127.0.0.1 cloud.valerioneri.com Port: 7080
55+
L-> FileName: /opt/local_projects/gopher-project/windows/keep.sh 172 Byte IP Client: 127.0.0.1 cloud.valerioneri.com Port: 7080

linux/lib/memory_mapping/linux_memory_mapping.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,17 @@ int linux_memory_mapping(void *params) {
4242
// log_ut("FD %d \n PATH %s \n %d\n", args->fd, args->path, args->mode_concurrency);
4343
struct stat sb;
4444

45-
int fd = open(args->path, O_RDONLY);
45+
int fd = open(args->path, O_RDWR);
4646
if (fd == -1) {
4747
perror("linux_memory_mapping/open");
4848
return -1;
4949
}
5050

5151
printf("fd valid: %d\n", fd_is_valid(fd));
5252

53-
vlog_ut(1, "Lock status: %d\n", lockf(fd, F_TLOCK, 0));
54-
perror("linux_memory_mapping/lockf F_TLOCK failed");
5553
if (args->mode_concurrency == M_PROCESS) {
5654
if (lockf(fd, F_LOCK, 0) == -1) {
57-
58-
vlog_ut(1, "Lock status: %d\n", lockf(fd, F_TLOCK, 0));
5955
perror("linux_memory_mapping/lockf F_LOCK failed");
60-
6156
}
6257
} else {
6358
if (pthread_mutex_lock(&p_mutex) != 0) {

0 commit comments

Comments
 (0)