~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to debian/patches/odbc.patch

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2010-11-14 12:25:50 UTC
  • Revision ID: james.westby@ubuntu.com-20101114122550-szjmghsv58010ux6
Tags: 1:14.a-dfsg-3
* Fixed a few spelling errors in packages descriptions and Debian changelog
  entries (closes: #592995, #597464).
* Applised patch by upstream which fixes wx application crash
  (closes: #592821).
* Switched to the old OpenSSL-based SSL implementation by default (it is
  still less buggy then the new one written in Erlang).
* Enabled IPv6 for odbcserver and prefer IPv4 in odbc.erl to make odbc
  application working in IPv6-only environment (closes: #598525).
* Overridden lintian error mesage about embedded pcre3 library because it
  is patched and cannot be replaced by a system one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Author: Upstream
 
2
Description: Fixes connecting odbcserver back to Erlang VM in IPv6-only
 
3
 environment
 
4
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=598525
 
5
Forwarded: not-needed
 
6
Last-updated: Sun, 14 Nov 2010 12:20:41 +0300
 
7
 
 
8
--- erlang-14.a-dfsg.orig/lib/odbc/src/odbc.erl
 
9
+++ erlang-14.a-dfsg/lib/odbc/src/odbc.erl
 
10
@@ -441,10 +441,12 @@ init(Args) ->
 
11
 
 
12
     {ok, ListenSocketSup} =
 
13
        gen_tcp:listen(0, [Inet, binary, {packet, ?LENGTH_INDICATOR_SIZE},
 
14
-                          {active, false}, {nodelay, true}]),
 
15
+                          {active, false}, {nodelay, true},
 
16
+                          {ip, loopback}]),
 
17
     {ok, ListenSocketOdbc} =
 
18
        gen_tcp:listen(0, [Inet, binary, {packet, ?LENGTH_INDICATOR_SIZE},
 
19
-                          {active, false}, {nodelay, true}]),
 
20
+                          {active, false}, {nodelay, true},
 
21
+                          {ip, loopback}]),
 
22
 
 
23
     %% Start the port program (a c program) that utilizes the odbc driver 
 
24
     case os:find_executable(?SERVERPROG, ?SERVERDIR) of
 
25
--- erlang-14.a-dfsg.orig/lib/odbc/c_src/odbcserver.c
 
26
+++ erlang-14.a-dfsg/lib/odbc/c_src/odbcserver.c
 
27
@@ -1727,74 +1727,48 @@ static byte * receive_erlang_port_msg(void)
 
28
 }
 
29
  
 
30
 /* ------------- Socket communication functions --------------------------*/
 
31
-#define USE_IPV4
 
32
-#ifdef UNIX
 
33
-#define SOCKET int   
 
34
-#endif
 
35
 
 
36
-#if defined WIN32 || defined USE_IPV4
 
37
-/* Currently only an old windows compiler is supported so we do not have ipv6
 
38
-  capabilities */
 
39
+#if defined(WIN32)
 
40
 static SOCKET connect_to_erlang(const char *port)
 
41
-{
 
42
-    SOCKET sock;
 
43
-    struct sockaddr_in sin;
 
44
-    
 
45
-    sock = socket(AF_INET, SOCK_STREAM, 0);
 
46
-    
 
47
-    memset(&sin, 0, sizeof(sin));
 
48
-    sin.sin_port = htons ((unsigned short)atoi(port));
 
49
-    sin.sin_family = AF_INET;
 
50
-    sin.sin_addr.s_addr = inet_addr("127.0.0.1");
 
51
-    
 
52
-    if (connect(sock, (struct sockaddr*)&sin, sizeof(sin)) != 0) {
 
53
-        close_socket(sock);
 
54
-        DO_EXIT(EXIT_SOCKET_CONNECT);
 
55
-    }
 
56
-    return sock;
 
57
-}
 
58
 #elif defined(UNIX)
 
59
 static int connect_to_erlang(const char *port)
 
60
+#endif
 
61
 {
 
62
-    int sock;
 
63
-    
 
64
-    struct addrinfo hints;
 
65
-    struct addrinfo *erlang_ai, *first;
 
66
-    
 
67
-    memset(&hints, 0, sizeof(hints));
 
68
-    hints.ai_family = PF_UNSPEC; /* PF_INET or PF_INET6 */
 
69
-    hints.ai_socktype = SOCK_STREAM;
 
70
-    hints.ai_protocol = IPPROTO_TCP;
 
71
-    
 
72
-    if (getaddrinfo("localhost", port, &hints, &first) != 0) {
 
73
-       DO_EXIT(EXIT_FAILURE);
 
74
-    }
 
75
+#if defined(WIN32)
 
76
+       SOCKET sock;
 
77
+#elif defined(UNIX)
 
78
+       int sock;
 
79
+#endif
 
80
+       struct sockaddr_in sin;
 
81
+
 
82
+#if defined(AF_INET6)
 
83
+       struct sockaddr_in6 sin6;
 
84
+
 
85
+       sock = socket(AF_INET6, SOCK_STREAM, 0);
 
86
+
 
87
+       memset(&sin6, 0, sizeof(sin6));
 
88
+       sin6.sin6_port = htons ((unsigned short)atoi(port));
 
89
+       sin6.sin6_family = AF_INET6;
 
90
+       sin6.sin6_addr = in6addr_loopback;
 
91
     
 
92
-    for (erlang_ai = first; erlang_ai; erlang_ai = erlang_ai->ai_next) {
 
93
+       if (connect(sock, (struct sockaddr*)&sin6, sizeof(sin6)) == 0) {
 
94
+               return sock;
 
95
+       }
 
96
+       close_socket(sock);
 
97
+#endif
 
98
+       sock = socket(AF_INET, SOCK_STREAM, 0);
 
99
+
 
100
+       memset(&sin, 0, sizeof(sin));
 
101
+       sin.sin_port = htons ((unsigned short)atoi(port));
 
102
+       sin.sin_family = AF_INET;
 
103
+       sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 
104
        
 
105
-       sock = socket(erlang_ai->ai_family, erlang_ai->ai_socktype,
 
106
-                     erlang_ai->ai_protocol);
 
107
-       if (sock < 0)
 
108
-           continue;
 
109
-       if (connect(sock,  (struct sockaddr*)erlang_ai->ai_addr,
 
110
-                   erlang_ai->ai_addrlen) < 0) {
 
111
-           close(sock); 
 
112
-           sock = -1;
 
113
-           continue;
 
114
-       } else {
 
115
-           break;
 
116
+       if (connect(sock, (struct sockaddr*)&sin, sizeof(sin)) != 0) {
 
117
+               close_socket(sock);
 
118
+               DO_EXIT(EXIT_SOCKET_CONNECT);
 
119
        }
 
120
-    }
 
121
-    freeaddrinfo(first); 
 
122
-    
 
123
-    if (sock < 0){
 
124
-       close_socket(sock); 
 
125
-       DO_EXIT(EXIT_SOCKET_CONNECT); 
 
126
-    }
 
127
-    
 
128
-    return sock;
 
129
+       return sock;
 
130
 }
 
131
-#endif
 
132
 
 
133
 #ifdef WIN32
 
134
 static void close_socket(SOCKET socket)