summaryrefslogtreecommitdiff
path: root/net/udpcast/files/patch-udpr-negotiate.c
blob: db9f50ba147def13a89795dd8b418e77f5799238 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--- udpr-negotiate.c.orig	Sat Feb 21 14:08:49 2004
+++ udpr-negotiate.c	Tue Jul 20 13:44:05 2004
@@ -2,6 +2,10 @@
 #include <unistd.h>
 #include <errno.h>
 
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
 #include "log.h"
 #include "socklib.h"
 #include "udpcast.h"
@@ -16,6 +20,10 @@
 # define O_BINARY 0
 #endif
 
+#ifdef __FreeBSD__
+struct client_config client_config_on_exit_hack;
+#endif
+
 static int sendConnectReq(struct client_config *client_config,
 			  struct net_config *net_config,
 			  int haveServerAddress) {
@@ -48,6 +56,12 @@
     sendDisconnect(exitStatus, (struct client_config *) args);
 }
 
+#ifdef __FreeBSD__
+static void sendDisconnectWrapper_on_exit_handler() {
+    sendDisconnectWrapper(0, &client_config_on_exit_hack);
+}
+#endif
+
 void sendDisconnect(int exitStatus,
 		    struct client_config *client_config) {    
     int endianness = client_config->endianness;
@@ -144,7 +158,7 @@
     if(disk_config->fileName != NULL) {
 	int oflags = O_CREAT | O_WRONLY;
 	if(!(disk_config->flags & FLAG_NOSYNC)) {
-	    oflags |= O_SYNC;
+	    oflags |= O_FSYNC;
 	}
 	outFile = open(disk_config->fileName, oflags | O_BINARY, 0644);
 	if(outFile < 0) {
@@ -333,7 +347,13 @@
     pipedOutFile = openPipe(client_config.toServer, outFile, disk_config,
 			    &pipePid);
 #ifndef __CYGWIN__
+# ifdef __FreeBSD__
+    client_config_on_exit_hack = client_config;
+
+    atexit(sendDisconnectWrapper_on_exit_handler);
+# else
     on_exit(sendDisconnectWrapper, &client_config);
+# endif
 #endif
     {
 	struct fifo fifo;