-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgcov.patch
106 lines (97 loc) · 3.11 KB
/
gcov.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
diff --git a/Source/Release/makefile b/Source/Release/makefile
index 2241106..6248625 100644
--- a/Source/Release/makefile
+++ b/Source/Release/makefile
@@ -28,7 +28,7 @@ all: fftp
fftp: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C Linker'
- gcc -o "fftp" $(OBJS) $(USER_OBJS) $(LIBS)
+ $(CC) $(CFLAGS) -o "fftp" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
diff --git a/Source/Release/subdir.mk b/Source/Release/subdir.mk
index f520c4d..bcf6f32 100644
--- a/Source/Release/subdir.mk
+++ b/Source/Release/subdir.mk
@@ -26,7 +26,7 @@ C_DEPS += \
%.o: ../%.c
@echo 'Building file: $<'
@echo 'Invoking: GCC C Compiler'
- gcc -std=c99 -O3 -Wall -Wextra -c -fmessage-length=0 -Wno-unused-parameter -Wno-unused-result -fno-ident -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<"
+ $(CC) $(CFLAGS) -std=c99 -O3 -Wall -Wextra -c -fmessage-length=0 -Wno-unused-parameter -Wno-unused-result -fno-ident -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '
diff --git a/Source/ftpserv.c b/Source/ftpserv.c
index d63d993..3d70357 100644
--- a/Source/ftpserv.c
+++ b/Source/ftpserv.c
@@ -2036,6 +2036,9 @@ void *ftpmain(void *p)
close(clientsocket);
}
}
+ //Terminate the main thread when the child thread terminates
+ pthread_join(th, NULL);
+ break;
}
free(scb);
diff --git a/Source/main.c b/Source/main.c
index eaa1a55..8fa1d27 100644
--- a/Source/main.c
+++ b/Source/main.c
@@ -11,6 +11,8 @@
#include "ftpserv.h"
#include "cfgparse.h"
#include "x_malloc.h"
+#include <signal.h>
+#include <unistd.h>
FTP_CONFIG g_cfg;
int g_log = -1;
@@ -24,6 +26,12 @@ static char CAFILE[PATH_MAX],
KEYFILE[PATH_MAX],
KEYFILE_PASS[256];
+extern void __gcov_flush();
+static void catch_function(int signal) {
+ __gcov_flush();
+ _exit(0);
+}
+
void TLSInit()
{
while (gnutls_global_init() >= 0)
@@ -76,7 +84,11 @@ int main(int argc, char *argv[])
int c;
uint32_t bufsize = 65536;
pthread_t thid;
-
+ signal(SIGUSR1, catch_function);
+ signal(SIGINT, catch_function);
+ signal(SIGSEGV, catch_function);
+ signal(SIGABRT, catch_function);
+ signal(SIGTERM, catch_function);
if (sizeof (off_t) != 8)
{
printf("off_t is not 64 bits long");
@@ -106,9 +118,10 @@ int main(int argc, char *argv[])
if (ParseConfig(cfg, CONFIG_SECTION_NAME, "local_mask", textbuf, bufsize))
g_cfg.LocalIPMask = inet_addr(textbuf);
- g_cfg.Port = DEFAULT_FTP_PORT;
- if (ParseConfig(cfg, CONFIG_SECTION_NAME, "port", textbuf, bufsize))
- g_cfg.Port = strtoul(textbuf, NULL, 10);
+ //g_cfg.Port = DEFAULT_FTP_PORT;
+ //if (ParseConfig(cfg, CONFIG_SECTION_NAME, "port", textbuf, bufsize))
+ // g_cfg.Port = strtoul(textbuf, NULL, 10);
+ g_cfg.Port = strtoul(argv[2], NULL, 10);
g_cfg.MaxUsers = 1;
if (ParseConfig(cfg, CONFIG_SECTION_NAME, "maxusers", textbuf, bufsize))
@@ -188,10 +201,8 @@ int main(int argc, char *argv[])
break;
}
- do {
- c = getc(stdin);
- sleep(1);
- } while ((c != 'q') && (c != 'Q'));
+ //Terminate the server when the main thread terminates
+ pthread_join(thid, NULL);
break;
}