From ec70f4cb47d5c2e51d59a351b751fde571923d15 Mon Sep 17 00:00:00 2001 From: MissValeska Date: Wed, 7 May 2014 18:57:20 -0700 Subject: [PATCH] Changed SIGKILL to SIGINT, So Netsukuku will clean and save everything properly. I, Also, Added more stuff to inet_sendto for packet division in the case of errno 90. Still working --- src/inet.c | 19 ++++++++++++------- src/netsukuku.c | 4 ++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/inet.c b/src/inet.c index 158d2b4..d79b268 100644 --- a/src/inet.c +++ b/src/inet.c @@ -1053,18 +1053,23 @@ ssize_t inet_sendto(int s, const void *msg, size_t len, int flags, ssize_t err; fd_set fdset; int ret; - int errno_int; - + + error("Socket: %i Data: %p Data Length: %u Flags: %i Address: %p Address Length: %u", s, msg, len, flags, to, tolen); + if((err=sendto(s, msg, len, flags, to, tolen))==-1) { - errno_int = errno; error("sendto errno: %d err is: %d", errno, err); - switch(errno_int) + switch(errno) { case EMSGSIZE: error("Packet artificially fragmented: %d", stderr); - inet_sendto(s, msg, len/2, flags, to, tolen); - err=inet_sendto(s, ((const char *)msg+(len/2)), - len-(len/2), flags, to, tolen); + error("\nData Length: %u", len); + int bytesleft = len; + while(bytesleft > 1024) { + inet_sendto(s, msg, 1024, flags, to, tolen); + bytesleft -= 1024; + //err=inet_sendto(s, ((const char *)msg+(len/2)), + //len-(len/2), flags, to, tolen); + } break; case EFAULT: error("The value of to is: %d", to); diff --git a/src/netsukuku.c b/src/netsukuku.c index 66d49fc..08541b9 100644 --- a/src/netsukuku.c +++ b/src/netsukuku.c @@ -367,11 +367,11 @@ void parse_options(int argc, char **argv) if(is_ntkd_already_running() == 1){ char process_name[256] = {0}; pid_t pid; - printf("...Shutting down ntkd...\n"); + printf("...Closing ntkd...\n"); FILE *fd=fopen(server_opt.pid_file, "r"); while(fscanf(fd, "%s %d", process_name, &pid)!=EOF) { if(strcmp(process_name, "ntkd") == 0) { - kill(pid, SIGKILL); + kill(pid, SIGINT); } } fclose(fd);