aboutsummaryrefslogtreecommitdiff
path: root/mail/dbmail20/files/patch-2.0.4_bug190_server.c
blob: 23129a5c8b527c99cc86f7619a8ff726b0c1d555 (plain) (blame)
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
Index: server.c
===================================================================
--- server.c	(revision 1600)
+++ server.c	(revision 1758)
@@ -119,9 +119,15 @@
  	alarm(10);
   
  	trace(TRACE_DEBUG, "StartServer(): children created, starting main service loop");
- 	while (!GeneralStopRequested) 
- 		manage_restart_children();
-   
+ 	while (!GeneralStopRequested) {
+		if (db_connect() != 0) {
+			GeneralStopRequested=1;
+		} else {
+			db_disconnect();
+ 			manage_restart_children();
+		}
+	}
+
  	manage_stop_children();
  	scoreboard_delete();
  
@@ -131,6 +137,8 @@
 
 void ParentSigHandler(int sig, siginfo_t * info, void *data)
 {
+	int saved_errno = errno;
+	
 	if (ParentPID != getpid()) {
 		trace(TRACE_INFO,
 		      "ParentSigHandler(): i'm no longer father");
@@ -162,6 +170,8 @@
 	default:
 		GeneralStopRequested = 1;
 	}
+
+	errno = saved_errno;
 }