From 1d3901569ecbe5f91846cde27fd84ec156488459 Mon Sep 17 00:00:00 2001 From: mukesh2006 Date: Wed, 15 Jan 2025 18:35:36 +0400 Subject: [PATCH] Assignment 8: Bug rmmod: ERROR: Module is in use --- aesd-char-driver/Makefile | 3 +++ server/aesdsocket.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/aesd-char-driver/Makefile b/aesd-char-driver/Makefile index e4cd5ca..31dc474 100644 --- a/aesd-char-driver/Makefile +++ b/aesd-char-driver/Makefile @@ -20,6 +20,9 @@ else KERNELDIR ?= /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) +#adding default rule +all: modules + modules: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules diff --git a/server/aesdsocket.c b/server/aesdsocket.c index 59a4e5a..7f3a41f 100644 --- a/server/aesdsocket.c +++ b/server/aesdsocket.c @@ -119,8 +119,8 @@ int main(int argc, char* argv[]) setup_print_time_thread(10); // h. Restarts accepting connections from new clients forever in a loop until SIGINT or SIGTERM is received - syslog(LOG_DEBUG,"Entering While (true)\n"); - printf("Entering While (true)\n"); + syslog(LOG_DEBUG,"Entering While (true) Now\n"); + printf("Entering While (true) Now\n"); while(true) { @@ -244,7 +244,7 @@ void* connection_handler_thread_fxn(void* thread_parameter) int number_of_bytes_sent = 0; int number_of_bytes_read = 0; - + printf("\nconnection_handler_thread_fxn: number_of_bytes_read = recv(thread_func_args->client_fd, read_buffer, RECEIVE_PACKET_SIZE, 0)) > 0 \n"); while((number_of_bytes_read = recv(thread_func_args->client_fd, read_buffer, RECEIVE_PACKET_SIZE, 0)) > 0) { printf("\nconnection_handler_thread_fxn: received_data_file_fd = fopen(RECEIVE_DATA_FILE) \n"); @@ -262,6 +262,7 @@ void* connection_handler_thread_fxn(void* thread_parameter) } } // f. Returns the full content of /var/tmp/aesdsocketdata to the client as soon as the received data packet completes. + received_data_file_fd = fopen(RECEIVE_DATA_FILE, "w+"); lseek(fileno(received_data_file_fd), 0, SEEK_SET); while((number_of_bytes_sent = read(fileno(received_data_file_fd), read_buffer, RECEIVE_PACKET_SIZE)) > 0) {